6.1. Selecting codecs and container formats

Audio and video codecs for encoding are selected with the -oac and -ovc options, respectively. Type for instance:

mencoder -ovc help

Audio Codecs:

Audio codec nameDescription
mp3lameencode to VBR, ABR or CBR MP3 with LAME
lavcuse one of libavcodec's audio codecs
faacFAAC AAC audio encoder
toolameMPEG Audio Layer 2 encoder
twolameMPEG Audio Layer 2 encoder based on tooLAME
pcmuncompressed PCM audio
copydo not reencode, just copy compressed frames

Video codecs:

Video codec nameDescription
lavcuse one of libavcodec's video codecs
xvidXvid, MPEG-4 Advanced Simple Profile (ASP) codec
x264x264, MPEG-4 Advanced Video Coding (AVC), AKA H.264 codec
nuvnuppel video, used by some realtime applications
rawuncompressed video frames
copydo not reencode, just copy compressed frames
framenoused for 3-pass encoding (not recommended)

Output container formats are selected with the -of option. Type:

mencoder -of help

Container formats:

Container format nameDescription
lavfone of the containers supported by libavformat
aviAudio-Video Interleaved
mpegMPEG-1 and MPEG-2 PS
rawvideoraw video stream (no muxing - one video stream only)
rawaudioraw audio stream (no muxing - one audio stream only)

libavformat containers:

If you selected libavformat to do the muxing of the output file (by using the -of lavf), the appropriate container format will be determined by the file extension of the output file. You may force a particular container format with libavformat's format option.

libavformat container nameDescription
mpgMPEG-1 and MPEG-2 PS
asfAdvanced Streaming Format
aviAudio-Video Interleaved
wavWaveform Audio
swfMacromedia Flash
flvMacromedia Flash video
rmRealMedia
auSUN AU
nutNUT open container (experimental and not yet spec-compliant)
movQuickTime
mp4MPEG-4 format
dvSony Digital Video container
mkvMatroska open audio/video container

例 6.1. encode to Macromedia Flash format

Creating a Macromedia Flash video suitable for playback in a web browser with the Macromedia Flash plugin:

mencoder input.avi -o output.flv -of lavf \
    -oac mp3lame -lameopts abr:br=56 -srate 22050 -ovc lavc \
    -lavcopts vcodec=flv:vbitrate=500:mbd=2:mv0:trell:v4mv:cbp:last_pred=3