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

I was exploring the VP9 codec and wanted to transcode a video with the VP9 codec using FFmpeg, what kind of parameters do I need to pass to FFmpeg to achieve 2-pass ABR transcoding in the VP9 codec?

Try this:
ffmpeg -i input.mp4 -c:v libvpx-vp9 -c:a libopus output.webm

Thank you,
Unfortunately, the command is broken. Probably the issue is that I don’t have a vp9 encoder installed or included (I thought that it was in the ffmpeg 2. x).

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?

I installed FFmpeg and all its components via this guide and it works now! Sign in - Google Accounts

How can I determine whether the input file uses VP9 or another codec?

With my version of ffmpeg,

$ ffmpeg -version

ffmpeg version 2.3.3 Copyright (c) 2000-2014 the FFmpeg developers