aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2023-07-13 13:34:32 +0200
committerAnton Khirnov <anton@khirnov.net>2023-07-20 20:30:13 +0200
commit80a64800eab896b1103094a519a35a9585f25f4b (patch)
treec8cc85dec62be93a5288465c82c34be65871823a
parentc4b074676a9fff3f072ae4c7e795cf71e010849d (diff)
downloadffmpeg-80a64800eab896b1103094a519a35a9585f25f4b.tar.gz
fftools/ffmpeg_enc: return errors from enc_frame() instead of aborting
-rw-r--r--fftools/ffmpeg.h2
-rw-r--r--fftools/ffmpeg_enc.c6
-rw-r--r--fftools/ffmpeg_filter.c12
3 files changed, 14 insertions, 6 deletions
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 1b799832ad..89c87cf1c4 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -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);
/*
diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c
index 8b750de4e5..5952fc42b7 100644
--- a/fftools/ffmpeg_enc.c
+++ b/fftools/ffmpeg_enc.c
@@ -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)
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 49e0800e6e..d373d8c002 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -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;
}
}