FFmpeg fails to save VP9 HDR10 4K input as HEVC because default pixel formats discard high-bit-depth data. Use -pix_fmt p010le for hardware acceleration or yuv420p10le for software encoding. This preserves the 10-bit HDR metadata and prevents the output from being downgraded to standard dynamic range.
The Core Issue: Pixel Format Mismatch
When you attempt to transcode a 4K VP9 video with HDR10 metadata into an HEVC container, the most common failure point is not the codec itself, but the pixel format. HDR10 requires a 10-bit depth to store the wider color gamut and higher luminance values. By default, FFmpeg often attempts to convert this to an 8-bit format likeyuv420p during the encoding process. This conversion truncates the bit-depth, effectively stripping the HDR characteristics from your video. The resulting file saves successfully, but it lacks the HDR metadata and visual fidelity you expect, appearing washed out or incorrectly graded on compatible displays.
The term "not saving" in user reports usually refers to the output file existing but lacking the expected HDR properties, or failing entirely due to unsupported pixel format combinations. If the encoder cannot handle the native 10-bit stream, it may crash or produce a corrupted container. Understanding the distinction between the input stream's native format and the required output pixel format is critical for successful transcoding.
Software Encoding Solution
For users relying on CPU-based encoding vialibx265, the solution involves explicitly specifying a 10-bit pixel format that matches the input's capabilities. You must instruct FFmpeg to maintain the 10-bit depth throughout the pipeline.
Use the following command structure:
ffmpeg -i input_vp9_hdr10.mkv -c:v libx265 -pix_fmt yuv420p10le -crf 18 output_hevc_hdr10.mp4
Here, -pix_fmt yuv420p10le forces the encoder to use a 10-bit YUV 4:2:0 format. This is widely supported by modern players and devices. The -crf 18 setting ensures high quality, though you should adjust this based on your storage constraints. If you encounter errors stating that the pixel format is not supported, verify that your version of libx265 supports 10-bit encoding. Most modern builds do, but older versions might require recompilation or updating.
If you are using a newer version of FFmpeg, you can also try yuv420p10le without specifying the endianness, as FFmpeg often handles the byte order automatically. However, explicit specification reduces ambiguity.
Hardware Acceleration Considerations
Many users seek faster encoding times using NVIDIA NVENC or AMD AMF encoders. Hardware encoders have stricter requirements regarding pixel formats. As discussed in our guide on HEVC NVENC with ffmpeg: '-pix_fmt p010le' and '-pix_fmt yuv420p10le' doesn't work, hardware accelerators often require specific internal formats that differ from software encoders. For NVIDIA cards supporting NVENC, you typically need to usep010le. The command would look like this:
ffmpeg -hwaccel cuda -hwaccel_output_format cuda -i input_vp9_hdr10.mkv -c:v hevc_nvenc -pix_fmt p010le -crf 18 output_hevc_hdr10.mp4
Note the use of -hwaccel cuda and -hwaccel_output_format cuda. These flags ensure that the decoding happens on the GPU and the frames remain in GPU memory, avoiding slow CPU-GPU transfers. If you skip these, FFmpeg might try to convert the frame to a CPU-readable format, which can lose HDR metadata or cause performance bottlenecks. Always check your GPU driver support for 10-bit HEVC encoding, as older drivers may not support this feature.
Verifying HDR Metadata Preservation
After encoding, it is essential to verify that the HDR metadata was preserved. Useffprobe to inspect the output file:
ffprobe -v error -show_entries stream=width,height,pix_fmt,tag:STUDIO -of default=noprint_wrappers=1:nokey=1 output_hevc_hdr10.mp4
Look for pix_fmt indicating 10-bit (e.g., yuv420p10le or p010le). Additionally, check for tags related to color transfer characteristics. If the pixel format is 8-bit, the HDR information is lost. For a deeper dive into error resilience when dealing with complex HEVC streams, refer to our article on FFmpeg Error Resilience: A Solution for Wonky HEVC Video Files.
Common Pitfalls and Troubleshooting
One frequent mistake is assuming that simply changing the container format (e.g., from MKV to MP4) will preserve HDR. It does not. The pixel format and color space tags must be explicitly handled. Another issue arises with VP9 inputs that have unusual dimensions or chroma subsampling. While 4K is standard, some VP9 files may use 4:2:2 or 4:4:4 chroma subsampling, which many HEVC encoders do not support. In such cases, you may need to add a scaling filter to convert to 4:2:0 before encoding. Also, ensure that your input file actually contains HDR10 metadata. Some files labeled as HDR may only be mastered in SDR and upscaled. Useffprobe to check the input stream's color transfer and matrix coefficients. If the input is not true HDR10, no amount of encoding settings will create valid HDR metadata in the output.
Finally, be aware of container limitations. While MP4 is common, it has strict limits on stream duration and size. For large 4K HDR files, MKV is often a safer choice for intermediate processing. If you experience audio sync issues after converting to MKV, see our guide on Delays in Audio Sync Playback with FFmpeg: A Solution for MKV Files with HEVC Video, AAC Audio, and MJPEG Subtitles.
Frequently Asked Questions
Why does my HEVC output look flat despite using 10-bit pixel format?
The issue is likely missing color space tags rather than pixel depth. Ensure you include-color_primaries bt2020 -color_trc smpte428 -colorspace bt2020nc in your command. Without these tags, players may interpret the 10-bit data as SDR, resulting in a washed-out appearance.
Can I use libsvtav1 instead of libx265 for VP9 HDR10?
Yes, SVT-AV1 is highly efficient for AV1 output, but if you specifically need HEVC, stick with libx265 or nvenc. SVT-AV1 does not encode HEVC. Using the wrong encoder will result in an AV1 file, not HEVC, which may not be compatible with your target devices.What if I get a 'pixel format not supported' error with NVENC?
This usually means your GPU driver or FFmpeg build does not support 10-bit NVENC. Update your NVIDIA drivers to the latest version. Alternatively, try usingyuv420p10le instead of p010le, as some older hardware implementations prefer the former.
Does HDR10 require a specific container format?
No, HDR10 metadata can be stored in both MP4 and MKV containers. However, MKV is more flexible with multiple streams and subtitles. MP4 is more universally supported by consumer electronics like smart TVs and game consoles.How do I know if my source VP9 file is actually HDR10?
Useffprobe to check the stream metadata. Look for tags like STUDIO or color primaries set to BT.2020. If the color transfer characteristic is BT.709, the file is likely SDR, even if it is 10-bit.