Changes between Version 8 and Version 9 of Encode/VP9


Ignore:
Timestamp:
Oct 31, 2017, 12:39:06 PM (23 months ago)
Author:
slhck
Comment:

add more explanation and examples, and link to Google rate control page

Legend:

Unmodified
Added
Removed
Modified
  • Encode/VP9

    v8 v9  
    99Note that the default audio encoder for WebM is libopus, but if it is not available then libvorbis will be used instead.
    1010
     11VP9 offers [https://developers.google.com/media/vp9/bitrate-modes/ different rate control modes], which determine the quality and file size:
     12
     13* 1-pass average bitrate
     14* 2-pass average bitrate
     15* Constant quality
     16* Constant bitrate
     17
    1118== Variable Bitrate (VBR) ==#variableb
    1219
    1320=== Average Bitrate (ABR) ===#averageb
    1421
    15 libvpx-vp9 offers a simple variable bitrate (VBR) mode by default. This is also sometimes called "Average Bitrate" or "Target Bitrate". In this mode, it will simply try to reach the specified bit rate on average, e.g. 2 MBit/s. It is not usually recommended to use this mode, as the output may not be compression-efficient, or lead to quality variations. Instead, use [#twopass Two-Pass] or [#constantq Constant Quality] encoding.
     22libvpx-vp9 offers a simple variable bitrate (VBR) mode by default. This is also sometimes called "Average Bitrate" or "Target Bitrate". In this mode, it will simply try to reach the specified bit rate on average, e.g. 2 MBit/s.
     23
     24It is not usually recommended to use this mode, as the output may not be compression-efficient, or lead to quality variations. Instead, use [#twopass Two-Pass] or [#constantq Constant Quality] encoding.
    1625
    1726{{{
     
    2332=== Two-Pass ===#twopass
    2433
    25 In order to create more efficient encodes when a particular target bitrate should be reached, you should choose two-pass encoding. For this, you need to run the encoding step twice:
     34In order to create more efficient encodes when a particular target bitrate should be reached, you should choose two-pass encoding. For two-pass, you need to run `ffmpeg` twice, with almost the same settings, except for:
     35
     36* In pass 1 and 2, use the `-pass 1` and `-pass 2` options, respectively.
     37* In pass 1, output to a null file descriptor, not an actual file. (This will generate a logfile that ffmpeg needs for the second pass.)
     38* In pass 1, you need to specify an output format (with `-f`) that matches the output format you will use in pass 2.
     39* In pass 1, specify the audio codec used in pass 2; in many cases, `-an` in pass 1 will not work.
    2640
    2741{{{
    28 ffmpeg -i input.mp4 -c:v libvpx-vp9 -b:v 2M -pass 1 -f webm /dev/null && \
    29 ffmpeg -i input.mp4 -c:v libvpx-vp9 -b:v 2M -pass 2 output.webm
     42ffmpeg -i input.mp4 -c:v libvpx-vp9 -b:v 2M -pass 1 -c:a libopus -f webm /dev/null && \
     43ffmpeg -i input.mp4 -c:v libvpx-vp9 -b:v 2M -pass 2 -c:a libopus output.webm
    3044}}}
    3145
    3246{{{
    33 #!div style="border: 1pt dotted; margin: 1em; background-color: #fffff9;"
    34 '''Note:''' Windows users should use `NUL` instead of `/dev/null`.
     47#!div style="border: 1px solid #e5e5c7; margin: 1em; background-color: #ffd;"
     48'''Note:''' Windows users should use `NUL` instead of `/dev/null` and `^` instead of `\`.
     49}}}
     50
     51For two-pass encoding, you can choose a higher encoding speed for the first pass (e.g., 4), and a lower one for the second pass (e.g. 1). This will speed up the entire process (for more info, scroll down to the [#speed section about controlling speed]:
     52
     53{{{
     54ffmpeg -i input.mp4 -c:v libvpx-vp9 -b:v 2M -pass 1 -speed 4 -c:a libopus -f webm /dev/null && \
     55ffmpeg -i input.mp4 -c:v libvpx-vp9 -b:v 2M -pass 2 -speed 1 -c:a libopus output.webm
    3556}}}
    3657
     
    79100== Lossless VP9 ==
    80101
    81 libvpx-vp9 has a lossless encoding mode that can be activated using `-lossless 1`.
     102libvpx-vp9 has a lossless encoding mode that can be activated using `-lossless 1`:
     103
     104{{{
     105ffmpeg -i input.mp4 -c:v libvpx-vp9 -lossless 1 output.webm
     106}}}
    82107
    83108== Controlling Speed and Quality ==#speed
     
    93118- `realtime` is recommended for live / fast encoding.
    94119
    95 === CPU Utilization ===
     120=== CPU Utilization / Speed ===
    96121
    97122`-cpu-used` sets how efficient the compression will be. For legacy reasons, the option is also accessible with `-speed` in ffmpeg.
    98123
    99 When the deadline/quality parameter is `good` or `best`, values for `-cpu-used` can be set between 0 and 5. The default is 0. Using 1 or 2 will increase encoding speed at the expense of having some impact on quality and rate control accuracy. 4 or 5 will turn off rate distortion optimization, having even more of an impact on quality. For two-pass encoding, it is recommended to set a higher speed for the first pass (e.g., 4), and a lower one for the second pass (e.g. 1).
     124When the deadline/quality parameter is `good` or `best`, values for `-cpu-used` can be set between 0 and 5. The default is 0. Using 1 or 2 will increase encoding speed at the expense of having some impact on quality and rate control accuracy. 4 or 5 will turn off rate distortion optimization, having even more of an impact on quality.
    100125
    101126When the deadline/quality is set to `realtime`, the encoder will try to hit a particular CPU utilization target, and encoding quality will depend on CPU speed and the complexity of the clip that you are encoding. See [https://www.webmproject.org/docs/encoder-parameters/ the vpx documentation] for more info. In this case, the valid values for `-cpu-used` are between 0 and 15, where the CPU utilization target (in per cent) is calculated as `(100*(16-cpu-used)/16)%`.
    102 
    103127
    104128== Also see ==