Changes between Version 8 and Version 9 of Encode/VP9
- Timestamp:
- Oct 31, 2017, 10:39:06 AM (9 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Encode/VP9
v8 v9 9 9 Note that the default audio encoder for WebM is libopus, but if it is not available then libvorbis will be used instead. 10 10 11 VP9 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 11 18 == Variable Bitrate (VBR) ==#variableb 12 19 13 20 === Average Bitrate (ABR) ===#averageb 14 21 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. 22 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. 23 24 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. 16 25 17 26 {{{ … … 23 32 === Two-Pass ===#twopass 24 33 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: 34 In 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. 26 40 27 41 {{{ 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.webm42 ffmpeg -i input.mp4 -c:v libvpx-vp9 -b:v 2M -pass 1 -c:a libopus -f webm /dev/null && \ 43 ffmpeg -i input.mp4 -c:v libvpx-vp9 -b:v 2M -pass 2 -c:a libopus output.webm 30 44 }}} 31 45 32 46 {{{ 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 51 For 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 {{{ 54 ffmpeg -i input.mp4 -c:v libvpx-vp9 -b:v 2M -pass 1 -speed 4 -c:a libopus -f webm /dev/null && \ 55 ffmpeg -i input.mp4 -c:v libvpx-vp9 -b:v 2M -pass 2 -speed 1 -c:a libopus output.webm 35 56 }}} 36 57 … … 79 100 == Lossless VP9 == 80 101 81 libvpx-vp9 has a lossless encoding mode that can be activated using `-lossless 1`. 102 libvpx-vp9 has a lossless encoding mode that can be activated using `-lossless 1`: 103 104 {{{ 105 ffmpeg -i input.mp4 -c:v libvpx-vp9 -lossless 1 output.webm 106 }}} 82 107 83 108 == Controlling Speed and Quality ==#speed … … 93 118 - `realtime` is recommended for live / fast encoding. 94 119 95 === CPU Utilization ===120 === CPU Utilization / Speed === 96 121 97 122 `-cpu-used` sets how efficient the compression will be. For legacy reasons, the option is also accessible with `-speed` in ffmpeg. 98 123 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).124 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. 100 125 101 126 When 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 103 127 104 128 == Also see ==
