Mastering MythTV MPEG2 files to DVD

MythTV is a wonderful project, which I’ve been running for nearly 12 months. In the AFL season 2007, I was downloading the Geelong games from the internet. Unfortunately, you’re at the mercy of whomever was encoding the game, in terms of quality. By Geelong winning the premiership last season, most of the games were broadcasted on free-to-air TV and I was recoding them all using MythTV, with the intention of putting them on DVD later.

I tried using MythArchive, but it was clumsy and didn’t give me enough control of the DVD creation process. I wanted the video to fit exactly on a single sided DVD, with minimal loss of quality, so I had to the process manually.

The problem I found trying to encode MythTV’s mpeg2 files was that you would always get the the video and audio out of sync. The length of the broadcast was around 3 hours long, so by the end, the sound could be more than a second behind the video. I think this is due to missing little pieces of the data from the broadcast.

To fix the broadcasting issues, use ProjectX to split the video and audio
java -jar /usr/share/java/ProjectX.jar -demux -out <your tmp directory> -name <your output filename prefix> <input mythtv recording file>

You’ll see some output like this:

demuxing DVB MPEG-TS file 1010_20080802192500.mpg
!> PID 0x0 (PAT) (0 #1) -> ignored
!> PID 0x100 (PMT) (188 #2) -> ignored
ok> PID 0x200 has PES-ID 0xEA (MPEG Video) (376 #3)
ok> PID 0x240 has PES-ID 0xBD (private stream 1) (TTX)  (5264 #29)
ok> PID 0x28B has PES-ID 0xBD (private stream 1) (20680 #111)
ok> PID 0x28A has PES-ID 0xC0 (MPEG Audio) (84412 #450)
-> video basics: 720*576 @ 25fps @ 0.7031 (16:9) @ 9000000bps, vbvBuffer 95
-> starting export of video data @ GOP# 0
!> dropping useless B-Frames @ GOP# 0 / new Timecode 00:00:00.000
6 %!> PID 0x200 -> packet 2687051 @ pos. 505165400 out of sequence (15/11) (shifting..) (~00:12:34.480)
!> PID 0x200 -> packet 2687616 @ pos. 505271620 out of sequence (1/14) (shifting..) (~00:12:34.960)
12 %!> PID 0x200 -> packet 5943135 @ pos. 1117309192 out of sequence (12/6) (shifting..) (~00:27:44.080)
16 %!> PID 0x200 -> packet 7860852 @ pos. 1477839988 out of sequence (8/14) (shifting..) (~00:36:38.320)
17 %!> PID 0x200 -> packet 8427938 @ pos. 1584452156 out of sequence (6/10) (shifting..) (~00:39:16.720)

Once this is done, multiplex the Video and Audio files back together again
mplex -f 9 -o <your output filename> <video file>.m2v <audio file>.mp2

This should give us a nice clean MPEG2 file, which we can then cut all the ads out of. Rather than using something like nuvexport and making the ads in MythTV itself, I found it much easier to use Avidemux.

Load the video into Avidemux, then

  • Use the arrow keys and mousewheel to find cutting spots.
  • Use the A_> and <_B buttons to mark the start and finish of ads
  • Hit the delete key to cut the ads

Once you’re done, I always save a project file, in case Avidemux crashes.

You can then load the ‘DVD’ profile from the Auto -> DVD menu. Leave the ratios at 1:1.

Hit the calculator button, select Format: MPEG and Medium: DVD5. Hit apply, and then close.

Hit the configure button underneath the video part on the left. Configure the video output to Interlaced (I used TFF, but prob doesn’t matter) and 16:9 Aspect ratio.

Then, just save the new encoded video. On my AMD 3200+ machine, it takes somewhere around 5-6 hours to encode about 2.5 hours of video.

For me, I found that the Avidemux encoding sometimes failed in the 2nd pass at one of my defined cutpoints. To combat this, I opened the output video to the end of the file to find out which cutpoint the video failed encoding at. With this, I would open up my project file in Avidemux again, and remove a few extra frames either side of my original cut. This was usually enough to get it over the line.

Once this is done, use DeVeDe to create the DVD ISO file.

When adding the newly encoded MPEG PS file, make sure you open the properties of the file click ‘Advanced Options’, and in the Misc tab, select the checkbox ‘This file is already a DVD/xCD-suitable MPEG-PS file’. Don’t worry if DeVeDe tells you the file is 106%, it will fit on a 4.7 DVD.

Once this is done, you should have a nice ISO image which you can burn straight to disc.

Posted in Geek, Linux at August 31st, 2008. 2 Comments.

Finally getting everything to work on Gutsy

I had everything working quite well on my Macbook Pro (Core 2 Duo) with Ubuntu Feisty, but due to some badness from the shitty, shitty ATI fglrx driver, I couldn’t use Gutsy with everything working.

The new kernel in Gutsy moved from the SLAB allocator to the SLUB allocator. (Btw, I have no idea what that actually is..). So, this meant that I couldn’t put the machine into Suspend mode while using the ATI drivers. Although the RadeonHD driver works quite well, it means that I can’t actually play BZFlag.

To solve this, I ended up compiling my own custom kernel for Ubuntu, and switching it to use the SLAB allocator. I thought it would be appropriate to blog it here in case anyone else is interested.

I followed much of the instructions from the Macbook Pro page on the Ubuntu Wiki, but I built a deb package for my kernel. So have a look at the Unofficial ATI linux driver wiki page for installing on Ubuntu Gutsy.

Here we go:

Symlink the firmware directory. This is usually needed for the initrd.
sudo ln -sf /lib/firmware/2.6.22-14-generic /lib/firmware/

Install all the required packages
sudo apt-get install linux-source libncurses5-dev build-essential kernel-package fakeroot module-assistant build-essential dh-make debhelper debconf libstdc++5 linux-headers-generic

Extract the kernel source, import the old config and start the make config
cd /usr/src/
sudo tar -xvjpf linux-source-2.6.22.tar.bz2
sudo ln -sf linux-source-2.6.22 linux
cd linux
sudo cp /boot/config-2.6.22-14-generic .config
sudo make menuconfig

In the menu, browse to ‘General setup‘, then select ‘Choose SLAB allocator‘ at the last entry. Change this from ‘SLUB’ to ‘SLAB‘, then exit ‘General setup’.

Select ‘Processor type …‘ and ‘Processor family‘ and change the CPU from ‘Generic-x86-64’ to ‘Intel Core2 / newer Xeon‘, exit ‘Proccessor type …’.

Go to ‘Device Drivers‘ > ‘Sound‘ > ‘Advanced Linux Sound Architecture‘ > ‘PCI devices‘ and Hit the M key to enable the ‘Intel HD Audio‘ module.

I think that Ubuntu packages this driver as part of an extra modules package, but the in-kernel one works fine

Save the new config and exit.

UPDATE: Edit the file /etc/kernel-pkg.conf, and add the line:

This should make sure of both cores when compiling your new kernel. This will take it down from about 1 hour to still timing it, please update

Build your new kernel package
time make-kpkg --rootcmd fakeroot --uc --us --initrd binary

I think it’s a good idea to boot into your new kernel here. Make sure everything’s working before you move on.

Download the ATI driver installer

Build Ubuntu fglrx packages from the ATI driver script
sudo bash --buildpkg Ubuntu/gutsy

Install the fglrx packages
sudo dpkg -i xorg-driver-fglrx_8.433-1*.deb fglrx-kernel-source_8.433-1*.deb fglrx-amdcccle_8.433-1*.deb

Build the fglrx kernel module package.
sudo module-assistant prepare,update
sudo module-assistant build,install fglrx -f
sudo depmod -a

Install the fglrx kernel module
sudo dpkg -i fglrx-kernel-

Make sure you’ve got fglrx set in the device section of your xorg.conf.

That should do it.

Posted in Geek, Linux, Ubuntu at December 21st, 2007. 2 Comments.

My new shiny toy: the Nokia n800


I splashed out a bit, and bought myself a new toy. It’s the Nokia N800 Internet Tablet, running Linux.

I’m still getting used to it, but it seems quite good so far. More to come..

Posted in Geek at September 14th, 2007. 2 Comments.

Suspend to Ram on a MacBook Pro

I’m running Gentoo and Ubuntu Feisty on my MacBook Pro (Core 2 Duo), and it just refused to resume after a suspend to ram. Let this be a note to anybody else going through the frustration that I was.

In /etc/default/acpi-support, I changed POST_VIDEO from true to false.

# Should we attempt to warm-boot the video hardware on resume?

Works a treat now 😉

Posted in Geek, Linux at April 18th, 2007. 2 Comments.

Victorian Partnership for Advanced Super Mario Bros


Posted in Geek, Work at November 28th, 2006. 3 Comments.

Banshee 0.11.0 is rad


The new Banshee rocks. Not only does it do two-way iPod sync, but it also does cover art, iTMS (from a plugin) and Last.FM recommendations. I nearly forgot, it also does DAAP for sharing with iTunes over mDNS.
I made some ebuilds for Gentoo, and submitted a bug report for it.

Posted in Geek, Linux at September 20th, 2006. 2 Comments.

WordPress 2.0.1

Looks like the new WordPress just hit Gentoo Portage, so I thought this might be a good time to finally upgrade to the world of WordPress 2. So far, it looks good. The ebuild handled the upgrade perfectly (the Gentoo guys really know how to package web apps!) which rocks.

The new editor is kinda funky, and i’m finally glad to see an upload field on the same page as where you type. Very nice.

On another note, the Gradiators are at it again. We’re playing in a B-grade volleyball competition on Thursday nights, and even though we had a loss, it was still a good effort for first timers.

Posted in Geek at February 3rd, 2006. No Comments.

Bringing Melways into the Google era

For a while, Jezza and I have been mucking around with the Melways maps from We’ve been working out ways to actually make their web site much better than it currently is. It was always painful to try and navigate your way through the little 300x300px window at a zoom level that was easy enough so that you could actually read the street names. We made a page that let us navigate the maps using your full browser window, and let you click to center the map. Life was good.

Recently, Jezza and I have been talking about making draggable maps, in the same fashion as google and yahoo maps. Using some great GPL javascript from the guys at, I have managed to interface their draggable map code to use the street-directory interface.

You can either search for an address or get started right away on the Melbourne CBD. It’s only working in Mozilla/Firefox at the moment, but it should soon be working in IE and Safari. I’m not sure if Konqueror can handle it though. Have a play, and leave some comments.

Posted in Geek at January 9th, 2006. 6 Comments.

Now that Xmas is over…

… life can return to normal. I’m not going back to work until the 3rd of Jan, so i’m taking it easy for the next couple of days.

I got a Canon IXUS 50 from my family this Christmas which was nice. My Dad did some research on the internet for me about digital cameras and was pretty impressed with this one, so he was pretty surprised to get one himself 🙂

Canon IXUS 50Canon IXUS 50

Posted in Geek, Personal at December 29th, 2005. No Comments.


My Powerbook is here!

For reference for anybody else, when ordering stuff from Apple, you can track the delivery of your goods by using the Apple Delivery Number as quoted in your email confirming that your stuff has been shipped.

Apple uses StarTrack Express for their deliveries, and you can use your Apple Delivery Number as the Reference Number on the StarTrack Express site to trace the delivery of your package.

I’m going to get off work early to drive to Lara to go pick it up. So exciting 🙂

Posted in Geek, Personal at December 1st, 2005. No Comments.