Mencoder Cheat Sheet

Mencoder is a video encoder for linux. It is part of the mplayer package which also includes a video player. This tool is quite versatile and can do pretty much any kind of video processing all from the console.

As with any linux tool, there a tons of bells and whistles. This makes the learning curve kind of steep, but with a bit of determination anyone can make sense of it. Without further ado, here’s the cheat sheet:

mencoder clip1.avi clip2.avi -ovc copy -oac copy -o new-clip.aviCopies clip1 and clip2 into new-clip.avi
mencoder clip.avi -ovc xvid -xvidencopts bitrate=800  -oac lamemp3 -lameopts cb:br=128 -o new-clip.aviEncodes a clip with the xvid codec at 800Kbps and mp3 audio at 128Kbps.
mencoder clip.avi -ovc xvid -xvidencopts bitrate=800:threads=2  -oac lamemp3 -lameopts cbr:br=128 -o new-clip.aviSame as above, but uses 2 threads for the xvid encoding.
mencoder clip.avi -endpos 00:05:00 -ovc copy -oac copy -o new-clip.aviCopies the first 5 minutes from clip.avi into new-clip.avi
mencoder clip.avi -endpos 00:05:00 -ss 00:01:00 -ovc copy -oac copy -o new-clip.aviCopies 5 minutes from clip.avi into new-clip.avi, skipping the first minute.
mencoder dvb://WJBF-DT -endpos 01:0000 -ovc copy -oac copy -o ugly.betty.mpegTunes to WJBF-DT, records 1 hour of that station to ugly.betty.mpeg
mencoder clip.avi -vf scale=640:-2 -ovc xvid -xvidencopts bitrate=1200:threads=2 -oac copy -o new-clip.aviResizes the video to 640 wide, keeping the aspect ration, then encoding video using xvid at 1200Kbps and copying the audio directly
mencoder tv:// -tv driver=v4l2:width=640:height=480:device=/dev/video0 -ovc lavc -o >(tee webcam-`date +%Y-%m-%d-%H.%M.%S`.avi | mplayer -cache 128)Records the webcam to “”, where that is the date, and display it to the screen while recording.
mencoder -idx clip.avi -ovc copy -oac copy new-clip.aviFixes the AVI index of clip.avi, the output being new-clip.avi
mencoder clip.avi -vf cropdetect -o /dev/nullDetects what cropping is needed
mencoder clip.avi -of mpeg -mpegopts format=dvd -lavcopts vcodec=mpeg2video:vbitrate=5000:acodec=ac3 -o dvd-clip.mpegEncodes clip.avi into a dvd-compatible mpeg at 5000Kbps
mencoder -dvd 2 -ovc lavc -lavcopts vcodec=mpeg4 -oac copy -o dvd.aviRips a DVD to dvd.avi