1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

fftools/ffmpeg_enc: return errors from enc_frame() instead of aborting

This commit is contained in:
Anton Khirnov 2023-07-13 13:34:32 +02:00
parent c4b074676a
commit 80a64800ea
3 changed files with 14 additions and 6 deletions

View File

@ -814,7 +814,7 @@ void enc_free(Encoder **penc);
int enc_open(OutputStream *ost, AVFrame *frame);
int enc_subtitle(OutputFile *of, OutputStream *ost, const AVSubtitle *sub);
void enc_frame(OutputStream *ost, AVFrame *frame);
int enc_frame(OutputStream *ost, AVFrame *frame);
void enc_flush(void);
/*

View File

@ -1129,17 +1129,19 @@ static void do_video_out(OutputFile *of, OutputStream *ost, AVFrame *frame)
av_frame_move_ref(e->last_frame, frame);
}
void enc_frame(OutputStream *ost, AVFrame *frame)
int enc_frame(OutputStream *ost, AVFrame *frame)
{
OutputFile *of = output_files[ost->file_index];
int ret;
ret = enc_open(ost, frame);
if (ret < 0)
exit_program(1);
return ret;
if (ost->enc_ctx->codec_type == AVMEDIA_TYPE_VIDEO) do_video_out(of, ost, frame);
else do_audio_out(of, ost, frame);
return 0;
}
void enc_flush(void)

View File

@ -1722,8 +1722,11 @@ int reap_filters(FilterGraph *fg, int flush)
av_log(fgp, AV_LOG_WARNING,
"Error in av_buffersink_get_frame_flags(): %s\n", av_err2str(ret));
} else if (flush && ret == AVERROR_EOF && ofp->got_frame &&
av_buffersink_get_type(filter) == AVMEDIA_TYPE_VIDEO)
enc_frame(ost, NULL);
av_buffersink_get_type(filter) == AVMEDIA_TYPE_VIDEO) {
ret = enc_frame(ost, NULL);
if (ret < 0)
return ret;
}
break;
}
@ -1759,8 +1762,11 @@ int reap_filters(FilterGraph *fg, int flush)
if (ost->type == AVMEDIA_TYPE_VIDEO)
fd->frame_rate_filter = av_buffersink_get_frame_rate(filter);
enc_frame(ost, filtered_frame);
ret = enc_frame(ost, filtered_frame);
av_frame_unref(filtered_frame);
if (ret < 0)
return ret;
ofp->got_frame = 1;
}
}