How to transcode a video in VP9 with a 2-pass ABR method using FFmpeg?

FFmpeg provides functionalities to transcode a video in VP9 code with 2-Pass ABR. Following is an example of transcoding a video.

ffmpeg -i input.mp4 -c:v libvpx-vp9 -b:v 2M -pass 1 -an -f null /dev/null
ffmpeg -i input.mp4 -c:v libvpx-vp9 -b:v 2M -pass 2 -c:a libopus output.webm

For two-pass, you need to run ffmpeg twice, with almost the same settings, except for:

In pass 1 and 2, use the -pass 1 and -pass 2 options, respectively. In pass 1, output to a null file descriptor, not an actual file. (This will generate a log file that FFmpeg needs for the second pass.)
In pass 1, you can leave audio out by specifying -an.

If you want to transcode with 2-pass CQVBR (Constant Quality VBR) then you have to use -crf option and set -b:v to 0. Like the following command.


ffmpeg -i input.mp4 -c:v libvpx-vp9 -b:v 2M -pass 1 -an -f null /dev/null
ffmpeg -i input.mp4 -c:v libvpx-vp9 -b:v 2M -pass 2 -c:a libopus output.webm

For more information related to VP9 refer: How can I use the Ffmpeg to determine the codec header size from a webm (vp9) stream?