How to Encode VVC H.266 Video with FFmpeg
This guide provides a straightforward tutorial on how to transcode video files into the next-generation Versatile Video Coding (VVC/H.266) format using FFmpeg. You will learn about the required encoder library, how to verify your FFmpeg installation, and the exact command-line arguments needed to compress your videos efficiently using constant quality or target bitrate modes.
Prerequisites
FFmpeg does not encode VVC out of the box with native code; instead, it relies on the external Fraunhofer HHI VVC encoder library, libvvenc.
To transcode to VVC, you must use a build of FFmpeg compiled with the
--enable-libvvenc flag. You can verify if your FFmpeg
installation supports VVC encoding by running the following command in
your terminal:
ffmpeg -encoders | grep vvencIf the output lists libvvenc, your installation is
ready. If not, you will need to download a pre-compiled static build
that includes libvvenc (such as those from ggyyxx or build
pipelines like media-autobuild_suite) or compile FFmpeg from source with
the library enabled.
Basic VVC Encoding Command
Once you have a compatible FFmpeg build, you can transcode a video using the following basic command structure:
ffmpeg -i input.mp4 -c:v libvvenc -preset medium -qp 32 -c:a copy output.mp4Command breakdown: * -i input.mp4:
Specifies your source video. * -c:v libvvenc: Selects the
H.266/VVC encoder. * -preset medium: Controls the trade-off
between encoding speed and compression efficiency. Available presets are
faster, fast, medium,
slow, and slower. * -qp 32: Sets
the Quantization Parameter (quality level). Lower values yield higher
quality and larger file sizes; higher values yield lower quality and
smaller file sizes. A range of 28 to 36 is typical for general use. *
-c:a copy: Copies the audio stream without re-encoding to
save time. * output.mp4: The output container. Modern
FFmpeg builds support muxing VVC directly into MP4 containers.
Target Bitrate Encoding (ABR)
If you need your output file to target a specific file size or bandwidth limit, you can use average bitrate (ABR) encoding instead of QP mode.
ffmpeg -i input.mp4 -c:v libvvenc -preset fast -b:v 2M -c:a aac -b:a 128k output.mp4-b:v 2M: Targets a video bitrate of 2 Megabits per second (Mbps).-c:a aac -b:a 128k: Re-encodes the audio to AAC at 128 Kbps, ensuring broad compatibility.
Two-Pass Encoding for Maximum Efficiency
For the absolute best quality at a targeted bitrate, a two-pass encoding workflow is recommended. This allows the encoder to analyze the entire video first before allocating bits to complex scenes in the second pass.
Pass 1:
ffmpeg -i input.mp4 -c:v libvvenc -preset medium -b:v 2M -pass 1 -f null /dev/null(On Windows, replace /dev/null with
NUL)
Pass 2:
ffmpeg -i input.mp4 -c:v libvvenc -preset medium -b:v 2M -pass 2 -c:a aac -b:a 128k output.mp4