[mythtv-users] Convert mpg to avi
Peter Bennett (cats22)
cats22 at comcast.net
Thu Sep 20 23:13:30 UTC 2012
On 09/18/2012 03:29 PM, reubencrane at gmail.com wrote:
> I am running mythtv on freebsd. Works great but I am having trouble
> doing video conversion. I successfully used mythtranscode (had to add
> season, episode, and another column to the recorder table) to cut
> commericials and am now trying to use mencoder to convert the
> resulting mpg to avi(mpeg4 and mp3) I can do a single pass but I
> wasn't to happy with video quality during scenes with motion. So now I
> am trying 2 and 3 passes but this always fails on second or third
> pass. Most of the information I have googled seems dated. So could
> someone share their preferred method to convert mythtv mpg to
> reasonable quality file?
My method consists of the following steps. I am not using mythtv
transcode in this process.
set LINKSDIR to a suitable directory
Create symbolic links for my recordings as follows:
--link $LINKSDIR/origdate --format "%U/%T/%oy%om%od %S"
This creates links in that directory to all your recordings (mpg files).
You can browse the directory and find the file that corresponds to your
program. I copy that to another computer because my backend is a low-end
machine with not much CPU power.
For creating mkv/x264 archives, download and install handbrake-cli. To
install on ubuntu add the following ppa:
sudo add-apt-repository ppa:stebbins/handbrake-releases
Handbrake is the best video tool I have found. The options below will
automatically figure out and apply deinterlacing if required and will
automatically apply correct frame rates. Some recordings may have
variable frame rates, for example 29.97 fps for commercials, 23.976 for
the movie. Handbrake will keep these rates in the mkv file.
To archive 1080i and 1080p content with excellent quality use this
HandBrakeCLI -i Serenity.mpg -o Serenity.mkv -f mkv -e x264
--x264-preset superfast --x264-profile high --x264-tune film -q 30 -E
copy --audio-fallback ffac3 --crop 0:0:0:0 -w 1920 -l 1080 --decomb
This uses a 1 pass constant quality encoding, uses about 1 GiB per hour
for the encoded file, although this will vary. On my system it is almost
real-time encoding, to encode 1 hour takes a little over an hour, around
1 hour 10 minutes.
To leave out excess footage at the beginning and end, add these entries
to the end of the command line
--start-at duration:138 --stop-at duration:1111
138 is the position in seconds to start encoding, and stop-at is the
length in seconds. You can use fractions for example --start-at
To archive into 480p content use the same command line but substitute
appropriate -w and -l values:
-w 640 -l 480 for 4x3 (SD) pictures or -w 720 -l 404 for 16x9. For 480p
I recommend -q 26 instead of -q 30 if you plan to watch it on a large
screen TV (to avoid artifacts that will show up when watching a
low-definition image enlarged). 26 will use about 300 GiB per hour. 30
will use about 200 GiB per hour. Encoding in SD takes also a little over
Instead of "-E copy" you can use "-E lame --ac 2 --ab 128" to encode
audio as mp3 to save more disk space.
The mkv files can be played on a computer with mythtv, VLC or other
programs, or burned on a DVD and played in a stand-alone Blu-ray player.
I plan to put this all in a blog with more detail, and info on how to
edit the files to remove commercials, join files, rip DVDs, and create
avi files that can be burned on a DVD and played in a standalone DVD player.
More information about the mythtv-users