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


Ignore:
Timestamp:
Jan 10, 2013, 4:57:01 AM (5 years ago)
Author:
llogan
Comment:

building a reputation as a nitlord

Legend:

Unmodified
Added
Removed
Modified
  • Encode/MPEG-4

    v2 v3  
    11= Xvid / Divx Encoding Guide = 
    22 
    3 Although, it might be logical to use a command like this, to encode an XVID video: 
     3FFmpeg has two encoders to output Xvid video. The external libxvid encoding library: 
    44{{{ 
    55ffmpeg -i input.avi -c:v libxvid output.avi 
    66}}} 
    77 
    8 but, 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: 
     8...and the native `mpeg4` encoder: 
    99{{{ 
    1010ffmpeg -i input.avi -c:v mpeg4 -vtag xvid output.avi 
    1111}}} 
    1212 
    13 Source: [http://ffmpeg.org/faq.html#How-do-I-encode-Xvid-or-DivX-video-with-ffmpeg_003f] 
     13The native encoder has the advantage of not requiring an external library and both encoders should provide a similar output. 
    1414 
    15 "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." 
     15From [http://ffmpeg.org/faq.html#How-do-I-encode-Xvid-or-DivX-video-with-ffmpeg_003f How do I encode Xvid or DivX video with ffmpeg?]: 
    1616 
    17 Note: 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. 
     17  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. 
    1818 
    19 == Variable Bit Rate with qscale == 
     19'''Note:''' 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 or MKV (Matroska) containers. For audio the MP3 codec is used; again, this is because certain old hardware devices support MP3 audio only, and you can consider using another codec like AAC. Also, consider using H.264 video as described in the [[https://ffmpeg.org/trac/ffmpeg/wiki/x264EncodingGuide|x264 Encoding Guide]], as it will give you better quality video for a given file size, and is very well supported in recent hardware and software. 
    2020 
    21 You 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. 
     21== Variable Bit Rate with `qscale` == 
    2222 
    23 For example: 
     23You can select a video quality level with `-qscale:v n` (or the alias `-q:v 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 using `-qp` (constant QP [quantization parameter]) with x264. Most of the time this should be the preferred method. 
     24 
     25You can select an audio quality level with `-qscale:a` (or the alias `-q:a`). The value changes depending on the audio encoder. Since this guide uses libmp3lame see the [[Encoding VBR (Variable Bit Rate) mp3 audio|MP3 Encoding Guide]] for examples and more information. 
     26 
     27Example: 
    2428{{{ 
    25 ffmpeg -i input.avi -c:v mpeg4 -vtag xvid -qscale 3 -c:a libmp3lame -q:a 4 output.avi 
     29ffmpeg -i input.avi -c:v mpeg4 -vtag xvid -qscale:v 3 -c:a libmp3lame -qscale:a 4 output.avi 
    2630}}} 
    2731 
    2832== Constant Bit Rate == 
    2933 
    30 You 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:  
     34You 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:  
    3135 
    3236{{{ 
     
    3842 
    3943{{{ 
    40 ffmpeg -i input.avi -c:v mpeg4 -vtag xvid -b:v 555k -pass 1 -an -f avi /dev/null 
     44ffmpeg -y -i input.avi -c:v mpeg4 -vtag xvid -b:v 555k -pass 1 -an -f avi /dev/null 
    4145ffmpeg -i input.avi -c:v mpeg4 -vtag xvid -b:v 555k -pass 2 -c:a libmp3lame -b:a 128k output.avi 
    4246}}} 
    4347 
    44 Note: Windows users should use NUL instead of /dev/null.  
     48Note: Windows users should use `NUL` instead of `/dev/null`.