Turn mythtv recordings into mp4 files

This piece is a work in progress, but I figured I should publish it slowly as I continue to add to it, as it might help people, even though it is not quite working yet. I’ve had it working in the past, but it’s not quite working on my setup yet.

I’ve spent a lot of time playing around with mythtv recordings to try and keep them for later viewing in a format that is transferable to other devices, players etc. I have found x264 encoding in an mp4 container to work quite well – especially for transferring to my ipad or iphone for viewing.

In this guide I re-encode my mythtv nuv files into mp4 x264 files and save them into my videos for viewing through mythvideo. I use the mythnuv2mkv.sh script which I have found to be the best script available for doing the re-encoding – though if you know of a better script, feel free to point it out.

1. Configure mythnuv2mkv script on your system 

Setup a custom job utilising the mythnuv2mkv.sh bash script. You will first need to get it here –> http://www.mythtv.org/wiki/Mythnuv2mkv

I suggest you place it somewhere on your system where all users can access. I’ve put mine in /usr/local/bin/
Make sure you chmod 755 to ensure it is executable.

2. Install dependencies for the mythnuv2mkv script to work

Install the dependencies required for it to work. I suggest installing all of the mp4 and mkv dependencies.

$ sudo apt-get install mplayer mencoder wget imagemagick x264 faac faad gpac vorbis-tools mkvtoolnix

3. Customise the script to your liking

There a quite a few options to consider for the mythnuv2mkv script. The options are stored in a seperate file named mythnuv2mkv.cfg which resides in the same directory/folder as the mythnuv2mkv.sh script. Here is a copy of what I have to help you.

4. Setup a user job on mythtv.

You will need to setup a user job in order to call the mythnuv2mkv.sh script from mythtv. The easiest way is to use mythweb to do this. I have a previous post on this here — Adding a mythtv job using mythweb

Using this guide, make the following changes to these variables and save them .

 JobAllowUserJob1 = 1
 UserJob1 = /usr/local/bin/mythnuv2mp4.sh --jobid=%JOBID% --quality=med --copydir=/media/videos/newly.exported --chanid=%CHANID% --starttime=%STARTTIME%
 UserJobDesc1 = Convert to mp4

Restart mythtv-backend in order to enact the changes. Remember that if you do this, you can cause programs that are being recorded to be interrupted. I suggest that if you have anything recording that you wait until nothing important is recording before restarting mythtv-backend.

5. Test the user job.

Now that you have the script and user job added to mythtv, you just need to find a recording and test it.

This entry was posted in Linux, Movies, mythtv, Technology and tagged , , , , , , , , , , , , , , . Bookmark the permalink.

One Response to Turn mythtv recordings into mp4 files

  1. Francesco says:


    how should the config file be written?
    Similar to the declaration in the original mythnuv2mkv v1.61 script?
    Something like:


    DEFAULTMPEG2ASPECT=”4:3″ # 4:3 or 16:9
    # Log directory
    LOGBASEDIR=”/var/tmp” # Don’t use a directory with spaces in it’s name
    # Number of errors reported by mplayer allowed in the transcoded file
    # Path to your mysql.txt file
    # Include denoise filter
    DENOISE=”OFF” # ON | OFF, can also change with –denoise argument


    Does the script work on mythtv 0.27? I’ve read somewhere that some of the userjobs parameter have changed, ie: %STARTTIME% should now be %STARTTIMEUTC%. I’m a long time user of the original script, just recently moved to mythtv 0.27 and it does not work anymore. I’m gonna try the v1.93 in a few days, but I’d appreciate any hints you can give. Is version 1.93 the latest available? I couldn’t find any newer revisions nor could I track down the revisor himself…


Leave a Reply

Your email address will not be published. Required fields are marked *