mirror of
https://github.com/asticode/go-astiav.git
synced 2025-10-26 17:40:26 +08:00
Fixed hardware filtering example
This commit is contained in:
@@ -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())
|
||||
|
||||
5
frame.go
5
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)
|
||||
|
||||
Reference in New Issue
Block a user