--- fftools/ffmpeg_enc.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-)
diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c index f84641b1c4..72ba56a03d 100644 --- a/fftools/ffmpeg_enc.c +++ b/fftools/ffmpeg_enc.c @@ -839,8 +839,8 @@ static int submit_encode_frame(OutputFile *of, OutputStream *ost, } } -static void do_audio_out(OutputFile *of, OutputStream *ost, - AVFrame *frame) +static int do_audio_out(OutputFile *of, OutputStream *ost, + AVFrame *frame) { Encoder *e = ost->enc; AVCodecContext *enc = ost->enc_ctx; @@ -850,7 +850,7 @@ static void do_audio_out(OutputFile *of, OutputStream *ost, enc->ch_layout.nb_channels != frame->ch_layout.nb_channels) { av_log(ost, AV_LOG_ERROR, "Audio channel count changed and encoder does not support parameter changes\n"); - return; + return 0; } if (frame->pts == AV_NOPTS_VALUE) @@ -866,13 +866,12 @@ static void do_audio_out(OutputFile *of, OutputStream *ost, enc->time_base); if (!check_recording_time(ost, frame->pts, frame->time_base)) - return; + return 0; e->next_pts = frame->pts + frame->nb_samples; ret = submit_encode_frame(of, ost, frame); - if (ret < 0 && ret != AVERROR_EOF) - exit_program(1); + return (ret < 0 && ret != AVERROR_EOF) ? ret : 0; } static double adjust_frame_pts_to_encoder_tb(OutputFile *of, OutputStream *ost, @@ -1059,7 +1058,7 @@ force_keyframe: } /* May modify/reset frame */ -static void do_video_out(OutputFile *of, OutputStream *ost, AVFrame *frame) +static int do_video_out(OutputFile *of, OutputStream *ost, AVFrame *frame) { int ret; Encoder *e = ost->enc; @@ -1090,7 +1089,7 @@ static void do_video_out(OutputFile *of, OutputStream *ost, AVFrame *frame) if (nb_frames > dts_error_threshold * 30) { av_log(ost, AV_LOG_ERROR, "%"PRId64" frame duplication too large, skipping\n", nb_frames - 1); ost->nb_frames_drop++; - return; + return 0; } ost->nb_frames_dup += nb_frames - (nb_frames_prev && ost->last_dropped) - (nb_frames > nb_frames_prev); av_log(ost, AV_LOG_VERBOSE, "*** %"PRId64" dup!\n", nb_frames - 1); @@ -1112,12 +1111,12 @@ static void do_video_out(OutputFile *of, OutputStream *ost, AVFrame *frame) in_picture = frame; if (!in_picture) - return; + return 0; in_picture->pts = e->next_pts; if (!check_recording_time(ost, in_picture->pts, ost->enc_ctx->time_base)) - return; + return 0; in_picture->quality = enc->global_quality; in_picture->pict_type = forced_kf_apply(ost, &ost->kf, enc->time_base, in_picture, i); @@ -1126,7 +1125,7 @@ static void do_video_out(OutputFile *of, OutputStream *ost, AVFrame *frame) if (ret == AVERROR_EOF) break; else if (ret < 0) - exit_program(1); + return ret; e->next_pts++; e->vsync_frame_number++; @@ -1135,6 +1134,8 @@ static void do_video_out(OutputFile *of, OutputStream *ost, AVFrame *frame) av_frame_unref(e->last_frame); if (frame) av_frame_move_ref(e->last_frame, frame); + + return 0; } int enc_frame(OutputStream *ost, AVFrame *frame) @@ -1146,10 +1147,8 @@ int enc_frame(OutputStream *ost, AVFrame *frame) if (ret < 0) 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; + return ost->enc_ctx->codec_type == AVMEDIA_TYPE_VIDEO ? + do_video_out(of, ost, frame) : do_audio_out(of, ost, frame); } void enc_flush(void) -- 2.40.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".