From 2972216a02d15477b7772d878ab129aa0a6f0488 Mon Sep 17 00:00:00 2001 From: dailz Date: Wed, 15 Apr 2026 15:01:06 +0800 Subject: [PATCH] fix(avhw): specify format=nv12 output for scale_vaapi filter scale_vaapi defaults to the input sw_format (RGBZ) when no output format is specified. h264_vaapi encoder only supports NV12/YUV formats. Adding format=nv12 ensures the filter outputs the correct color format for hardware encoding. --- src/avhw.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/avhw.rs b/src/avhw.rs index a048575..31dd9db 100644 --- a/src/avhw.rs +++ b/src/avhw.rs @@ -518,7 +518,11 @@ fn build_filter_graph( } // scale_vaapi: hardware scaling and colourspace conversion (keeps original dimensions) - let mut scale_ctx = graph.add(&scale_vaapi, "scale", &format!("{width}:{height}"))?; + let mut scale_ctx = graph.add( + &scale_vaapi, + "scale", + &format!("{width}:{height}:format=nv12"), + )?; // SAFETY: scale_vaapi needs hw_device_ctx for VAAPI device access. unsafe { (*scale_ctx.as_mut_ptr()).hw_device_ctx = hw_dev.ref_clone();