MythTV: Use nuvexport to convert your recordings to another format.
NOTE: This guide has been written for Ubuntu Server Lucid Lynx 10.04, Karmic Koala 9.10, Jaunty 9.04 and Intrepid 8.10 although it may well work on earlier and later versions.
Although the files produced by MythTV can be streamed to my Media Streamers just fine I do have the occasional issue whereby trick-play does not always work as expected. For example, when I use fast-forward it is not always predictable where the video is going to start playing again. Furthermore, the file standard used by MythTV (NuppelVideo) cannot be streamed to every media streamer out there. To ensure my recordings would be playable whatever brand of streamer I may decide to use in the future I figured it would be a good idea to convert them all to a more universal format.
There is a great utility called nuvexport which can be used to convert your recordings into a variety of other formats. I use it to convert my recordings to "regular MPEGs" but it can also be used to create files suitable for playback on a PSP for example.
It is not trivial to set up and configure nuvexport (well, it certainly wasn't for me!) so I figured it would be worth explaining how I got it all working.
For information, this guide assumes you're running a gnome desktop either directly or via VNC.
If nuvexport has not been installed as part of MythTV then you can install nuvexport via the Synaptic Package Manager. So, from the gnome menu choose System -> Administration and launch the Synaptic Package Manager. Type nuvexport in the Quick Search box and then place a check against nuvexport in the list of results returned and click Mark For Installation. Choose the additional packages too. Next click the Apply button and then the Apply button once again for confirmation.
NOTE: If you don't have the Synaptic Package Manager (it is not installed by default under Lucid or Karmic) then you can install it by issuing sudo apt-get install synaptic from a Terminal or Putty session.
Once nuvexport has been downloaded and installed we now need to modify the nuvexportrc file to make nuvexport work the way we want it to.
Modify the nuvexportrc file
nuvexport uses a configuration file called nuvexportrc which needs to be tweaked from it's default so that nuvexport works the way we want it to. I've included a copy of my nuvexportrc file here which you can use instead of trying to figure out what modifications you need to make to your own version of the file. Rename the existing /etc/nuvexportrc file to a .old and then download my one (removing the .txt) and copy it into the /etc folder.
Next highlight the contents of the nuvexportrc file I've provided above (by right-clicking on the contents when it is displayed and choosing Select All) and then select Copy.
Using Putty type the following command:
sudo vim /etc/nuvexportrc
and enter your password if prompted. This will open a new nuvexportrc file for editing.
Then press the [Insert] key once (to switch into INSERT mode) and add a couple of blank lines by pressing the [Enter] key. Then right click and the contents will be pasted into the file.
Once you've done this there are a couple of lines in the nuvexportrc file which you may want to tweak to suit your environment:
The line which reads: filename=%pY-%pm-%pd-%S can be modified to suit using the strings given in the nuvexportrc file.
As it stands this line will convert all my recordings using the Programme Start Time as the filename. As can be seen below, each of my recordings lives in its respective RecordingGroup/ShowTitle folder so simply naming the individual recordings as the programme start times is all I need to identify and sort my recordings.
The line in the file which reads path=. is where nuvexport will dump the converted file. I've overridden this setting in the script provided below so you can safely ignore this line if you're going to be using the script I've provided.
Once you've finished modifying the nuvexportrc file press the [Esc] key once and type :wq to save and quit out of the script. If you make a mistake then issue :q! instead of :wq to abort your changes.
Once you've configured the nuvexportrc file you can test that nuvexport is working correctly by running nuvexport from the command line. Simply type nuvexport from within a Putty/Terminal Session, follow the prompts and then sit back and relax. It can take a good while for the conversion to run through especially if your processor is not particularly powerful.
Write a script to perform the conversion
Assuming you've got nuvexport working correctly you can now modify MythTV so it performs the conversion after each and every recording. I've created a script to perform the conversion and to then dump the converted file into the folder location which my Streamers are pointing at. You can download the script from here. Rename the script to a .sh file and make it executable. Reminder: sudo chmod a+x ConvertAndMove.sh will make the script executable.
Instead of downloading the script you can create it via Putty:
Highlight the whole script, right click on it and select Copy.
Using Putty navigate into the folder where you're going to store the script. For example type cd /home/xxx/MyScripts where xxx is your username.
Next type vim ConvertAndMove.sh (or your preferred script name) and press Enter. This will open the file for editing.
Then press the [Insert] key once and add a couple of blank lines by pressing the [Enter] key. Next right click and the whole script will be pasted into the screen.
Then press the [Esc] key once and type :wq to save and quit out of the script. If you make a mistake then issue :q! instead of :wq to abort your changes.
Don't forget to make the script executable: chmod a+x ConvertAndMove.sh
Modify MythTV so it converts your recordings automatically
Now we have the script we need to configure MythTV so it runs this script after each and every recording. So, start the MythTV backend (System -> Administration -> MythTV Backend Setup ) and go into the General option and click Next until you reach the Job Queue (Backend-Specific) screen. Check the Allow User Job #1 job option. I've also set the Maximum simultaneous jobs on this backend: option to 4. I've also checked the Allow Advert Detection jobs and Allow Transcoding jobs options too.
Next move onto the Job Queue (Global) screen and check the Start Auto-Advert Flagging jobs when the recording starts option.
Next move onto the Job Queue (Job Commands) screen and enter a suitable description in the User Job #1 Description: field. In the User Job #1 Command: box type the following:
and then click Finish. Obviously change /home/htkh/MyScripts to the location of the script. Plus you can tweak the other arguments to suit. See User Job arguments for MythTV for the complete list of arguments you can specify for a User Job.
When the script runs it will pipe any output to the CAMoutput.txt file located in /home/mythtv. So examine this file for any errors:
For information the script will create a main folder using the 'Recording Group' setting which was specified when you set the recording up. Then within each Recording Group it will create a sub-folder for each 'Show title'. It will then use 'Recording Date' for each episode. For example:
Childrens (the recording group)
Engie Benjy (the show title) 2009-05-10-Far out.mpg (the episode) 2009-05-11-One Step Closer.mpg etc
Chucklevision 2009-05-10-Silence is golden.mpg 2009-05-11-On the Hoof.mpg etc
Given this script is creating folders and files and is running from within the MythTV backend you need to ensure that the user mythtv has the necessary permissions to create files and folders in your chosen location(s). You can do this as follows:
If you've Installed Webmin then from within Webmin go into System -> Users and Groups and click on the Username called mythtv. A new screen will open and in the Group Membership section scroll down the All groups list until you reach users. Click on it once and then click the -> button so users is added to the In groups box. Then click the Save button. This has now added mythtv to the users group so all folders created with "users" as the group owner can now be written to by this script.
Next you should double-check the permissions for the folder which the script will be writing to. My script is writing to "/media/ST3750640NS/TV Shows/" and the permission settings for this folder are "d rwx rwx r-x". This is ok because the group permissions (the second set of values) are rwx and both I and the mythtv user belong to the users group. If your folder is "d rwx r-x ---" or similar (note the group permissions are set to r-x) then you can issue the following command to change the group permissions to allow the script permission to write to this folder:
chmod g+rwx "/media/ST3750640NS/TV Shows/"
For information the double quotes around the folder name in this command are only required because the folder name has spaces in it.
If you'd like to modify the script to suit your environment then the complete list of arguments you can specify for User Jobs within the MythTV backend can be found here
Organising my TV shows this way works well in my household. So, my children browse to the Childrens folder and then are presented with only their programmes. My wife browses to Mums and gets to see only the programmes she's interested in and so on. Obviously the above folder structure relies on you assigning relevant Recording Groups when you set up a Recording Schedule. It's not very intuitive how you set up and maintain recording groups so here's how: How to add Recording Groups to MythTV
Still stuck? Not what you were looking for? Then head over to the Discussion Forum