A new OS experience

2009-06-29

Decoding and Encoding With MEncoder

I use the following to encode DVD to AVI and rencode to a smaller DVD.

#!/bin/bash

# Two pass encoding from DVD to AVI using MEncoder (NTSC). The following
# two pass method rips the first title (dvd://1) from the DVD. This
# method will NOT encode the subtitles so it pulls only the main title
# which usually is title 1. The following method encodes an AVI using
# XViD codecs and generally will compress the data down to < 4GB.

# Pass 1 (no crop)
mencoder dvd://1 -dvd-device /media/dvd -aid 128 -sws 9 -ovc xvid -xvidencopts pass=1:bitrate=1300:vhq=1:max_bframes=2:threads=2 -nosound -noodml -o /dev/null

#Pass 2 (no crop)
mencoder dvd://1 -dvd-device /media/dvd -aid 128 -sws 9 -ovc xvid -xvidencopts pass=2:bitrate=1300:vhq=1:max_bframes=2:threads=2 -oac copy -noodml -o "movie.avi"

# Once mencoder is finished a file called movie.avi will contain the
# first title. If there are multiple titles as is the case of episodes
# you would have to run the above for each title. Next use ffmpeg to
# convert movie.avi into a DVD (NTSC) compliant MPEG. Followed by
# dvdauthor to create a DVD file system and mkisofs to turn it into
# a burnable DVD ISO.


# Use ffmpeg to convert AVI to DVD compliant MPEG
ffmpeg -i movie.avi -target ntsc-dvd -sameq -aspect 16:9 -y movie.mpg

# Use dvdauthor to create the simple DVD filesystem
dvdauthor --title -o myDVD -f movie.mpg

# Use dvdauthor to create the TOC
dvdauthor -o myDVD -T

# Create an iso to burn
mkisofs -dvd-video -o myMovie.iso myDVD/

# Burn the iso using growisofs. Make sure there is a DVD in the DVD
# burner. Note that the DVD will most likely work only on progressive
# scan DVD players. To burn the dvd use the following
growisofs -dvd-compat -Z /dev/dvd=myMovie.iso

# Perform cleanup, leaving only the iso files or make changes to
# keep only the files you need by commenting out respective lines

# Removing MPEG files
rm movie.mpg

# Removing AVI files
rm movie.avi

# Removing DVD directory
rm -R myDVD

No comments: