From 0c1d68c6a89c8309a80dacc38aad21997685b8d4 Mon Sep 17 00:00:00 2001 From: Nick Kugaevsky Date: Tue, 21 Jul 2026 09:20:30 +0500 Subject: [PATCH] hardware: bind vaapi filter device for FFmpeg 8 The VAAPI transcode inserts a "hwupload" filter but relied on -hwaccel to provide the device to the filter graph. Since FFmpeg 8 that no longer happens, so hwupload fails with "A hardware device reference is required to upload frames to" whenever the input isn't hardware decoded (e.g. an RTSP restream). Explicitly -init_hw_device / -filter_hw_device, matching what the hardware probe commands already do. --- internal/ffmpeg/hardware/hardware.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/internal/ffmpeg/hardware/hardware.go b/internal/ffmpeg/hardware/hardware.go index 801668905..d384c5cc2 100644 --- a/internal/ffmpeg/hardware/hardware.go +++ b/internal/ffmpeg/hardware/hardware.go @@ -58,7 +58,11 @@ func MakeHardware(args *ffmpeg.Args, engine string, defaults map[string]string) args.Codecs[i] = defaults[name+"/"+engine] if !args.HasFilters("drawtext=") { - args.Input = "-hwaccel vaapi -hwaccel_output_format vaapi -hwaccel_flags allow_profile_mismatch " + args.Input + // `-init_hw_device`/`-filter_hw_device` - bind a device to the + // filter graph, so `hwupload` works when the input isn't + // hardware decoded. Required since FFmpeg 8, which no longer + // derives the filter device from `-hwaccel` alone. + args.Input = "-init_hw_device vaapi=vaapi0 -filter_hw_device vaapi0 -hwaccel vaapi -hwaccel_output_format vaapi -hwaccel_flags allow_profile_mismatch " + args.Input if name == "h264" { fixPixelFormat(args) @@ -82,7 +86,7 @@ func MakeHardware(args *ffmpeg.Args, engine string, defaults map[string]string) args.InsertFilter("format=vaapi|nv12,hwupload") } else { // enable software pixel for drawtext, scale and transpose - args.Input = "-hwaccel vaapi -hwaccel_output_format nv12 -hwaccel_flags allow_profile_mismatch " + args.Input + args.Input = "-init_hw_device vaapi=vaapi0 -filter_hw_device vaapi0 -hwaccel vaapi -hwaccel_output_format nv12 -hwaccel_flags allow_profile_mismatch " + args.Input args.AddFilter("hwupload") }