From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id F106145E6E for ; Thu, 13 Apr 2023 14:17:22 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 163EF68BE88; Thu, 13 Apr 2023 17:16:07 +0300 (EEST) Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 82C9E68BDCA for ; Thu, 13 Apr 2023 17:16:01 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id EB6132404F8 for ; Thu, 13 Apr 2023 16:16:00 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id Q9lh9K24Ss4P for ; Thu, 13 Apr 2023 16:16:00 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 853492406D0 for ; Thu, 13 Apr 2023 16:15:53 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 755923A038E for ; Thu, 13 Apr 2023 16:15:53 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 13 Apr 2023 16:12:13 +0200 Message-Id: <20230413141223.17245-15-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230413141223.17245-1-anton@khirnov.net> References: <20230413141223.17245-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 15/25] fftools/ffmpeg: initialize no-filter streams earlier X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: There is no reason to postpone it until transcode_init() anymore, it can be done right at the end of of_open(). --- fftools/ffmpeg.c | 34 ---------------------------------- fftools/ffmpeg_mux_init.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 34 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 900d6e5e83..33b2f72d90 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -1853,23 +1853,6 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eo 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) { int ret = 0; @@ -1882,22 +1865,6 @@ static int transcode_init(void) 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 */ for (int i = 0; i < nb_input_files; i++) { InputFile *ifile = input_files[i]; @@ -1914,7 +1881,6 @@ static int transcode_init(void) } } - dump_format: /* dump the stream mapping */ av_log(NULL, AV_LOG_INFO, "Stream mapping:\n"); for (InputStream *ist = ist_iter(NULL); ist; ist = ist_iter(ist)) { diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index e3d8f5e386..bc14cabad4 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -2314,6 +2314,23 @@ static void validate_enc_avopt(Muxer *mux, const AVDictionary *codec_avopt) 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) { const Muxer *mux = obj; @@ -2509,6 +2526,21 @@ int of_open(const OptionsContext *o, const char *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 */ if (of->format->flags & AVFMT_NOSTREAMS && oc->nb_streams == 0) { int ret = mux_check_init(mux); -- 2.39.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".