Different behaviors when using libavcodec for real-time mpeg2 encoding/decoding between ffmpeg-3.3.3 and ffmpeg-3.4.1

For the developers that use FFmpeg in their software.
Post Reply
jackly8831040
Posts: 2
Joined: Mon Apr 23, 2018 9:05 am

Different behaviors when using libavcodec for real-time mpeg2 encoding/decoding between ffmpeg-3.3.3 and ffmpeg-3.4.1

Post by jackly8831040 » Mon Apr 23, 2018 9:31 am

Good day!
when I used ffmpeg for real-time mpeg2 encoding/decoding, I got different results between version 3.3.3 and 3.4.1
(1) When using ffmpeg-3.3.3, the old API avcodec_decode_video2() can provide the output frame immediatly(one-stream-in-one-frame-out);
(2) When using ffmpeg-3.4.1, I can not get the output frame immediatly. It seems that there is a buffer. When I send the first packet, there is no output;
(3) When using new API of ffmpeg-3.4.1, after calling avcodec_send_packet, the first time return value of avcodec_receive_frame is AVERROR (EAGAIN);
So my question is : is there any way I can get the output frame in time, even the first packet?

best wishes!

jackly8831040
Posts: 2
Joined: Mon Apr 23, 2018 9:05 am

Re: Different behaviors when using libavcodec for real-time mpeg2 encoding/decoding between ffmpeg-3.3.3 and ffmpeg-3.4.

Post by jackly8831040 » Tue Apr 24, 2018 3:00 am

It seems that I found the cause.
When setting AVCodecContext flag with CODEC_FLAG_TRUNCATED, the problem exisets;
"ptx->flag |= CODEC_FLAG_TRUNCATED"
When the code is disable, the problem is gone.

Post Reply