VP9 Two-Pass Encoding: How to Run the First Pass
Performing a two-pass encode with the libvpx-vp9 codec
in FFmpeg is the industry standard for achieving the best balance
between video quality and target file size. This guide explains how to
execute the initial first pass of this process, detailing the specific
command-line arguments required to analyze your source video and
generate the necessary log file for the second pass.
To run the first pass of a two-pass VP9 encode, you must use FFmpeg to analyze the video and write the analysis statistics to a log file. Because the actual video output of the first pass is not needed, you discard the output video stream to save time and disk space.
The First Pass Command
Run the following command in your terminal:
ffmpeg -i input.mp4 -c:v libvpx-vp9 -b:v 2M -pass 1 -an -f null /dev/nullNote: If you are using Windows, replace /dev/null at
the end of the command with NUL.
Parameter Breakdown
-i input.mp4: Specifies the path to your source video file.-c:v libvpx-vp9: Selects the VP9 video encoder.-b:v 2M: Sets the target video bitrate (e.g., 2 Megabits per second). This target is crucial, as the first pass analyzes how to best distribute these bits across the duration of the video.-pass 1: Instructs FFmpeg to run the first pass of the two-pass mode. This automatically generates a log file namedffmpeg2pass-0.login your current directory.-an: Disables audio processing. Excluding audio during the first pass speeds up the encoding process, as audio only needs to be processed during the second pass.-f null /dev/null(orNULon Windows): Forces FFmpeg to output to a “null” muxer, effectively discarding the video output. This ensures you only write the lightweight log file needed for the next step.
Once this command finishes, you will see a newly created log file in your directory. You are then ready to execute the second pass, which will read this log file to apply the final compression and encode the audio.