Changes between Version 1 and Version 2 of Encode/MPEG-4


Ignore:
Timestamp:
Jan 5, 2013, 6:58:23 PM (6 years ago)
Author:
evilsoup
Comment:

I've tried to bring it up to a similar standard as the x264 guide...

Legend:

Unmodified
Added
Removed
Modified
  • Encode/MPEG-4

    v1 v2  
     1= Xvid / Divx Encoding Guide = 
     2 
    13Although, it might be logical to use a command like this, to encode an XVID video: 
    24{{{ 
    3 ffmpeg -i input.avi -vcodec libxvid output.avi 
     5ffmpeg -i input.avi -c:v libxvid output.avi 
    46}}} 
    57 
    68but, there is another (better?) way of doing the same thing, with an internal ffmpeg's encoder, without the need for the external library, such as libxvid: 
    79{{{ 
    8 ffmpeg -i input.avi -vcodec mpeg4 -vtag xvid output.avi 
     10ffmpeg -i input.avi -c:v mpeg4 -vtag xvid output.avi 
    911}}} 
    1012 
     
    1214 
    1315"Both Xvid and DivX (version 4+) are implementations of the ISO MPEG-4 standard (note that there are many other coding formats that use this same standard). Thus, use ’-c:v mpeg4’ to encode in these formats. The default fourcc stored in an MPEG-4-coded file will be ’FMP4’. If you want a different fourcc, use the ’-vtag’ option. E.g., ’-vtag xvid’ will force the fourcc ’xvid’ to be stored as the video fourcc rather than the default." 
     16 
     17Note: this guide uses AVI container files for the examples, as the most common usage of Xvid video is currently for older hardware devices that don't support h.264 or the MP4 container. If you are using MPEG4 for some other reason, you should probably use the more modern MP4 container, or possible MKV (matroska). For audio the MP3 codec is used; again, this is because certain old hardware devices support MP3 audio only, and you should consider using a more modern codec, like AAC. Also, consider using h.264 video as described [[https://ffmpeg.org/trac/ffmpeg/wiki/x264EncodingGuide|in this guide]], as it will give you better quality video for a given file size, and is very well supported in recent hardware and software. 
     18 
     19== Variable Bit Rate with qscale == 
     20 
     21You can select a general quality level with -qscale n, where n is a number from 1-31, with 1 being highest quality/largest filesize and 31 being the lowest quality/smallest filesize. This is a variable bit rate mode, roughly analogous to [[https://ffmpeg.org/trac/ffmpeg/wiki/x264EncodingGuide#crf|using a -crf with x264]], except that the range is more linear. Most of the time, this should be the preferred method. 
     22 
     23For example: 
     24{{{ 
     25ffmpeg -i input.avi -c:v mpeg4 -vtag xvid -qscale 3 -c:a libmp3lame -q:a 4 output.avi 
     26}}} 
     27 
     28== Constant Bit Rate == 
     29 
     30You can target a bitrate with -b:v. This is best used with two-pass encoding. Adapting an example from the x264 encoding guide: your video is 10 minutes (600 seconds) long and an output of 50 MB is desired. Since bitrate = file size / duration:  
     31 
     32{{{ 
     33(50 MB * 8192 [converts MB to kilobits]) / 600 seconds = ~683 kilobits/s total bitrate 
     34683k - 128k (desired audio bitrate) = 555k video bitrate 
     35}}} 
     36 
     37=== Two-pass example === 
     38 
     39{{{ 
     40ffmpeg -i input.avi -c:v mpeg4 -vtag xvid -b:v 555k -pass 1 -an -f avi /dev/null 
     41ffmpeg -i input.avi -c:v mpeg4 -vtag xvid -b:v 555k -pass 2 -c:a libmp3lame -b:a 128k output.avi 
     42}}} 
     43 
     44Note: Windows users should use NUL instead of /dev/null.