Changes between Initial Version and Version 1 of Encode/VP8


Ignore:
Timestamp:
Feb 24, 2013, 9:35:10 PM (7 years ago)
Author:
slhck
Comment:

created first version

Legend:

Unmodified
Added
Removed
Modified
  • Encode/VP8

    v1 v1  
     1libvpx is the VP8 video encoder for [http://www.webmproject.org/about/ WebM], an open, royalty-free media file format. This guide is an attempt to summarize the most important options for creating video with libvpx.
     2
     3To install FFmpeg with support for libvpx, look at the [https://ffmpeg.org/trac/ffmpeg/wiki/CompilationGuide Compilation Guides] and compile FFmpeg with the {{{--enable-libvpx}}} option.
     4
     5Note that in the below examples, the libvorbis audio encoder is used. Make sure your FFmpeg version also includes this (check with {{{ffmpeg -codecs}}}), as the native Vorbis encoder from FFmpeg itself should not be used.
     6
     7== Constant Bitrate ==
     8
     9Like most other encoders, libvpx offers a constant bitrate encoding mode, which tries to encode the video in such a way that an average bitrate is reached. This doesn't mean that every frame is encoded with the same amount of bits (since it would harm quality), but the bitrate will be very constrained. You should use constant bitrate encoding if you need your video files to have a certain size, or if you're streaming the videos over a channel that only allows a certain bit rate.
     10
     11The syntax for setting a constant bit rate is:
     12
     13{{{
     14ffmpeg -i input.mp4 -c:v libvpx -minrate 1M -maxrate 1M -b:v 1M -c:a libvorbis output.webm
     15}}}
     16
     17Here, you can choose different values for the bitrate other than `1M`, e.g. `500K`, but you must set all options (i.e., `minrate`,`maxrate` and `b:v`) to the same value.
     18
     19== Variable Bitrate ==
     20
     21libvpx offers two different variable bitrate modes, but FFmpeg (at the moment) only uses the one called "Constant Quality" (CQ).  Like in the x264 encoder (for H.264 video), a constant quality mode will ensure that every frame gets the number of bits it deserves to achieve a certain quality level, rather than forcing the stream to have an average bit rate. This results in overall better quality and should be the default method of encoding video with libvpx.
     22
     23There are four important parameters for encoding VBR with libvpx, all of which are optional, but there are some caveats:
     24
     25* `-qmin` – the minimum quantizer (default 4)
     26* `-qmax` – the maximum quantizer (default 63)
     27* `-b:v` – the target bit rate setting. If not set, the encoder will choose ~1000 kBit/s as a default, but only when the `-crf` option is used.
     28* `-crf` – the overall quality setting. If not set, the encoder will do "normal" VBR, trying to reach the target bitrate in within the `qmin`/`qmax` bounds. If set, the encoder will use CQ mode, and the target bitrate will become the maximum allowed bitrate. The CRF value is 10 by default.
     29
     30Important: If neither `-b:v` nor `-crf` are set, the encoder will use a default bitrate of 256 kBit/s and your result will probably look very bad.
     31
     32So, how do you set the quality?
     33
     34* `-qmin` should be set from 0–4, and `-qmax` from 50–63. These Q values are quantization parameters, and lower generally means "better quality". If you set the bounds from 0 to 63, this means the encoder has free choice of how to assign the quality. You can try to set `-qmax` to 50 to get an overall better quality.
     35* `-crf` defaults to 10 and seems like a good choice. Lower values mean better quality, and the worst quality is achieved with `-crf 63`.
     36* `-b:v` should be set to your target bitrate if you don't use `-crf`, or your maximum allowed bit rate if you use `-crf`. In the latter case, libvpx will try not to overshoot it.
     37
     38To summarize this, in one example with constant quality and an allowed maximum bit rate of 1 MBit/s:
     39
     40{{{
     41ffmpeg -i input.mp4 -c:v libvpx -crf 10 -b:v 1M -c:a libvorbis output.webm
     42}}}
     43
     44Or, if you want to have libvpx just target 2 MBit/s:
     45
     46{{{
     47ffmpeg -i input.mp4 -c:v libvpx -b:v 2M -c:a libvorbis output.webm
     48}}}
     49
     50You can also artificially force libvpx to use a certain quality if you specify `-qmin` and `-qmax` without any bit rate or CRF value, but this is not an ideal solution.
     51
     52