# HG changeset patch # User gpoirier # Date 1113418410 0 # Node ID 067f10ad65386d67ee6cb7cfd914ff9e178bb4df # Parent 9198a882c8871d1447c6c216ff6eb452774758a8 New section: "menc-feat-dvd-mpeg4-muxing" about how to mux a video obtained with MEncoder into different containers. Based on Rich's guide and some tips by Nico Sabi. Reviewed by The Wanderer, Dominik 'Rathann' Mierzejewski and Diego Biurrun diff -r 9198a882c887 -r 067f10ad6538 DOCS/xml/en/mencoder.xml --- a/DOCS/xml/en/mencoder.xml Wed Apr 13 18:31:44 2005 +0000 +++ b/DOCS/xml/en/mencoder.xml Wed Apr 13 18:53:30 2005 +0000 @@ -1290,6 +1290,142 @@ + +Muxing + + Now that you have encoded your video, you will most likely want + to mux it with one or more audio tracks into a movie container, such + as AVI, Matroska or NUT. + MEncoder is currently only able to output + audio and video into MPEG and AVI container formats. + for example: + mencoder -oac copy -ovc copy -o output_movie.avi -audiofile input_audio.mp2 input_video.avi + This would merge the video file input_video.avi + and the audio file input_audio.mp2 + into the AVI file output_movie.avi. + This command works with MPEG-1 layer I, II and III (more commonly known + as MP3) audio, WAV and a few other audio formats too. + + + + MEncoder features experimental support for + libavformat, which is a + library from the FFmpeg project that supports muxing and demuxing + a variety of containers. + For example: + mencoder -oac copy -ovc copy -o output_movie.asf -audiofile input_audio.mp2 input_video.avi -of lavf -lavfopts format=asf + This will do the same thing as the previous example, except that + the output container will be ASF. + Please note that this support is highly experimental (but getting + better every day), and will only work if you compiled + MPlayer with the support for + libavformat enabled (which + means that a pre-packaged binary version will not work in most cases). + + + +Limitations of the AVI container + + Although it is the most widely-supported container format after MPEG-1, + AVI also has some major drawbacks. + Perhaps the most obvious is the overhead. + For each chunk of the AVI file, 24 bytes are wasted on headers and + index. + This translates into a little over 5 MB per hour, or 1-2.5% + overhead for a 700 MB movie. This may not seem like much, but it could + mean the difference between being able to use 700 kbit/sec video or + 714 kbit/sec, and every bit of quality counts. + + + + In addition this gross inefficiency, AVI also has the following major + limitations: + + + + + + Only fixed-fps content can be stored. This is particularly limiting + if the original material you want to encode is mixed content, for + example a mix of NTSC video and film material. + Actually there are hacks that can be used to store mixed-framerate + content in AVI, but they increase the (already huge) overhead + fivefold or more and so are not practical. + + + + + Audio in AVI files must be either constant-bitrate (CBR) or + constant-framesize (i.e. all frames decode to the same number of + samples). + Unfortunately, the most efficient codec, Vorbis, does not meet + either of these requirements. + Therefore, if you plan to store your movie in AVI, you'll have to + use a less efficient codec such as MP3 or AC3. + + + + + + Having said all that, MEncoder does not + currently support variable-fps output or Vorbis encoding. + Therefore, you may not see these as limitations if + MEncoder is the + only tool you will be using to produce your encodes. + However, it is possible to use MEncoder + only for video encoding, and then use external tools to encode + audio and mux it into another container format. + + + + +Muxing into the Matroska container + + The Matroska is a free, open standard container format, aiming + to offer a lot of advanced features, which older containers + like AVI cannot handle. + For example, Matroska supports variable bitrate audio content + (VBR), variable framerates (VFR), chapters, file attachments, + error detection (EDC) and modern A/V Codecs like "advanced audio + coding" (AAC), "Vorbis" or "MPEG-4 AVC" (H.264), next to nothing + handled by AVI. + + + + The tools required to create Matroska files are collectively called + mkvtoolnix, and are available for most + Unix platforms as well as Windows. + Given that Matroska is an open standard, you may find other + tools that suit you better, but since mkvtoolnix is the most + common, and is supported by the Matroska team itself, we will + only cover its usage. + + + + Probably the easiest way to get started with Matroska is to use + MMG, the graphical frontend shipped with + mkvtoolnix, and follow the + guide to mkvmerge GUI (mmg) + + + + You may also mux audio and video files using the command line: + mkvmerge -o output.mkv input_video.avi input_audio1.mp3 input_audio2.ac3 + This would merge the video file input_video.avi + and the two audio files input_audio1.mp3 + and input_audio2.ac3 into the Matroska + file output.mkv. + Matroska, as mentioned earlier, is able to do much more than that, like + multiple audio tracks (including fine-tuning of audio/video + synchronization), chapters, subtitles, splitting, etc... + Please refer to the documentation of those applications for + more details. + + + + + +