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 5455445F47 for ; Wed, 19 Apr 2023 19:56:39 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7996768BFB3; Wed, 19 Apr 2023 22:53:30 +0300 (EEST) Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E82D068BF20 for ; Wed, 19 Apr 2023 22:53:06 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 83E792404EC for ; Wed, 19 Apr 2023 21:53:06 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id wjBFeqOFpkQY for ; Wed, 19 Apr 2023 21:53:05 +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 75B59240D1C for ; Wed, 19 Apr 2023 21:52:56 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id E9E2C3A07C2 for ; Wed, 19 Apr 2023 21:52:55 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 19 Apr 2023 21:52:32 +0200 Message-Id: <20230419195243.2974-14-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230419195243.2974-1-anton@khirnov.net> References: <20230419195243.2974-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 14/25] fftools/ffmpeg_mux_init: drop useless new_stream_{data, unknown} 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: Their only function is checking that encoding was not specified for data/unknown-type streams, but the check is broken because enc_ctx will not be created in ost_add() unless a valid encoder can be found. Add an actually working check for all types for which encoding is not supported in choose_encoder(). --- fftools/ffmpeg_mux_init.c | 38 +++++++++++++++----------------------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index 59d9a12c1a..28254cb49b 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -113,8 +113,21 @@ static int choose_encoder(const OptionsContext *o, AVFormatContext *s, *enc = NULL; - if (type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO || type == AVMEDIA_TYPE_SUBTITLE) { - MATCH_PER_STREAM_OPT(codec_names, str, codec_name, s, ost->st); + MATCH_PER_STREAM_OPT(codec_names, str, codec_name, s, ost->st); + + if (type != AVMEDIA_TYPE_VIDEO && + type != AVMEDIA_TYPE_AUDIO && + type != AVMEDIA_TYPE_SUBTITLE) { + if (codec_name && strcmp(codec_name, "copy")) { + const char *type_str = av_get_media_type_string(type); + av_log(ost, AV_LOG_FATAL, + "Encoder '%s' specified, but only '-codec copy' supported " + "for %s streams\n", codec_name, type_str); + return AVERROR(ENOSYS); + } + return 0; + } + if (!codec_name) { ost->par_in->codec_id = av_guess_codec(s->oformat, NULL, s->url, NULL, ost->type); @@ -130,7 +143,6 @@ static int choose_encoder(const OptionsContext *o, AVFormatContext *s, *enc = find_codec_or_die(ost, codec_name, ost->type, 1); ost->par_in->codec_id = (*enc)->id; } - } return 0; } @@ -796,24 +808,6 @@ static void new_stream_audio(Muxer *mux, const OptionsContext *o, } } -static void new_stream_data(Muxer *mux, const OptionsContext *o, - OutputStream *ost) -{ - if (ost->enc_ctx) { - av_log(ost, AV_LOG_FATAL, "Data stream encoding not supported yet (only streamcopy)\n"); - exit_program(1); - } -} - -static void new_stream_unknown(Muxer *mux, const OptionsContext *o, - OutputStream *ost) -{ - if (ost->enc_ctx) { - av_log(ost, AV_LOG_FATAL, "Unknown stream encoding not supported yet (only streamcopy)\n"); - exit_program(1); - } -} - static void new_stream_attachment(Muxer *mux, const OptionsContext *o, OutputStream *ost) { @@ -1218,9 +1212,7 @@ static OutputStream *ost_add(Muxer *mux, const OptionsContext *o, case AVMEDIA_TYPE_VIDEO: new_stream_video (mux, o, ost); break; case AVMEDIA_TYPE_AUDIO: new_stream_audio (mux, o, ost); break; case AVMEDIA_TYPE_SUBTITLE: new_stream_subtitle (mux, o, ost); break; - case AVMEDIA_TYPE_DATA: new_stream_data (mux, o, ost); break; case AVMEDIA_TYPE_ATTACHMENT: new_stream_attachment(mux, o, ost); break; - default: new_stream_unknown (mux, o, ost); break; } if (type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO) { -- 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".