Note: You are viewing an old version of this page. View the current version.

mencoder -dvd-device /dev/sr0 dvd://1 -aid 128 -sid 0 -ovc lavc -oac lavc -lavcopts vcodec=mpeg4:vpass=1:vbitrate=700:acodec=mp3:abitrate=192 -vf harddup -o video.avi

mencoder -dvd-device /dev/sr0 dvd://1 -aid 128 -ovc lavc -oac lavc -lavcopts vcodec=mpeg4:vpass=1:vbitrate=700:vhq:trell:acodec=mp3:abitrate=192 -vf harddup -o video.avi

Extract subtitles (why?) mencoder -dvd-device /dev/sr0 dvd://1 -vo copy -ao copy -o /dev/null -vobsubout video-english -vobsuboutid eng

Start Here

Ogg-Vorbis audio is not compatible with AVI containers. You must mux it separately.

Extract audio

mplayer dvd://1 -alang en -ao pcm:fast:waveheader:audio.wav -vc null -vo null

Encode audio

oggenc --quality 4.0 -o audio.ogg audio.wav

Use a pipe to streamline the previous two

mkfifo -m600 audio.pipe

These two must be run simultaneously (source first) and cannot be backgrounded.

mplayer dvd://1 -alang en -ao pcm:fast:waveheader:file=audio.pipe -vc null -vo null
oggenc --quality 4.0 -o audio2.ogg audio.pipe
rm audio.pipe

Calculate target bitrate from movie length and encoded audio size
movie length: 7446 seconds

video_space=$(((700 * 8388608) - $(stat -c '%s' audio.ogg) ))
video_length=7446
video_bitrate=$(( (${video_space} / ${video_length}) / 1024))

mencoder dvd://1 -sid 0 -noaudio -ovc lavc -lavcopts vcodec=mpeg4:vpass=1:vbitrate=${video_bitrate}:vhq:trell \
 -vf harddup -o /dev/null
mencoder dvd://1 -sid 0 -audiofile audio.ogg -sid 0 -ovc lavc -oac copy -lavcopts \
 vcodec=mpeg4:vpass=2:vbitrate=${video_bitrate}:vhq:trell -vf harddup -o video.avi
  • -ss - selects a start time in seconds or hh:mm:ss.mmm - Note that this is not accurate--it will start at the first keyframe after the chosen timeframe.
  • -endpos - specifies the number of seconds to encode before stopping

Mencoer options are poorly documented!

If 'Skipping frame!' or '1 duplicate frame(s)!' warnings occur repeatedly, and the resultant audio grows out of sync (as if one is faster) then try tweaking the source framerate. 'skipping frame' means there's too many frames coming in, so try a lower fps. 'duplicate frame' means there isn't enough frames coming in to satisfy the outgoing framerate, so try a higher source fps. Try and tweak so that there are as few of each message as possible.

  • -fps <decimal|fraction> - specifies the source framerate. The fraction can be, for instance, 24000/1001 for 23.976fps.
  • -ofps <decimal|fraction> - specifies the output frame rate. This must be set to the actual real framerate of the source, so that the frames line up with the audio.

( In two samples, the settings that got near-perfect results were '-fps 22000/1020 -ofps 24000/1001' )

-- mencoder doesn't support rendering SSA/ASS subtitles, and renders them as regular text. Very ugly.
To get around this, you can pre-render using mplayer. Beware, this takes an obscene amount of disk space (raw video frames)

mplayer -ass -sub file.ass -vo yuv4mpeg file.avi
mplayer -sid 0 -vo yuv4mpeg file.avi
# dump video
mplayer -nosound -noframedrop -noautosub -vo yuv4mpeg:file=stream.y4m 300_F2_1080P.mov

# dump audio
mplayer -vo null -vc null -ao pcm:fast 300_F2_1080P.mov

# Encode
mencoder stream.y4m -audiofile audiodump.wav -fps 24000/1001 -o test.mpeg -of mpeg -mpegopts format=dvd:tsaf -srate 48000 -ofps 25 -ovc lavc -oac lavc -lavcopts vcodec=mpeg2video:vrc_buf_size=1835:keyint=15:vrc_maxrate=9800:vbitrate=4900:aspect=24/10:acodec=ac3:abitrate=192 -vf scale=720:300,expand=720:300,harddup