diff --git a/buffersrc_filter_context.go b/buffersrc_filter_context.go index 131722f..86caf2e 100644 --- a/buffersrc_filter_context.go +++ b/buffersrc_filter_context.go @@ -25,8 +25,12 @@ func (bfc *BuffersrcFilterContext) FilterContext() *FilterContext { } // https://ffmpeg.org/doxygen/7.0/group__lavfi.html#ga8c15af28902395399fe455f6f8236848 -func (bfc *BuffersrcFilterContext) Initialize() error { - return newError(C.avfilter_init_dict(bfc.fc.c, nil)) +func (bfc *BuffersrcFilterContext) Initialize(d *Dictionary) error { + var dc **C.AVDictionary + if d != nil { + dc = &d.c + } + return newError(C.avfilter_init_dict(bfc.fc.c, dc)) } // https://ffmpeg.org/doxygen/7.0/group__lavfi__buffersrc.html#ga398cd2a84f8b4a588197ab9d90135048 diff --git a/buffersrc_filter_context_test.go b/buffersrc_filter_context_test.go new file mode 100644 index 0000000..b363fed --- /dev/null +++ b/buffersrc_filter_context_test.go @@ -0,0 +1,16 @@ +package astiav + +import ( + "github.com/stretchr/testify/require" + "testing" +) + +func TestBuffersrcFilterContext(t *testing.T) { + fg := AllocFilterGraph() + filter := FindFilterByName("movie") + bufferSrcCtx, err := fg.NewBuffersrcFilterContext(filter, "movie") + require.NoError(t, err) + d := NewDictionary() + require.NoError(t, d.Set("filename", "testdata/video.mp4", 0)) + require.NoError(t, bufferSrcCtx.Initialize(d)) +} diff --git a/examples/filtering/main.go b/examples/filtering/main.go index cbf57f8..3b667df 100644 --- a/examples/filtering/main.go +++ b/examples/filtering/main.go @@ -274,7 +274,7 @@ func initFilter() (err error) { } // Initialize buffersrc context - if err = s.buffersrcContext.Initialize(); err != nil { + if err = s.buffersrcContext.Initialize(nil); err != nil { err = fmt.Errorf("main: initializing buffersrc context failed: %w", err) return } diff --git a/examples/hardware_decoding_filtering/main.go b/examples/hardware_decoding_filtering/main.go index 0d3fade..2a0dc6d 100644 --- a/examples/hardware_decoding_filtering/main.go +++ b/examples/hardware_decoding_filtering/main.go @@ -319,7 +319,7 @@ func initFilter() (err error) { } // Initialize buffersrc context - if err = buffersrcContext.Initialize(); err != nil { + if err = buffersrcContext.Initialize(nil); err != nil { err = fmt.Errorf("main: initializing buffersrc context failed: %w", err) return } diff --git a/examples/transcoding/main.go b/examples/transcoding/main.go index 0576388..657201d 100644 --- a/examples/transcoding/main.go +++ b/examples/transcoding/main.go @@ -431,7 +431,7 @@ func initFilters() (err error) { } // Initialize buffersrc context - if err = s.buffersrcContext.Initialize(); err != nil { + if err = s.buffersrcContext.Initialize(nil); err != nil { err = fmt.Errorf("main: initializing buffersrc context failed: %w", err) return } diff --git a/filter_graph_test.go b/filter_graph_test.go index 8e728f8..9e5d11d 100644 --- a/filter_graph_test.go +++ b/filter_graph_test.go @@ -182,7 +182,7 @@ func TestFilterGraph(t *testing.T) { buffersrcContextParameters.SetWidth(src.width) } buffersrcContext.SetParameters(buffersrcContextParameters) - require.NoError(t, buffersrcContext.Initialize()) + require.NoError(t, buffersrcContext.Initialize(nil)) buffersrcContexts = append(buffersrcContexts, buffersrcContext) o := AllocFilterInOut()