diff --git a/examples/hardware_decoding_filtering/main.go b/examples/hardware_decoding_filtering/main.go index 65ffe02..0d3fade 100644 --- a/examples/hardware_decoding_filtering/main.go +++ b/examples/hardware_decoding_filtering/main.go @@ -228,7 +228,7 @@ func main() { // Make sure the filter is initialized // We need to wait for the first frame to be decoded before initializing the filter - // since the decoder codec context doesn't have a valid hardware frame context until then + // since we need a valid hardware frames context if filterGraph == nil { if err := initFilter(); err != nil { log.Fatal(fmt.Errorf("main: initializing filter failed: %w", err)) @@ -305,7 +305,7 @@ func initFilter() (err error) { // Create buffersrc context parameters buffersrcContextParameters := astiav.AllocBuffersrcFilterContextParameters() defer buffersrcContextParameters.Free() - buffersrcContextParameters.SetHardwareFramesContext(decCodecContext.HardwareFramesContext()) + buffersrcContextParameters.SetHardwareFramesContext(decodedHardwareFrame.HardwareFramesContext()) buffersrcContextParameters.SetHeight(decCodecContext.Height()) buffersrcContextParameters.SetPixelFormat(decCodecContext.PixelFormat()) buffersrcContextParameters.SetSampleAspectRatio(decCodecContext.SampleAspectRatio()) diff --git a/frame.go b/frame.go index f13d94e..dc3936c 100644 --- a/frame.go +++ b/frame.go @@ -87,6 +87,11 @@ func (f *Frame) Data() *FrameData { return newFrameData(newFrameDataFrame(f)) } +// https://ffmpeg.org/doxygen/7.0/structAVFrame.html#a29493fbfabaa21432c360a090426aa8e +func (f *Frame) HardwareFramesContext() *HardwareFramesContext { + return newHardwareFramesContextFromC(f.c.hw_frames_ctx) +} + // https://ffmpeg.org/doxygen/7.0/structAVFrame.html#a3f89733f429c98ba5bc64373fb0a3f13 func (f *Frame) Height() int { return int(f.c.height)