Tip #5: Minimizing the risk of Disk Failure

Mythtv recordings use a lot of disk space

One thing that us mythtv users use is a *lot* of disk space. Especially those of us who record HDTV, and what that means is (usually) a lot of disks. The more disks, the more often there are disk failures.

Some ways to keep your data safe

There are a couple ways to keep disk failure from being a major headache. 1) backups. nice idea, but when you have hundreds and hundreds of Gigabytes of videos and every time you record a high-def show, it drops another 8G on your disk, that option becomes costly, time-consuming, and unrealistic. 2) Raid. Raid configurations can come in several levels, but the one that favors data redundancy (Raid 1) means that you need to double the disk space for your existing data.

My method

Another methodology you can use is to separate your operating system and your videos (and other media) onto separate disks, and employ different strategies for each.
Here's what I do:
I have three systems, but this could work with one or two as well.

I have one disk dedicated to the following partitions:


This could be a relatively small disk. I find 80Gig works nicely, and since speed is not a big issue, I also go with IDE disks, and format them as ext3 filesystems. IDE is a bit cheaper, and ext3 is a bit more reliable as filesystems go.

I also grabbed a 250Gig IDE drive and mounted it to /mnt/backups, exported it, and mounted it on my other machines so that I could perform network (and local) backups of my root filesystems to that one disk.

In order to protect my 'root' filesystems, I do daily backups (full weekly, and incremental daily). I use Simple Linux Backup (which uses tar) and followed the instructions here to get it going. All three of my systems backup to that one drive, two over the network (via NFS mounts) and one locally. This way, I'm protecting all my data on all three machines, but not touching any of the mythtv media.

Now for my videos. Since my MythTV configuration is split into separate frontend/backend configurations, I put all of my video data in one Logical volume on my backend, and mount it to /video (currently, I'm sitting with 6 SATA drives totaling 2.2Terabytes). I then export that entire logical volume to my frontend, and mount it in the same location. Since it is just toooooo much data to backup to another disk, I choose the 'monitor my disks' method. I have mostly SATA disks, and until recent kernels, smartmontools did not support SATA, but now it does. I have smartd monitor all my drives with the following configuration file:

/dev/sda -a -d ata -H -m
/dev/sdb -a -d ata -H -m
/dev/sdc -a -d ata -H -m
/dev/sdd -a -d ata -H -m
/dev/sde -a -d ata -H -m
/dev/sdf -a -d ata -H -m

And every day, I get a nice report from smartmon that tells me if my disks are going wonky. If I start to get failures for a disk, I can run some more tests using smartctl, and if the disk needs replacing, I use pvmove to move data off of the failing disk, remove the disk from my logical volume, replace the disk and add it back in.

Final thoughts

It's not a perfect solution, but for me, keeping the solution as low cost as possible is what's important. I'm willing to fork over the money for a 250Gig drive to backup my root partitions, but everything else just isn't that important. Whatever method you choose. Make sure you choose *something*. Not backing up, or not monitoring your disk health will eventually hurt you.

Tip #4: Transcode profiles for HDTV

The Problem I was having transcoding HDTV

One of the biggest issues with recording HDTV is that the files are huge. Also, mythtranscode's ability to transcode HDTV was spotty prior to 0.19. My old solution was to use ProjectX to demux the Transport Stream and transcode (with ffmpeg) to resize, convert to MPEG-4 (XviD) and remux. If I wanted to maintain the best quality, I would use two passes, and this solution was *sloooooow* and very manual.

Mythtranscode works now! ...What's next?

With 0.19, mythtranscode has been rock solid transcoding my HD Transport Streams. It's also blazingly fast! Once I started using it, though, I realized that the default profiles didn't work for me. I had three different sources of DTV:

  • 1080i
  • 720p
  • 480i

I also have several different desired output formats:

  • No Resize - High Quality (De-Interlaced)
  • Resize to 960x540 High Quality (De-Interlaced)
  • Resize to 634x352 Med Quality (De-Interlaced)

Because of all the combinations, I wanted the following Transcode profiles:

  • 1080i - NoResize
  • 1080i - Resize High
  • 1080i - Resize Med
  • 720p - NoResize
  • 720p - Resize High
  • 720p - Resize Med
  • 480i - NoResize

Great... Now how can I do that?

With MythTV, you are given some profiles for transcoding (Default, Live TV, High Quality, Low Quality), which you can modify, rename, etc; however, it does not allow you to create new transcoding profiles through the UI, so I went to the database (mythconverg). Once I figured out all of the tables that are involved in the transcoding process, I went to work.

The three tables I'm interested in are: profilegroups -> recordingprofiles -> codecparams

Modify Transcoder Profile Group

First, we want to modify the Transcoder Profile Group. From mythfrontend, select: Setup -> TV Settings -> Profile Groups -> Transcoders. This will drop you into the recordings profile screen where you will see the four default profiles: Default, Live TV, High Quality, Low Quality. These are generally not good enough for the needs of HDTV folks. The next step will show you how to customize those recordings profiles, and even create a few more.

Modify existing recordings profiles

  • From mythfrontend, select the first profile 'Default'.
  • Replace the name 'Default' with 1080i NoResize.
  • Make sure Lossless transcoding, and Resize video while transcoding are not checked, and select Next.
  • Now set up your code params. I use the following settings:

    Click to enlarge

  • Click 'Next'. On the 'Audio Quality' screen, choose Uncompressed, and 48000 as the sampling rate.
  • Click 'Finish'.

Repeat this for each of the remaining profiles (Live TV, High Quality, Low Quality) renaming them as you go.
For example:
For 1080i Resize High Quality
Rename Live TV -> 1080i Resize High
Check 'Resize Video while transcoding'
Width: 960 Height 540
Codec: MPEG-4
Maximum quality:2
Minimum quality:15
Max diff between frames:3
Check all boxes except Scale bitrate for frame size
Audio Settings:
Sampling rate:48000

Now... When you use the last profile and you need to create another one, you need to add an entry to the recordingprofiles table. Do this by executing:

mysql> insert into recordingprofiles (name,videocodec,audiocodec,profilegroup) values ('480i Resize','MPEG-4','Uncompressed','6');
Query OK, 1 row affected (0.01 sec)

Now when you go back into your transcoders screen, you will see the new profile and you can modify the settings appropriately.

Additional Notes

When creating the profiles for 720p source content be sure to uncheck to two boxes Enable Interlaced DCT encoding and Enable Interlaced Motion Estimation.

My bitrate and widthxheight settings are as follows:

  • 1080i - NoResize - 4526 na
  • 1080i - Resize High - 2400 960x540
  • 1080i - Resize Med - 1300 624x352
  • 720p - NoResize - 4559 na
  • 720p - Resize High - 2400 960x540
  • 720p - Resize Med - 1300 624x352
  • 480i - NoResize - 900 na

I leave my bitrates higher than they probably need to be, but I have not had time for a tremendous amount of experimentation, and the settings yield enough of a decrease in filesize that it works for me.

Good Luck, and if you have any comments, please feel free to leave them here.

Tip #3: Importing downloaded TV shows into MythTV


Last week, I upgraded my kernel. Unfortunately, after a re-boot, my DVB drivers failed to load. The net result is I went three days without recording a single show. Now my only option is downloading the TV shows, and watching them manually, somehow (usually mplayer). WAF definitely goes down.

How to Get the Shows Into MythTV

It turns out, that importing the shows into MythTV is easy. The issue is it's not terribly simple. I'll describe below how to import a show into MythTV. Some of the metadata is 'optional'.

Let's get to it!

Not entering the optional data will get your show into MythTV, but the Meta-Data about the show will not be imported (Meta data like Show description, the correct date/time of the show, subtitle, etc...)

  • the show must be in mpeg-4, or mpeg-2 format. If it is not, you can use mencoder, or transcode to convert it.
  • You need to know the name of the show
  • You need to know the channel ID of the show's recordings (see script below)
  • Optional:The original date/time of the episode
  • Optional:The Subtitle of the episode (see tv.com for this stuff)
  • Optional:The description of the show (tv.com is your friend)

I wrote a little shell script to list the channels in my channels table:
mysql --host -umythtv -p -e 'use mythconverg; select chanid, name, callsign from channel where visible=1'

Let's say I missed an episode of E-Ring

  1. Download the show from your favorite source (fine by me if you use torrents).
  2. Move the file to your recordings directory (in my case /video/recordings)
  3. run myth.rebuilddatabase.pl --ext avi (if your file has the extension avi)

    These are the files stored in (/video/recordings) and will be checked against
    your database to see if the exist. If they do not, you will be prompted
    for a title and subtitle of the entry, and a record will be created.

    Non-nuv file /video/recordings/E-Ring.11-16.Delta.Does.Detroit.avi found.
    Do you want to import? (y/n):y

  4. Enter 'y'
  5. You will be prompted for several pieces of information, and when you are done, myth.rebuilddatabase.pl should ask you to rebuild the seek table (critical!). If it does not, then when the script exists execute the following command:

$ mythcommflag --rebuild --file .nuv
This will rebuild the seek table, but will not commercial flag the recording. Commercial flagging is probably not necessary as your downloaded file probably does not contain commercials.

Final Note

Sometimes when viewing imported AVI files with MythTV's internal player I will notice problems with the screen refreshing when I skip around. This is usually due to the fact the many shows are encoded with key frames far and few between. Wait a couple seconds (usually a scene change) and the screen will clear up.

Good Luck!

Tip #2: How to Customize MythTV's Menus

The fact that MythTV has so many features can be both a strength, and a weakness. With so many features, the menu structure can be quite difficult to navigate, and it's almost certain that there are some features you will *never* use.

Wouldn't it be nice to trim the MythTV menus to just what you use. Or, how about simply re-ordering them to suit your preferences? The good news is that you can, and quite easily.

First, a bit on how MythTV's menu system works.

The menu's are driven by XML files (located in /usr/share/mythtv/). Here is a snippet from the mainmenu.xml file:

<text>Watch TV</text>
<text lang="FR">Regarder la TV</text>
... [more languages snipped]

<text>Media Library</text>
<text lang="FR">Médiathèque</text>
... [more languages snipped]
<action>MENU library.xml</action>

The important parts are the menu title:
<text>Media Library</text>

and the action
<action>MENU library.xml</action>

There are two types of actions:

  1. link to another menu (MENU menuname.xml)
  2. launch an action (TV_WATCH_LIVE)

Needless to say, linking to another menu simply loads another menu XML file. Launching an action will run the MythTV feature that you select.

Don't start editing those files just yet! Let's run through an example and I'll show you how to safely go about editing the menus.

Example: Remove MythPhone and Netflix from Info Menu

Let's say that I never use MythPhone, or NetFlix, and I want to remove them from the Information menu. You might think.. "Hey, no problem, I'll just bring up /usr/share/mythtv/info_menu.xml up in my favorite editor (vi.. right?) and hack away!"

Nope... Once again, the MythTV devs have outdone themselves. You can make a local copy of the entire mythtv menu system in mythtv's home directory ~mythtv/.mythtv and when you fire up mythfrontend, it will read those files instead.

So.. go ahead..

$cp /usr/share/mythtv/*.xml ~mythtv/.mythtv

Just for reference, here is a quick screenshot of the offending menu (with MythPhone and NetFlix)

O.K. Now lets fire up vi and start editing your local copy of ~mythtv/.mythtv/info_menu.xml

Here is the menu entry for MythPhone

<action>PLUGIN mythphone</action>

Simply remove the section above (everything, including the <button> tags), and MythPhone will be removed from the menu.
Find the entry for NetFlix, and do the same.
Save the file, and re-run mythfrontend.

Viola, here's our new menu. sans MythPhone and NetFlix

As you can see, this process is quite simple.

Additional Notes:

Now, let's say MythTV upgrades to 0.20 and the devs add a new menu item. Unfortunately, you're custom menus won't be updated with the rest of MythTV, and this could leave you in a lurch. What I would recommend is making a diff file of your modified xml file with the original. Then after an upgrade, you should be able to re-apply your diff to the new menus. If you want to be safe, you can also diff your file with the new original and compare the two diff's, and handle the entire situation manually.

You can re-arrange any menu action and move it into any menu. You can create your own menus. One thing you can't do that I would love is to assign a shell action to a menu item.

UPDATE (6/17/2009):
As requested, here is an example of how I use MythTV's menu to launch Front Row (on the mac) and Hulu Desktop

<action>EXEC /Users/mythtv/bin/runfrontrow.sh</action>
<action>EXEC /Users/mythtv/bin/runhulu.sh</action>

Needless to say, I have scripts in my bin directory that actually execute the commands, but there you go.

Comments, Questions? Post 'em, I'll try and answer any question.

Coming up next: Transcoding profiles for HDTV folks.

Tip #1: MythTV's New Edit Keys Feature (0.19)

New to MythTV version 0.19 is the Edit Keys feature. As with any new feature in MythTV, there is little documentation on how to use it. I decided to take a look at it and see just how it works, and I was quite pleased with how easy and intuitive it was to use.

What is Edit Keys?

The Edit Keys screen allows you to remap any of the keyboard/remote control keys in all of the MythTV contexts. This includes jumppoints, TV Playback, Web Browsing, everything. It's quite powerful, and if you go too far, you can mess yourself up. Fortunately, if you try to re-map an already existing binding, the UI will warn you.

Update: As noted in mythtv-users you will need mythcontrols in order for the Edit Keys menu to be active.

Make a backup first

If you are uneasy about modifying your key bindings, then all you have to do is backup the keybindings table prior to making any changes.

$ mysqldump -p --host <hostname if remote> --databases mythconverg --table keybindings > keybindings.sql

And to restore:

$ mysql -p --host <hostname if remote> mythconverg < keybindings.sql

Let's see an example

O.K. Now that we've got that out of the way.. On to the example/tutorial. I use the Radio Shack 15-2116 remote (an awesome JP1 programmable remote), and one of my biggest pet peeves is the fact that the 'Select' key behaves differently between MythTV's internal player, and mplayer.

When viewing a video with mplayer, the 'Select' key toggles pause/play (nice!), and when viewing TV with MythTV's internal player the 'Select' key bookmarks the video. Toggle playback is done with the 'Pause' key instead. The 'Select' key is my favorite on this remote, because it's a big, fat, key right in the middle of the remote, and the 'Pause' key is small, and awkwardly placed towards the bottom.

This needs to be fixed. My goal here is to remap MythTV's internal TV Playback pause/play to the 'Select' key on my remote.

Edit Keys to the rescue!

From the main menu, select Utilities/Setup -> Edit Keys.

Figure 1: Edit Keys screen (click to enlarge).

The column on the left are all of the different contexts that can be configured. Each context can have its own keybindings.

For this example we'll just scroll down to the 'TV Playback' context.

Figure 2: Edit Keys screen - TV Playback (click to enlarge).

Moving to the right, and scroll down to the action you want to edit. In our case, that would be 'Pause' (which is really 'Toggle Play/Pause').

Figure 3: Edit Keys screen - Pause action selected (click to enlarge).

After selecting Pause, you drop down to the next open slot below. Note: each action can be assigned three keys.

Figure 4: Edit Keys screen - Next open slot (click to enlarge).

Next, we want to go ahead and add our new key assignment. Press enter (keyboard, or remote) and you will be prompted (Waiting for keypress):

Figure 5: Edit Keys screen - Waiting for keypress (click to enlarge).

Press the key on the remote (or keyboard) that you want to map to 'Pause'. In my case, this is the 'Select' key on my remote, which lirc defines to be the keyboard 'Return'.

Figure 6: Edit Keys screen - Add key 'Return'? (click to enlarge).

After accepting the new assignment, you may get a warning about conflicting with the global context, but that's just fine, because we are defining this key for just the TV Playback context.

Figure 7: Edit Keys screen - Global Context warning? (click to enlarge).

After selecting 'Bind Key', you will now see the new key binding in the slot on the bottom.

Figure 8: Edit Keys screen - Global Context warning? (click to enlarge).

That's IT! You now have a new key bound to the 'Pause' action. When you exit the screen, you'll be prompted to save your changes:

Figure 9: Edit Keys screen - Save Changes? (click to enlarge).
Select 'Yes' and you're off to the races!

If you have any questions, or comments, please be sure to leave them below.

Coming up next: Customizing MythTV Menus

Back up to: The 'Myth' of HDTV

Tags: ,

Introduction to MythTV Tips

Hello and welcome to MythTV Tips. I'm kicking off this blog after assembling several questions (both mine, and from others) about how to actually use MythTV. There are SOOOOO many features in MythTV, some documented well, and some.. not so much. I am going to use this site to publish my personal tips, tricks, tutorials for MythTV.

Feel free to comment with any questions you have, and I'll do my best to answer.
You can subscribe to MythTV Tips via RSS

Coming up: MythTV's new Edit Keys feature