I have been using MythTV for a couple of years now. Like most complex bits of software, it can be difficult to get it set up the way that you want it. There are a number of comprehensive guides to installing Myth on various flavours of Linux elsewhere on the Internet. These pages are not a HowTo on installing MythTV, but contain hints and tips that have helped me fine tune my system.
If you want to build Myth from svn see Compiling MythTV from svn .
Hauppauge Nova-T 500.
This card contains twin DVB tuners. It’s supported out of the box by Feisty, but you may experience problems with usb disconnects causing kernel panics. If your box locks up periodically for no apparent reason this may be the cause. One solution is to disable the EIT program guide in Myth and use mythfilldatabase instead. It’s also possible to install the latest dvb drivers, which seem to have made a big difference for me.
There is a good page about the card in the MythTV wiki . One useful tip is to make sure that you turn on the on board amplifier:
sudo vim /etc/modprobe.d/options Add the following to the end of the file: options dvb-usb-dib0700 force_lna_activation=1
Using mythrename.pl.
In the contribute scripts directory MyThTV contains a script called mythrename.pl, which will rename your recordings to a more human readable format. By default Myth creates file names of the format:
[ChannelID]_[Year][Month][Hour][Min][Sec].mpg
If you want to copy your recordings somewhere else, it can be difficult to identify the correct file. Running mythrename.pl with no parameters will rename your files in the format:
At first this seemed like a “good idea”. However, various other Myth utilities expect the file names to be in the default format. One example is mythtranscode. So what happens if you have run mythrename.pl and want to restore your file names to the default format? You can use mythrename.pl to restore the original format:
mythrename.pl --format '%c_%Y%m%d%H%i%s' --live
Now you can use mythrename with the —link option to create symlinks with pretty file names to the original files.
Trimming Recordings.
Myth has various automated methods for marking adverts in recordings. None of these work well for me here in the UK. For most programs I simply fast forward past the adverts. However, if I want to keep a recording I mark the adverts manually using edit mode.
Initially I found that editing recorded files to cut out the ads was problematic. The reason was the nature of the mpg files produced from DVB cards by Myth. There seems to be a 300 msec delay between the audio and video track. If you just watch the program this is not noticeable. However, once you start trying to edit the files, audio and video rapidly get noticeably out of sync.
One solution is to demux the mpg file using ProjectX and then re-multiplex the streams. However, this is quite labour intensive and time consuming. Luckily mythtranscode has an option that will fix errors in recorded mpg files. As a starting point I use the script from the MythTV wiki. I modified it as I don’t want automatic commercial flagging.
I have set this script up as a user job, so I can run it when required.
#!/bin/sh
VIDEODIR=$1
FILENAME=$2
CHANID=$3
STARTTIME=$4
# Sanity checking, to make sure everything is in order.
if [ -z "$VIDEODIR" -o -z "$FILENAME" ]; then
echo "Usage: $0 <VideoDirectory> <FileName>"
exit 5
fi
if [ ! -f "$VIDEODIR/$FILENAME" ]; then
echo "File does not exist: $VIDEODIR/$FILENAME"
exit 6
fi
# The meat of the script. Flag commercials, copy the flagged commercials to
# the cutlist, and transcode the video to remove the commercials from the
# file.
# I am not interested in flagging commercials as I do this manually,
# so I removed this part of the script.
# Use --mpeg2 to fix audio sync problems.
# Note that mythtranscode seems to ignore --honorcutlist when using -i
# so we use the chanid and start time instead
mythtranscode --showprogress --honorcutlist --mpeg2 -c $CHANID -s $STARTTIME -o $VIDEODIR/$FILENAME.tmp
ERROR=$?
if [ $ERROR -ne 0 ]; then
echo "Transcoding failed for ${FILENAME} with error $ERROR"
exit $ERROR
fi
# The original file is save with a .old prefix.
# You probably need a cron job to remoe these files every few days.
mv $VIDEODIR/$FILENAME $VIDEODIR/$FILENAME.old
mv $VIDEODIR/$FILENAME.tmp $VIDEODIR/$FILENAME
# Rebuild the seektable with mythtranscode as rebuilding with mythcommflag
# doesn't work properly with files from DVB cards.
mythtranscode --showprogress --buildindex --mpeg2 -c $CHANID -s $STARTTIME
# Clear out the cut list as it's no longer needed.
mythcommflag --clearcutlist -f $VIDEODIR/$FILENAME
ERROR=$?
if [ $ERROR -eq 0 ]; then
# Fix the database entry for the file
cat << EOF | mysql -u mythtv -pmythtv mythconverg
UPDATE
recorded
SET
cutlist = 0,
filesize = $(ls -l $VIDEODIR/$FILENAME | awk '{print $5}')
WHERE
basename = '$FILENAME';
EOF
exit 0
else
echo "Clearing cutlist failed for ${FILENAME} with error $ERROR"
rm /usr/video/$FILENAME.tmp
exit $ERROR
fi
Encoding Video for an Archos 404.
I recently bought an Archos multimedia player and I wanted an easy way to re-encode my MythTV recordings in a format suitable for the Archos.
There are a number of scripts around for converting MythTV recordings into PDA and iPod compatible formats. Benton Roberts has created a nice Perl script that helps you create a set of shell scripts for processing MythTV recordings. You can download his scripts from here . The main script can be run either as a user job, or from a command line. One of the nice things about his scripts is the ability to create a job definition file. This is a simple text file the script uses to determine things like encoding parameters and output file name. If your household has several multimedia devices you can create a job definition file for each device and choose which one to run from the main script.
Creating Time-stamped Backups Using cron.
It’s quite easy to backup your database using mysqldump. However, what happens if you discover a problem with the database that occured a few days ago? Simply dumping the database once a day won’t help you, as your backup file will contain the error. The solution is to create daily backups. Each backup is a compressed .tgz file with the name in the format mysql-dd-mm-yyyy.tgz.
Don’t forget to clear out your backup directory once in a while, or your hard drive will eventually fill up! If your hard disk crashes, having multiple backups won’t help you, so you probably need another cron job to rsync your backups to another computer.
#!/bin/bash
# creates a backup of the mysql database running at /var/lib/mysql
# get current datestamp
DATESTAMP="`date '+%d%m%Y'`"
# Dump database to a text file.
# I am using root, but in most systems the mythtv user will be able
# to dump the database.
mysqldump -u root -pyourpassword mythconverg > /home/mythtv/mysql_backup/mythconverg.sql
# Create tgz file from the backup.
# Filename is in mysql-ddmmyyy format.
tar -zvcf /home/mythtv/backup/mysql-${DATESTAMP}.tgz /home/mythtv/mysql_backup/
Problems Tuning Some Freeview Channels.
Myth has been having problems tuning certain Freeview channels, including BBC4, Channel5 and Radio 4. However, I can receive these channels with no problem using Kaffeine, so the hardware and signal strength must be OK. My database is quite old, having originated at about MythTV 0.17. I had tried various options to re-tune, but the problem persisted. In case anyone else is experiencing th same sort of trouble this is how I fixed it.
- Create a channels.conf file using scan (tzap). Make sure that you stop mythbackend first.
scan -c /usr/share/doc/dvb-utils/examples/scan/dvb-t/uk-WinterHill > channels.conf
- Run mythtv-setup and delete all existing channels. Run the channel scanner with the option to use channels.conf and delete existing channels.
Myth can now tune all the Freeview channels correctly.
