[FFmpeg-cvslog] opusenc: fix infinite loop if flushing encoder upon init

Rostislav Pehlivanov git at videolan.org
Wed Dec 12 22:09:58 EET 2018

ffmpeg | branch: master | Rostislav Pehlivanov <atomnuker at gmail.com> | Wed Dec 12 20:05:33 2018 +0000| [83db1efd42bd4d89a5a78bb3001481e009d99304] | committer: Rostislav Pehlivanov

opusenc: fix infinite loop if flushing encoder upon init

The issue is that the afq still has samples as on init it counts
the overlap used as a delay to adjust the PTS it generates, hence
we can't rely on it right after init.
So just check to see if any frames have been encoded. frame_number
can't be anything but 0 right after init and can only be set by lavc.

Signed-off-by: Rostislav Pehlivanov <atomnuker at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=83db1efd42bd4d89a5a78bb3001481e009d99304

 libavcodec/opusenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/opusenc.c b/libavcodec/opusenc.c
index 578785f4b4..3c08ebcf69 100644
--- a/libavcodec/opusenc.c
+++ b/libavcodec/opusenc.c
@@ -543,7 +543,7 @@ static int opus_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
         ff_bufqueue_add(avctx, &s->bufqueue, av_frame_clone(frame));
     } else {
-        if (!s->afq.remaining_samples)
+        if (!s->afq.remaining_samples || !avctx->frame_number)
             return 0; /* We've been flushed and there's nothing left to encode */

More information about the ffmpeg-cvslog mailing list