Skip to content

Commit

Permalink
Fixed hardware filtering example
Browse files Browse the repository at this point in the history
  • Loading branch information
asticode committed Dec 20, 2024
1 parent 805ca1b commit 04ab708
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions examples/hardware_decoding_filtering/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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())
Expand Down
5 changes: 5 additions & 0 deletions frame.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 04ab708

Please sign in to comment.