From patchwork Sat Jul 23 14:09:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 36907 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:1649:b0:8b:613a:194d with SMTP id no9csp1047012pzb; Sat, 23 Jul 2022 07:11:36 -0700 (PDT) X-Google-Smtp-Source: AGRyM1veA8zfAexjxvEoURdi+/OSUU+xiH7NiXlpbzBgTp7l7QfFWi43nH5WqZKFg2fb6DNwt3Ul X-Received: by 2002:a17:907:3e03:b0:722:e694:438 with SMTP id hp3-20020a1709073e0300b00722e6940438mr3612642ejc.755.1658585495801; Sat, 23 Jul 2022 07:11:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658585495; cv=none; d=google.com; s=arc-20160816; b=VzD6GPGHsie2v0OYfa+RFKxotrU6zWxRj75vsOoMKypKI0g+jMYLiMBCw+WZBRn22M o6iflSidNcygYlZidOSGXemudE/Z6v38BCFOd9JuA2EB7k0yrGfwLdAkuEjny0Z/30nC seaxzFQ3IO0NUx516jYcW2HdDO916vEDf9HMB6ry8LsL8e4i06Ftv4oQUYJ0P8M+hx3k 4T8T6B/NK8ynK/CKL+uhxu8VnA0Gt5txpv5wlRQ+qvidDl2blS2UTLXpI5CGT43g+oTI QQ/fAXTxuFoDajLA2mXBaDiXHb3MdCj2/AImKf7A+vzTE42tTkqd5Y/crXw0/zLifTmZ 1dbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=Qs5OPJeTBc2xg8stPA+l7WuqFwjxH+3WNXq6BtDmOJg=; b=HZfrv4tbh8MyGDk1xwUjnGAQQF8lU81scAxduIH65+VK9TGiALE5yA8xRk+gniUbCY CKzbjMndTxWfHGcYWJEiYFwNqSaMBzCzChoCdU1d3jKSJR54IOnHe9+WnbSSMSdn0Aos Ylubn4U5lAo+CXe8OWX1ziZwTTPGiM1u6unQJ1yBZD5zyd+efmVzvxit7NPXV4D8ZvsO z29qEPiRDQ7f44E5daIrxKJZqKqCjYgMtNgm+iV+ApxARBrbQnFEiasLAePgaPIPfwMF jO+FFw1RBz8TzieEe1yWq1iNYBinViVYSnay73DmtyeGfUgs3NqF9jrrfF0Qmui538Go 2IwA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id eq5-20020a056402298500b0043a90a31070si7264910edb.284.2022.07.23.07.11.35; Sat, 23 Jul 2022 07:11:35 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id F37EC68B870; Sat, 23 Jul 2022 17:10:34 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4B83068B7CF for ; Sat, 23 Jul 2022 17:10:28 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 7A116240593 for ; Sat, 23 Jul 2022 16:10:25 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id hM8dOVXoDrHa for ; Sat, 23 Jul 2022 16:10:25 +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 AF2322405F5 for ; Sat, 23 Jul 2022 16:10:19 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id BB91C3A03D8; Sat, 23 Jul 2022 16:10:19 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sat, 23 Jul 2022 16:09:49 +0200 Message-Id: <20220723140952.31814-24-anton@khirnov.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220723140952.31814-1-anton@khirnov.net> References: <20220723140952.31814-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 24/27] fftools/ffmpeg_opt: factor auto-mapping data streams out of open_output_file() 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: Wc7BtrIbtTgp --- fftools/ffmpeg_opt.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 04f4abb88a..287527f478 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -2618,6 +2618,20 @@ static void map_auto_subtitle(OutputFile *of, AVFormatContext *oc, } } +static void map_auto_data(OutputFile *of, AVFormatContext *oc, + OptionsContext *o) +{ + /* Data only if codec id match */ + enum AVCodecID codec_id = av_guess_codec(oc->oformat, NULL, oc->url, NULL, AVMEDIA_TYPE_DATA); + for (int i = 0; codec_id != AV_CODEC_ID_NONE && i < nb_input_streams; i++) { + if (input_streams[i]->user_set_discard == AVDISCARD_ALL) + continue; + if (input_streams[i]->st->codecpar->codec_type == AVMEDIA_TYPE_DATA + && input_streams[i]->st->codecpar->codec_id == codec_id ) + new_data_stream(o, oc, i); + } +} + static int open_output_file(OptionsContext *o, const char *filename) { AVFormatContext *oc; @@ -2701,18 +2715,8 @@ static int open_output_file(OptionsContext *o, const char *filename) map_auto_audio(of, oc, o); if (!o->subtitle_disable) map_auto_subtitle(of, oc, o); - - /* Data only if codec id match */ - if (!o->data_disable ) { - enum AVCodecID codec_id = av_guess_codec(oc->oformat, NULL, filename, NULL, AVMEDIA_TYPE_DATA); - for (i = 0; codec_id != AV_CODEC_ID_NONE && i < nb_input_streams; i++) { - if (input_streams[i]->user_set_discard == AVDISCARD_ALL) - continue; - if (input_streams[i]->st->codecpar->codec_type == AVMEDIA_TYPE_DATA - && input_streams[i]->st->codecpar->codec_id == codec_id ) - new_data_stream(o, oc, i); - } - } + if (!o->data_disable) + map_auto_data(of, oc, o); } else { for (i = 0; i < o->nb_stream_maps; i++) { StreamMap *map = &o->stream_maps[i];