diff options
author | Anton Khirnov <anton@khirnov.net> | 2021-11-10 15:21:47 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2022-04-13 12:07:54 +0200 |
commit | 5bc644ea8a6a0f8d02df36a12c1ce09bda696a77 (patch) | |
tree | d6e646fabe89c6d88ff0bb95c7dcf99d726163d2 | |
parent | 288aa37387e93deefa66ff01f1ffae1d6a8988e3 (diff) | |
download | ffmpeg-5bc644ea8a6a0f8d02df36a12c1ce09bda696a77.tar.gz |
fftools/ffmpeg: move writing the trailer to ffmpeg_mux.c
-rw-r--r-- | fftools/ffmpeg.c | 16 | ||||
-rw-r--r-- | fftools/ffmpeg.h | 1 | ||||
-rw-r--r-- | fftools/ffmpeg_mux.c | 21 |
3 files changed, 25 insertions, 13 deletions
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 47724f7231..cc7855a4cc 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -4450,19 +4450,9 @@ static int transcode(void) /* write the trailer if needed */ for (i = 0; i < nb_output_files; i++) { - os = output_files[i]->ctx; - if (!output_files[i]->header_written) { - av_log(NULL, AV_LOG_ERROR, - "Nothing was written into output file %d (%s), because " - "at least one of its streams received no packets.\n", - i, os->url); - continue; - } - if ((ret = av_write_trailer(os)) < 0) { - av_log(NULL, AV_LOG_ERROR, "Error writing trailer of %s: %s\n", os->url, av_err2str(ret)); - if (exit_on_error) - exit_program(1); - } + ret = of_write_trailer(output_files[i]); + if (ret < 0 && exit_on_error) + exit_program(1); } /* dump report by using the first video and audio streams */ diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index cb475bb690..4425b7a874 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -689,6 +689,7 @@ int hwaccel_decode_init(AVCodecContext *avctx); /* open the muxer when all the streams are initialized */ int of_check_init(OutputFile *of); +int of_write_trailer(OutputFile *of); void of_write_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost, int unqueue); diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c index 92d8a8c088..5348eef01d 100644 --- a/fftools/ffmpeg_mux.c +++ b/fftools/ffmpeg_mux.c @@ -290,3 +290,24 @@ int of_check_init(OutputFile *of) return 0; } + +int of_write_trailer(OutputFile *of) +{ + int ret; + + if (!of->header_written) { + av_log(NULL, AV_LOG_ERROR, + "Nothing was written into output file %d (%s), because " + "at least one of its streams received no packets.\n", + of->index, of->ctx->url); + return AVERROR(EINVAL); + } + + ret = av_write_trailer(of->ctx); + if (ret < 0) { + av_log(NULL, AV_LOG_ERROR, "Error writing trailer of %s: %s\n", of->ctx->url, av_err2str(ret)); + return ret; + } + + return 0; +} |