summaryrefslogtreecommitdiff
path: root/fftools
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2021-12-11 13:22:36 +0100
committerAnton Khirnov <anton@khirnov.net>2022-04-13 12:07:54 +0200
commitb1a984cb4956e73e6b2bcc6463f4f1d9ba8b5a29 (patch)
tree356a40c07b6c9ef2884417b6bdaa7fe9dc7f2b3d /fftools
parent16aea9a38bbe1113b12f814def1d13251e76ecac (diff)
fftools/ffmpeg: store the output file index in OutputFile
Use it to simplify check_init_output_file(). Will allow further simplifications in the following commits.
Diffstat (limited to 'fftools')
-rw-r--r--fftools/ffmpeg.c10
-rw-r--r--fftools/ffmpeg.h2
-rw-r--r--fftools/ffmpeg_opt.c1
3 files changed, 8 insertions, 5 deletions
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 29b01f9d93..bc700052b6 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -2947,7 +2947,7 @@ static int compare_int64(const void *a, const void *b)
}
/* open the muxer when all the streams are initialized */
-static int check_init_output_file(OutputFile *of, int file_index)
+static int check_init_output_file(OutputFile *of)
{
int ret, i;
@@ -2962,13 +2962,13 @@ static int check_init_output_file(OutputFile *of, int file_index)
av_log(NULL, AV_LOG_ERROR,
"Could not write header for output file #%d "
"(incorrect codec parameters ?): %s\n",
- file_index, av_err2str(ret));
+ of->index, av_err2str(ret));
return ret;
}
//assert_avoptions(of->opts);
of->header_written = 1;
- av_dump_format(of->ctx, file_index, of->ctx->url, 1);
+ av_dump_format(of->ctx, of->index, of->ctx->url, 1);
nb_output_dumped++;
if (sdp_filename || want_sdp) {
@@ -3571,7 +3571,7 @@ static int init_output_stream(OutputStream *ost, AVFrame *frame,
ost->initialized = 1;
- ret = check_init_output_file(output_files[ost->file_index], ost->file_index);
+ ret = check_init_output_file(output_files[ost->file_index]);
if (ret < 0)
return ret;
@@ -3674,7 +3674,7 @@ static int transcode_init(void)
for (i = 0; i < nb_output_files; i++) {
oc = output_files[i]->ctx;
if (oc->oformat->flags & AVFMT_NOSTREAMS && oc->nb_streams == 0) {
- ret = check_init_output_file(output_files[i], i);
+ ret = check_init_output_file(output_files[i]);
if (ret < 0)
goto dump_format;
}
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 04369df139..0eee6f4da8 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -577,6 +577,8 @@ typedef struct OutputStream {
} OutputStream;
typedef struct OutputFile {
+ int index;
+
AVFormatContext *ctx;
AVDictionary *opts;
int ost_index; /* index of the first stream in output_streams */
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 8e217af4ab..daecba9e57 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -2314,6 +2314,7 @@ static int open_output_file(OptionsContext *o, const char *filename)
of = ALLOC_ARRAY_ELEM(output_files, nb_output_files);
+ of->index = nb_output_files - 1;
of->ost_index = nb_output_streams;
of->recording_time = o->recording_time;
of->start_time = o->start_time;