From d16a7b98ebc00257f965f3c2e61ac6e964140a6b Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 28 Jan 2021 10:04:02 -0500 Subject: [PATCH] fix send_packet_receive_frame. Can't just resend the same packet until we get a frame! --- src/zm_ffmpeg.cpp | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/zm_ffmpeg.cpp b/src/zm_ffmpeg.cpp index e8cb7f0d4..22f346371 100644 --- a/src/zm_ffmpeg.cpp +++ b/src/zm_ffmpeg.cpp @@ -591,20 +591,18 @@ int zm_send_packet_receive_frame( return packet.size; # else int frameComplete = 0; - while ( !frameComplete ) { - if ( is_video_context(context) ) { - ret = zm_avcodec_decode_video(context, frame, &frameComplete, &packet); - Debug(2, "ret from decode_video %d, framecomplete %d", ret, frameComplete); - } else { - ret = avcodec_decode_audio4(context, frame, &frameComplete, &packet); - Debug(2, "ret from decode_audio %d, framecomplete %d", ret, frameComplete); - } - if ( ret < 0 ) { - Error("Unable to decode frame: %s", av_make_error_string(ret).c_str()); - return ret; - } - } // end while !frameComplete - return ret; + if ( is_video_context(context) ) { + ret = zm_avcodec_decode_video(context, frame, &frameComplete, &packet); + Debug(2, "ret from decode_video %d, framecomplete %d", ret, frameComplete); + } else { + ret = avcodec_decode_audio4(context, frame, &frameComplete, &packet); + Debug(2, "ret from decode_audio %d, framecomplete %d", ret, frameComplete); + } + if ( ret < 0 ) { + Error("Unable to decode frame: %s", av_make_error_string(ret).c_str()); + return ret; + } + return frameComplete ? ret : 0; #endif } // end int zm_send_packet_receive_frame(AVCodecContext *context, AVFrame *frame, AVPacket &packet)