aboutsummaryrefslogtreecommitdiffstats
path: root/fftools/ffmpeg_enc.c
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
commitaa1173feee791c35f1306df2bbd69917cb59aae8 (patch)
tree2e4de2c4cd37e4ed3ee892548d7fdd0da86ba67c /fftools/ffmpeg_enc.c
parent80a64800eab896b1103094a519a35a9585f25f4b (diff)
downloadffmpeg-aa1173feee791c35f1306df2bbd69917cb59aae8.tar.gz
fftools/ffmpeg_enc: return errors from enc_open() instead of aborting
Diffstat (limited to 'fftools/ffmpeg_enc.c')
-rw-r--r--fftools/ffmpeg_enc.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c
index 5952fc42b7..ec1b7fa3ae 100644
--- a/fftools/ffmpeg_enc.c
+++ b/fftools/ffmpeg_enc.c
@@ -165,19 +165,19 @@ static int hw_device_setup_for_encode(OutputStream *ost, AVBufferRef *frames_ref
return 0;
}
-static void set_encoder_id(OutputFile *of, OutputStream *ost)
+static int set_encoder_id(OutputFile *of, OutputStream *ost)
{
const char *cname = ost->enc_ctx->codec->name;
uint8_t *encoder_string;
int encoder_string_len;
if (av_dict_get(ost->st->metadata, "encoder", NULL, 0))
- return;
+ return 0;
encoder_string_len = sizeof(LIBAVCODEC_IDENT) + strlen(cname) + 2;
encoder_string = av_mallocz(encoder_string_len);
if (!encoder_string)
- report_and_exit(AVERROR(ENOMEM));
+ return AVERROR(ENOMEM);
if (!of->bitexact && !ost->bitexact)
av_strlcpy(encoder_string, LIBAVCODEC_IDENT " ", encoder_string_len);
@@ -186,6 +186,8 @@ static void set_encoder_id(OutputFile *of, OutputStream *ost)
av_strlcat(encoder_string, cname, encoder_string_len);
av_dict_set(&ost->st->metadata, "encoder", encoder_string,
AV_DICT_DONT_STRDUP_VAL | AV_DICT_DONT_OVERWRITE);
+
+ return 0;
}
int enc_open(OutputStream *ost, AVFrame *frame)
@@ -211,7 +213,9 @@ int enc_open(OutputStream *ost, AVFrame *frame)
return AVERROR(ENOMEM);
}
- set_encoder_id(output_files[ost->file_index], ost);
+ ret = set_encoder_id(output_files[ost->file_index], ost);
+ if (ret < 0)
+ return ret;
if (ist) {
dec_ctx = ist->dec_ctx;
@@ -413,7 +417,7 @@ int enc_open(OutputStream *ost, AVFrame *frame)
if (ret < 0) {
av_log(ost, AV_LOG_FATAL,
"Error initializing the output stream codec context.\n");
- exit_program(1);
+ return ret;
}
if (ost->enc_ctx->nb_coded_side_data) {