Skip to content

Commit

Permalink
Fix crash on PNG options
Browse files Browse the repository at this point in the history
  • Loading branch information
j0sh committed Dec 3, 2024
1 parent b33cac6 commit fc96cad
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ffmpeg/ffmpeg.go
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,9 @@ func (t *Transcoder) Transcode(input *TranscodeOptionsIn, ps []TranscodeOptions)
}

// changing the input map here is maybe not great
if input.Demuxer.Opts == nil {
input.Demuxer.Opts = map[string]string{}
}
input.Demuxer.Opts["framerate"] = fmt.Sprintf("%d/%d", input.Profile.Framerate, input.Profile.FramerateDen)
}
}
Expand Down
24 changes: 24 additions & 0 deletions ffmpeg/ffmpeg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2439,3 +2439,27 @@ func TestTranscoder_DemuxerOptsError(t *testing.T) {
assert.Equal(t, "Invalid data found when processing input", err.Error())

}

func TestTranscoder_PNGDemuxerOpts(t *testing.T) {
// we implicitly add demuxer opts to png input that has a framerate
// so test those
run, dir := setupTest(t)
defer os.RemoveAll(dir)
cmd := `
ffmpeg -i $1/../transcoder/test.ts -an -frames:v 3 test-%d.png
`
run(cmd)
res, err := Transcode3(&TranscodeOptionsIn{
Fname: dir + "/test-%d.png",
Profile: VideoProfile{
Framerate: 1,
FramerateDen: 3,
},
}, []TranscodeOptions{{
Profile: P144p30fps16x9,
Oname: "out.ts",
}})
assert.Nil(t, err)
assert.Equal(t, 3, res.Decoded.Frames)
assert.Equal(t, 180, res.Encoded[0].Frames)
}

0 comments on commit fc96cad

Please sign in to comment.