Skip to content

Commit

Permalink
bufferSrcCtx initialize with dictionary
Browse files Browse the repository at this point in the history
  • Loading branch information
oldma3095 committed Dec 23, 2024
1 parent b46e692 commit 2b1c488
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 6 deletions.
8 changes: 6 additions & 2 deletions buffersrc_filter_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions buffersrc_filter_context_test.go
Original file line number Diff line number Diff line change
@@ -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))
}
2 changes: 1 addition & 1 deletion examples/filtering/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion examples/hardware_decoding_filtering/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion examples/transcoding/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion filter_graph_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 2b1c488

Please sign in to comment.