diff --git a/codec/h264/h264dec/nalunit.go b/codec/h264/h264dec/nalunit.go index 9f4ecab3..4f5725cc 100644 --- a/codec/h264/h264dec/nalunit.go +++ b/codec/h264/h264dec/nalunit.go @@ -262,6 +262,11 @@ func NewNALUnit(br *bits.BitReader) (*NALUnit, error) { for moreRBSPData(br) { next3Bytes, err := br.PeekBits(24) + + // If PeekBits cannot get 3 bytes, but there still might be 2 bytes left in + // the source, we will get an io.EOF; we wish to ignore this and continue. + // The call to moreRBSPData will determine when we have reached the end of + // the NAL unit. if err != nil && errors.Cause(err) != io.EOF { return nil, errors.Wrap(err, "could not Peek next 3 bytes") }