Automatic Encoding of MythTV Recordings To avi or mkv on Ubuntu 10.04 Lucid (Mythbuntu)

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

This tutorial assumes that you have a working MythTV setup. If you came here looking how to setup MythTV, please look at the related posts at the end of this post to help you out with the setup.

mythnuv2mkv is a great script to convert your MythTV recordings to avi or mkv (h.264). You can run it manually to convert your recordings as and when you want or set it up such that the entire process is managed through the mythtv frontend via a User Job. The User Job will also remove commercials (if a cutlist has been created manually), save the job to a mkv or avi file and then move the file to a specified folder (of your choice). You can configure all these options and more based on your requirements. The credit should go the the creator of this (thank you Duffy for this tutorial for arch linux), on which this tutorial is based, with a few minor modifications and adaptations for Ubuntu.

With this setup you would be able to start the conversion or transcoding process from any front end or even via Mythweb if you have it setup. Let’s start with a quick overview of things we need to do.The process can be broken down as follows in terms of what you need to do at the backend and what you would need to do at the frontend:

Backend

1. Download and edit mythnuv2mkv.sh (change one line)
2. Install the required applications to get mythnuv2mkv working
3. Run a test transcode
4. Set up a User Job in mythtv

Frontend

5. Create a cutlist for a recording, important if you want the encoded video to be free from commercials
6. Run the User Job on your recording

Step 1: Download

Tthe latest version of mythnuv2mkv.sh (1.6 at the time of writing this tutorial) can be downloaded from here.

The download page has detailed instructions on all the runtime options for encoding. They are very simple to use and I would recommend you glance over them. Once the download is over, open the script in a text editor (say gedit) and make the following changes

gedit mythnuv2mkv.sh

Go to the line which looks like this

readonly DEFAULTMPEG2ASPECT=”NA” # 4:3 or 16:9

and replace “NA” with the aspect ratio you want, I would recommend you put 16:9, while IMHO either of them should work fine. So now that line should look like this

readonly DEFAULTMPEG2ASPECT=16:9 # 4:3 or 16:9

Save the file and exit the text editor, now we need to make the file executable by running the following command:

chmod a+x mythnuv2mkv.sh

Step 2: Install the dependencies for mythnuv2mkv script

You can install all of them in one go by executing this command

sudo apt-get install mythtv-transcode-utils perl mplayer mencoder wget imagemagick lame liblame0 x264 faac libfaac0 faad libfaad0 mkvtoolnix vorbis-tools gpac

Alright this should set the script ready to get going.

Step 3: Run a test transcode

Do a five minute recording to test the script out. By default your recordings would be in /var/lib/mythtv/recordings folder. You can go to that folder and launch this script from there or launch it from the folder where it is located by doing something like this

./mythnuv2mkv.sh –contype=mkv –quality=med –pass=one –crop=OFF /var/lib/mythtv/recordings/1201_20100804230000.mpg

don’t forget to replace the file name with that of your recording. Beware, this command in its current setup would remove your original recording, so don’t run it on something which you want to archive. This should start the encoding process, currently it is set to transcode to mkv with medium quality in a single pass without doing auto cropping. If the script exits successfully and you have a .mkv file lying in the recording directory, then you should be ready to proceed to next step. But before you get there move the script to /usr/bin or create a shortcut (symbolic link) for it in /usr/bin by doing either of the two

sudo mv mythnuv2mkv.sh /usr/bin/

or

sudo ln -s /absolute_path_to_current_directory/mythnuv2mkv.sh /usr/bin/mythnuv2mkv

Step 4: Setup user job(s) for encoding

Now launch the MythTV backend setup from System>Administration menu. From the home screen choose  1.General

Keep hitting next button till you get the screen titled “Job Queue (Backend Specific)”.  Make tick against the boxes which says Job # 1 etc depending on the number of jobs you want to create. In my case I have created two jobs the names of which are visible in this screenshot below, instead of these you would see Allow User Job #1 jobs, #2 etc.

Keep hitting next again for a couple of times till you reach the screen that says Job Queue (Job Commands), you would need to enter the command you want to be executed, as well as you can change the name of Commands to be make them more obvious.

I created two jobs with different quality settings using the following commands, after the encoding I want to move them to my XBMC video folder, if you don’t want that you can customize or get rid of the –copydir=/home/your_username/Videos option.

mythnuv2mkv.sh –jobid=%JOBID% –quality=480 –crop=OFF –copydir=/home/your_username/Videos –chanid=%CHANID% –starttime=%STARTTIME%

mythnuv2mkv.sh –jobid=%JOBID% –quality=780 –crop=OFF –copydir=/home/your_username/Videos –chanid=%CHANID% –starttime=%STARTTIME%

After entering the Job command and names, keep hitting next till you reach the main menu again. Now close mythbackend and move to your Frontend machine.

5. Create a cutlist

The mythnuv2mkv.sh script will honour any cutlist that has been created. The cutlist just marks the segments of the file you want deleted from the recording (typically, commercials and any buffer you may have at the start and end of the recording). Running commercial flagging itself is not good enough, it doesn’t create a cutlist. First of all the commercial flagging is not perfect, so you would have to check the flagged video and confirm or edit the cutlist. It is quite a straight-forward process and you can find a very detailed tutorial with screenshots and all here. After you have gone through this process once, it becomes very easy.

6. Run a User Job

Now on the mythtv frontend, select Media Library. After highlighting the recording which you want to transcode to mkv or avi and hit “M” button on keyboard or hit info button on your remote to come up with the Menu which has options like these

Play
Add to Playlist
Mark as Watched
Storage Options
Recording Options
Job Options
Delete

Select Job Options and then choose the Recording job which you had created in Step 4. Sit back and relax, it would take a while before the encoding gets over.

Alternatively, if you want you can use Mythweb and go to recorded programs and then just click on the recorder program to get the options for the possible jobs that can be run on it and then add the job in queue via web interface.

You can keep track of the transcoding process via the web interface or by going to

Information Centre > System Status > Job Queue

via the main Menu on the Frontend.

If you found this useful, please consider leaving a comment or liking us on Facebook or following us on Twitter or subscribing to the RSS feed to have future articles delivered to your feed reader.

You might also like

Upgrade MythTV 0.22 to 0.23 on Ubuntu 9.10 Ubuntu 10.04...
Stream Live TV to Several Computers on LAN Streaming of...
MythTV Frontend for Windows with Live TV! Update: read...
Enable Closed Caption (CC) / Subtitle on Live TV / Video Playback Unlike Windows...

About the Author

has written 386 posts on this blog.

Meditating towards his "nerdvana", lifehacker is a teacher by the day and a nerdy blogger by the night. He lives to learn and yearns to learn living.

One Comment on “Automatic Encoding of MythTV Recordings To avi or mkv on Ubuntu 10.04 Lucid (Mythbuntu)”

Trackbacks

  1. Encoding MythTV Recordings with Subtitle and Surround Sound | Hack Your Life!
Copyright © 2014 Hack Your Life!. All rights reserved.
Proudly powered by WordPress. Developed by Deluxe Themes