mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-24 13:56:33 +02:00
avconv_opt: allocate an OutputFile before the streams.
This way OutputFile variables like recording time can be used when creating the streams.
This commit is contained in:
parent
a1e05b0487
commit
3d62442008
35
avconv_opt.c
35
avconv_opt.c
@ -820,7 +820,7 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e
|
|||||||
exit(1);
|
exit(1);
|
||||||
output_streams[nb_output_streams - 1] = ost;
|
output_streams[nb_output_streams - 1] = ost;
|
||||||
|
|
||||||
ost->file_index = nb_output_files;
|
ost->file_index = nb_output_files - 1;
|
||||||
ost->index = idx;
|
ost->index = idx;
|
||||||
ost->st = st;
|
ost->st = st;
|
||||||
st->codec->codec_type = type;
|
st->codec->codec_type = type;
|
||||||
@ -1294,6 +1294,19 @@ static int open_output_file(OptionsContext *o, const char *filename)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GROW_ARRAY(output_files, nb_output_files);
|
||||||
|
of = av_mallocz(sizeof(*of));
|
||||||
|
if (!of)
|
||||||
|
exit(1);
|
||||||
|
output_files[nb_output_files - 1] = of;
|
||||||
|
|
||||||
|
of->ost_index = nb_output_streams;
|
||||||
|
of->recording_time = o->recording_time;
|
||||||
|
of->start_time = o->start_time;
|
||||||
|
of->limit_filesize = o->limit_filesize;
|
||||||
|
of->shortest = o->shortest;
|
||||||
|
av_dict_copy(&of->opts, o->g->format_opts, 0);
|
||||||
|
|
||||||
if (!strcmp(filename, "-"))
|
if (!strcmp(filename, "-"))
|
||||||
filename = "pipe:";
|
filename = "pipe:";
|
||||||
|
|
||||||
@ -1302,6 +1315,9 @@ static int open_output_file(OptionsContext *o, const char *filename)
|
|||||||
print_error(filename, AVERROR(ENOMEM));
|
print_error(filename, AVERROR(ENOMEM));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
of->ctx = oc;
|
||||||
|
if (o->recording_time != INT64_MAX)
|
||||||
|
oc->duration = o->recording_time;
|
||||||
|
|
||||||
if (o->format) {
|
if (o->format) {
|
||||||
file_oformat = av_guess_format(o->format, NULL, NULL);
|
file_oformat = av_guess_format(o->format, NULL, NULL);
|
||||||
@ -1477,23 +1493,6 @@ loop_end:
|
|||||||
avio_close(pb);
|
avio_close(pb);
|
||||||
}
|
}
|
||||||
|
|
||||||
GROW_ARRAY(output_files, nb_output_files);
|
|
||||||
of = av_mallocz(sizeof(*of));
|
|
||||||
if (!of)
|
|
||||||
exit(1);
|
|
||||||
output_files[nb_output_files - 1] = of;
|
|
||||||
|
|
||||||
of->ctx = oc;
|
|
||||||
of->ost_index = nb_output_streams - oc->nb_streams;
|
|
||||||
of->recording_time = o->recording_time;
|
|
||||||
if (o->recording_time != INT64_MAX)
|
|
||||||
oc->duration = o->recording_time;
|
|
||||||
of->start_time = o->start_time;
|
|
||||||
of->limit_filesize = o->limit_filesize;
|
|
||||||
of->shortest = o->shortest;
|
|
||||||
av_dict_copy(&of->opts, o->g->format_opts, 0);
|
|
||||||
|
|
||||||
|
|
||||||
/* check if all codec options have been used */
|
/* check if all codec options have been used */
|
||||||
unused_opts = strip_specifiers(o->g->codec_opts);
|
unused_opts = strip_specifiers(o->g->codec_opts);
|
||||||
for (i = of->ost_index; i < nb_output_streams; i++) {
|
for (i = of->ost_index; i < nb_output_streams; i++) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user