[FFmpeg-devel] [PATCH] ffmpeg; check return code of avcodec_send_frame when flushing encoders
Michael Niedermayer
michael at niedermayer.cc
Tue Apr 18 03:31:23 EEST 2017
On Sat, Apr 15, 2017 at 08:33:07PM +0200, Marton Balint wrote:
> Fixes Coverity CID 1404841.
>
> Signed-off-by: Marton Balint <cus at passwd.hu>
> ---
> ffmpeg.c | 14 +++++++++++---
> 1 file changed, 11 insertions(+), 3 deletions(-)
>
> diff --git a/ffmpeg.c b/ffmpeg.c
> index e4b94b2..dd179b0 100644
> --- a/ffmpeg.c
> +++ b/ffmpeg.c
> @@ -1904,8 +1904,6 @@ static void flush_encoders(void)
> if (enc->codec_type != AVMEDIA_TYPE_VIDEO && enc->codec_type != AVMEDIA_TYPE_AUDIO)
> continue;
>
> - avcodec_send_frame(enc, NULL);
> -
> for (;;) {
> const char *desc = NULL;
> AVPacket pkt;
> @@ -1927,7 +1925,17 @@ static void flush_encoders(void)
> pkt.size = 0;
>
> update_benchmark(NULL);
> - ret = avcodec_receive_packet(enc, &pkt);
> +
> + while ((ret = avcodec_receive_packet(enc, &pkt)) == AVERROR(EAGAIN)) {
> + ret = avcodec_send_frame(enc, NULL);
> + if (ret < 0) {
> + av_log(NULL, AV_LOG_FATAL, "%s encoding failed: %s\n",
> + desc,
> + av_err2str(ret));
> + exit_program(1);
> + }
> + }
can the code be changed to not require this ?
If so this should make its use easier
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Awnsering whenever a program halts or runs forever is
On a turing machine, in general impossible (turings halting problem).
On any real computer, always possible as a real computer has a finite number
of states N, and will either halt in less than N cycles or never halt.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20170418/06b50dc7/attachment.sig>
More information about the ffmpeg-devel
mailing list