You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-10 06:10:52 +02:00
fftools/ffmpeg: initialize no-filter streams earlier
There is no reason to postpone it until transcode_init() anymore, it can be done right at the end of of_open().
This commit is contained in:
@@ -1853,23 +1853,6 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eo
|
|||||||
return !eof_reached;
|
return !eof_reached;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int init_output_stream_nofilter(OutputStream *ost)
|
|
||||||
{
|
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
if (ost->enc_ctx) {
|
|
||||||
ret = enc_open(ost, NULL);
|
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
} else {
|
|
||||||
ret = of_stream_init(output_files[ost->file_index], ost);
|
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int transcode_init(void)
|
static int transcode_init(void)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
@@ -1882,22 +1865,6 @@ static int transcode_init(void)
|
|||||||
ifile->streams[j]->start = av_gettime_relative();
|
ifile->streams[j]->start = av_gettime_relative();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* initialize stream copy and subtitle/data streams.
|
|
||||||
* Encoded AVFrame based streams will get initialized when the first AVFrame
|
|
||||||
* is received in do_video_out
|
|
||||||
*/
|
|
||||||
for (OutputStream *ost = ost_iter(NULL); ost; ost = ost_iter(ost)) {
|
|
||||||
if (ost->enc_ctx &&
|
|
||||||
(ost->st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO ||
|
|
||||||
ost->st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
ret = init_output_stream_nofilter(ost);
|
|
||||||
if (ret < 0)
|
|
||||||
goto dump_format;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* discard unused programs */
|
/* discard unused programs */
|
||||||
for (int i = 0; i < nb_input_files; i++) {
|
for (int i = 0; i < nb_input_files; i++) {
|
||||||
InputFile *ifile = input_files[i];
|
InputFile *ifile = input_files[i];
|
||||||
@@ -1914,7 +1881,6 @@ static int transcode_init(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dump_format:
|
|
||||||
/* dump the stream mapping */
|
/* dump the stream mapping */
|
||||||
av_log(NULL, AV_LOG_INFO, "Stream mapping:\n");
|
av_log(NULL, AV_LOG_INFO, "Stream mapping:\n");
|
||||||
for (InputStream *ist = ist_iter(NULL); ist; ist = ist_iter(ist)) {
|
for (InputStream *ist = ist_iter(NULL); ist; ist = ist_iter(ist)) {
|
||||||
|
@@ -2317,6 +2317,23 @@ static void validate_enc_avopt(Muxer *mux, const AVDictionary *codec_avopt)
|
|||||||
av_dict_free(&unused_opts);
|
av_dict_free(&unused_opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int init_output_stream_nofilter(OutputStream *ost)
|
||||||
|
{
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
|
if (ost->enc_ctx) {
|
||||||
|
ret = enc_open(ost, NULL);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
} else {
|
||||||
|
ret = of_stream_init(output_files[ost->file_index], ost);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static const char *output_file_item_name(void *obj)
|
static const char *output_file_item_name(void *obj)
|
||||||
{
|
{
|
||||||
const Muxer *mux = obj;
|
const Muxer *mux = obj;
|
||||||
@@ -2512,6 +2529,21 @@ int of_open(const OptionsContext *o, const char *filename)
|
|||||||
|
|
||||||
of->url = filename;
|
of->url = filename;
|
||||||
|
|
||||||
|
/* initialize stream copy and subtitle/data streams.
|
||||||
|
* Encoded AVFrame based streams will get initialized when the first AVFrame
|
||||||
|
* is received in do_video_out
|
||||||
|
*/
|
||||||
|
for (int i = 0; i < of->nb_streams; i++) {
|
||||||
|
OutputStream *ost = of->streams[i];
|
||||||
|
|
||||||
|
if (ost->filter)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
err = init_output_stream_nofilter(ost);
|
||||||
|
if (err < 0)
|
||||||
|
report_and_exit(err);
|
||||||
|
}
|
||||||
|
|
||||||
/* write the header for files with no streams */
|
/* write the header for files with no streams */
|
||||||
if (of->format->flags & AVFMT_NOSTREAMS && oc->nb_streams == 0) {
|
if (of->format->flags & AVFMT_NOSTREAMS && oc->nb_streams == 0) {
|
||||||
int ret = mux_check_init(mux);
|
int ret = mux_check_init(mux);
|
||||||
|
Reference in New Issue
Block a user