Skip to content

Commit 4fc00ce

Browse files
committed
Skip nil frames in decoder
1 parent 4254090 commit 4fc00ce

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

pkg/ffmpeg/decoder.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,17 @@ func (d *Decoder) decode(packet *ff.AVPacket, fn DecoderFrameFn) error {
155155
dest = (*Frame)(d.frame)
156156
}
157157

158+
// If we have a nil frame here, then don't pass back to the caller
159+
if dest == nil {
160+
ff.AVUtil_frame_unref(d.frame)
161+
continue
162+
}
163+
158164
// Copy across the timebase and pts
159-
// TODO if dest != nil {
165+
// TODO
160166
// fmt.Println("pts=", d.frame.Pts())
161-
// (*ff.AVFrame)(dest).SetPts(d.frame.Pts())
162-
// (*ff.AVFrame)(dest).SetTimeBase(d.timeBase)
163-
//}
167+
// (*ff.AVFrame)(dest).SetPts(d.frame.Pts())
168+
// (*ff.AVFrame)(dest).SetTimeBase(d.timeBase)
164169

165170
// Pass back to the caller
166171
if err := fn(d.stream, dest); errors.Is(err, io.EOF) {

0 commit comments

Comments
 (0)