From bcd4090d5152ee87e5c1b000f178ea36f79c7aff Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Sat, 2 Mar 2019 16:02:01 +0100 Subject: [PATCH] Fix recording with old decoding/encoding API The deprecated avcodec_decode_video2() should always the whole packet, so there is no need to loop (cf doc/examples/demuxing_decoding.c in FFmpeg). This hack changed the packet size and data pointer. This broke recording which used the same packet. --- app/src/decoder.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/app/src/decoder.c b/app/src/decoder.c index a4a5beca..c2008834 100644 --- a/app/src/decoder.c +++ b/app/src/decoder.c @@ -237,19 +237,15 @@ static int run_decoder(void *data) { goto run_quit; } #else - while (packet.size > 0) { - int got_picture; - int len = avcodec_decode_video2(codec_ctx, decoder->video_buffer->decoding_frame, &got_picture, &packet); - if (len < 0) { - LOGE("Could not decode video packet: %d", len); - av_packet_unref(&packet); - goto run_quit; - } - if (got_picture) { - push_frame(decoder); - } - packet.size -= len; - packet.data += len; + int got_picture; + int len = avcodec_decode_video2(codec_ctx, decoder->video_buffer->decoding_frame, &got_picture, &packet); + if (len < 0) { + LOGE("Could not decode video packet: %d", len); + av_packet_unref(&packet); + goto run_quit; + } + if (got_picture) { + push_frame(decoder); } #endif