DVD Authoring

From Servfire
Revision as of 02:54, 21 October 2011 by Hell Fire (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Some various tips on DVD authoring

So far my current favorite menu maker and software to put together DVDs is Bombono DVD. Easy menu editor for static stuff anyway, chapter editing and thumbnail generator, etc.

However, it uses ffmpeg on the backend for transcoding, so if you pass it a messed up stream (say, recorded stream from MythTV with errors), the audio will drift out of sync.

mplayer/mencoder handles this better, unfortunately, it'll need reencoding, so some quality loss will happen, but it'll repair the stream while it's at it.

Max DVD bitrate is 9800kbps, so we pass that along to libavcodec, as well as 256kbps audio, mp2 audio with mpeg2video video codecs. Also, if you're recording HD streams, it's probably in widescreen, but sent with more lines, so you'll need to tell mencoder the output stream needs scaling with mpegopts. (Note, this doesn't do any scaling in software, this is purely a MPEG stream flag that sets the aspect ratio on the output, telling the playing device what it needs to do, as opposed to scaling it now, and then probably having the player end up scaling it again.) While we're at it, we'll do the DVD MPEG format and add timestamps to all frames

And hopefully the output file you get is a pretty decently reencoded file without any errors. Maxing out the bitrates helps with the quality loss, since it's unlikely that the OTA stream will be more than DVDs bitrate (at least the 720p stuff I've encountered).

Cutting OTA transmissions out for DVD authoring

To date the best program I've found for this is "dvbcut", then doing the menus with Bombono DVD seems to work well. I've been feeding dvbcut the raw MPEGs as recorded and it seems to handle it well enough. The DVDs made with these files however, may not play in some DVD players that don't handle MPEG stream errors all that well if the recording isn't perfect.

DVBcut seems to set the FPS on the MPEG header to 50 for some reason if used first, though mencoder reads the original files FPS correctly. Not sure what's going on there. Workaround is to reencode the file first, then cut.

General process to use

This is what I'm currently using, this script to repair/reencode the MythTV recordings, then DVBcut to trim the edges, BombonoDVD for menu and iso generation, then k3b for burning to disk.


# Some dependancy checks

if [ "`which mpginfo`" = "" ]; then
        echo "error: couldn't find mpginfo, please install mpgtx" >&2

if [ "`which mencoder`" = "" ]; then
        echo "error: couldn't find mencoder, please install mencoder/mplayer" >&2

if [ "`which java`" = "" ]; then
        echo "error: couldn't find java, please install java" >&2

if [ ! -e "ProjectX/ProjectX.jar" ]; then
        echo "error: couldn't find Project-X in ProjectX subfolder, please download" >&2

if [ "`which mplex`" = "" ]; then
        echo "error: couldn't find mplex, please install mjpegtools" >&2

if [ ! -e "$1" ]; then
        echo "error: $1 is not a valid file" >&2

FILE="`echo "$1" | sed 's,\.mpg$,,'`"

if [ "$1" = "$FILE" ]; then
        echo "error: $1 does not end in .mpg" >&2

if [ $ERROR -eq 1 ]; then
        exit 1

# The actual code

echo "Demuxing with Project-X"

java -jar ProjectX/ProjectX.jar -demux -out . "$FILE.mpg"

echo "Remuxing with mplex"
mplex -f 9 -o "$FILE.remux.mpg" "$FILE.m2v" "$FILE.mp2"

echo "Fetching aspect ratio with mpginfo"
AR=`mpginfo -N "$FILE.remux.mpg" | grep 'Aspect ratio' | awk '{ print $3 }'`
echo "Passing AR $AR to mencoder"

echo "Reencoding video with mencoder"
mencoder -oac lavc -ovc lavc -of mpeg \
        -vf harddup \
        -lavcopts acodec=mp2:abitrate=256:vcodec=mpeg2video:vbitrate=9800:vrc_buf_size=1835:vrc_maxrate=9800:vstrict=0:keyint=15 \
        -mpegopts vaspect=$AR:format=dvd:tsaf \
        "$FILE.remux.mpg" -o "$FILE.out.mpg"