From 2fdc368c419a2cd462eb0562cebb3f1bc05fa022 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Fri, 9 Feb 2018 09:56:02 +0100 Subject: [PATCH] Do not try to decode video when EOF is reached When the video stream socket is closed and read_packey() returns -1, av_read_frame() still returns 0. To detect EOF, check the flag eof_reached in the AVIOContext. This avoids garbage errors on closing. --- app/src/decoder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/decoder.c b/app/src/decoder.c index 480b3617..2aeab773 100644 --- a/app/src/decoder.c +++ b/app/src/decoder.c @@ -92,7 +92,7 @@ static int run_decoder(void *data) { packet.data = NULL; packet.size = 0; - while (!av_read_frame(format_ctx, &packet)) { + while (!av_read_frame(format_ctx, &packet) && !avio_ctx->eof_reached) { // the new decoding/encoding API has been introduced by: // #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(57, 37, 0)