From c5ca672865f469249ae8cd22ff47dc11880453f5 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sun, 19 Oct 2025 16:16:06 -0500 Subject: [PATCH] Don't set pix_fmt for hwaccel decoders This works around a bug in the AV1 Vulkan decoding code in FFmpeg that causes it to incorrectly skip hwaccel init. Fixes #1511 --- app/streaming/video/ffmpeg.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/streaming/video/ffmpeg.cpp b/app/streaming/video/ffmpeg.cpp index 13b6dcf0..cb4db924 100644 --- a/app/streaming/video/ffmpeg.cpp +++ b/app/streaming/video/ffmpeg.cpp @@ -519,9 +519,19 @@ bool FFmpegVideoDecoder::completeInitialization(const AVCodec* decoder, enum AVP // Setup decoding parameters m_VideoDecoderCtx->width = params->width; m_VideoDecoderCtx->height = params->height; - m_VideoDecoderCtx->pix_fmt = requiredFormat != AV_PIX_FMT_NONE ? requiredFormat : m_FrontendRenderer->getPreferredPixelFormat(params->videoFormat); m_VideoDecoderCtx->get_format = ffGetFormat; + // For non-hwaccel decoders, set the pix_fmt to hint to the decoder which + // format should be used. This is necessary for certain decoders like the + // out-of-tree nvv4l2dec decoders for L4T platforms. We do not do this + // for hwaccel decoders because it causes the AV1 Vulkan video decoder in + // FFmpeg 7.0-8.0 to incorrectly believe ff_get_format() was called. + // See #1511. + if (m_HwDecodeCfg == nullptr) { + m_VideoDecoderCtx->pix_fmt = (requiredFormat != AV_PIX_FMT_NONE) ? + requiredFormat : m_FrontendRenderer->getPreferredPixelFormat(params->videoFormat); + } + AVDictionary* options = nullptr; // Allow the backend renderer to attach data to this decoder