From patchwork Fri Jul 2 10:03:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gyan Doshi X-Patchwork-Id: 28738 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a5d:965a:0:0:0:0:0 with SMTP id d26csp1475026ios; Fri, 2 Jul 2021 03:03:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw46WmUUt7zRKaDDftuLaMpAkaln43K7kb+AJjFS8ed1lDxEWcJozXbMpXspkvb/Uc+pemU X-Received: by 2002:a05:6402:1d25:: with SMTP id dh5mr5742077edb.355.1625220220438; Fri, 02 Jul 2021 03:03:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625220220; cv=none; d=google.com; s=arc-20160816; b=LNrCntSQsyNsqopkBEfZKr9D/WO1mNzL4/Xp+stFalHzfDyvFHMjWpU1MpGp+8Ta+u p6ZYoXqmiP0xmdEyk6D6/44rQddH5ovZzli+IOgK6cwpv04/VpXEY+4BTaLb+ZtJfqaZ oVUwF3bqJ61zz/P10AkxisylTPO/Cwj6ZH/rMomdIgpxRZEkRuMloKR0ApwZHhNvlJdY eeH0YJLuHpVd7+kXj4nlLkQe1u3LLxWNpI1BSlcZeud3fRsAz6dUNGKO0E7gkNst9M37 dujZA03RS6UF1IGT4uL1iy7njCscaLWuD+6pAWp8vQt0k3OSDw92qCeSPjc57ipZT6e/ x5Tg== 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:message-id:date:to:from :delivered-to; bh=9R1OpZ75iVJ2xudsOsTvOiUBGefP14yOotKXFTyHvLA=; b=OPT8B+sYuSdjB4CG90pJltXhc1NpHcVHOGuKXzmcNMAgitQzAhRDHnxnjM8s7EwbBq d+dSURe1C2zD5xvzgwnMSO7aItk42vp9yDlXGQp1arus+HgR83WhenEqV7UMgFlFT6HG u/8bB1kMMyFC5TSO5leftTwEbiFbRqRfaWhWwNFJE53syIFmGRvRnxoBTjX+s5EMlDPr +S9ExJ+skOxTuTjABe7Zr4jM+FcgUAkEpq1e9/jOHt5rRUu3TWtMV6KxyDqHyl8Wekkf m1bnqOvJXj1idGi5uNih+Dk3+FsUrfZ7B5pSST16QRAe6uCO5BYtoXTbbN2ALMRBXOTP XHrQ== 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 be9si2564592edb.606.2021.07.02.03.03.39; Fri, 02 Jul 2021 03:03:40 -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 58382689C38; Fri, 2 Jul 2021 13:03:34 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mout-p-102.mailbox.org (mout-p-102.mailbox.org [80.241.56.152]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EC4F9680AEB for ; Fri, 2 Jul 2021 13:03:27 +0300 (EEST) Received: from smtp2.mailbox.org (smtp2.mailbox.org [80.241.60.241]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 4GGVyk2fJNzQjb8 for ; Fri, 2 Jul 2021 12:03:26 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by spamfilter03.heinlein-hosting.de (spamfilter03.heinlein-hosting.de [80.241.56.117]) (amavisd-new, port 10030) with ESMTP id GO3_m2lg98fF for ; Fri, 2 Jul 2021 12:03:22 +0200 (CEST) From: Gyan Doshi To: ffmpeg-devel@ffmpeg.org Date: Fri, 2 Jul 2021 15:33:05 +0530 Message-Id: <20210702100305.1692-1-ffmpeg@gyani.pro> MIME-Version: 1.0 X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.89 / 15.00 / 15.00 X-Rspamd-Queue-Id: 8AB44181A X-Rspamd-UID: 8864f0 Subject: [FFmpeg-devel] [PATCH] ffmpeg: add option recast_media 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: wnxDw1UV2BbF Allows forcing decoders of different media type. Needed to decode media data muxed as data streams. --- doc/ffmpeg.texi | 5 +++++ fftools/ffmpeg_opt.c | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi index 7827291755..c1065086e5 100644 --- a/doc/ffmpeg.texi +++ b/doc/ffmpeg.texi @@ -449,6 +449,11 @@ output file already exists. Set number of times input stream shall be looped. Loop 0 means no loop, loop -1 means infinite loop. +@item -recast_media (@emph{global}) +Enable to allow forcing a decoder of a different media type than +the one detected or designated by the demuxer. Useful for decoding +media data muxed as data streams. + @item -c[:@var{stream_specifier}] @var{codec} (@emph{input/output,per-stream}) @itemx -codec[:@var{stream_specifier}] @var{codec} (@emph{input/output,per-stream}) Select an encoder (when used before an output file) or a decoder (when used diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index a63bed54cf..76a220c21c 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -186,6 +186,7 @@ static int input_sync; static int input_stream_potentially_available = 0; static int ignore_unknown_streams = 0; static int copy_unknown_streams = 0; +static int recast_media = 0; static int find_stream_info = 1; static void uninit_options(OptionsContext *o) @@ -759,7 +760,7 @@ static const AVCodec *find_codec_or_die(const char *name, enum AVMediaType type, av_log(NULL, AV_LOG_FATAL, "Unknown %s '%s'\n", codec_string, name); exit_program(1); } - if (codec->type != type) { + if (codec->type != type && !recast_media) { av_log(NULL, AV_LOG_FATAL, "Invalid %s type '%s'\n", codec_string, name); exit_program(1); } @@ -774,6 +775,8 @@ static const AVCodec *choose_decoder(OptionsContext *o, AVFormatContext *s, AVSt if (codec_name) { const AVCodec *codec = find_codec_or_die(codec_name, st->codecpar->codec_type, 0); st->codecpar->codec_id = codec->id; + if (recast_media && st->codecpar->codec_type != codec->type) + st->codecpar->codec_type = codec->type; return codec; } else return avcodec_find_decoder(st->codecpar->codec_id); @@ -3429,6 +3432,8 @@ const OptionDef options[] = { "Ignore unknown stream types" }, { "copy_unknown", OPT_BOOL | OPT_EXPERT, { ©_unknown_streams }, "Copy unknown stream types" }, + { "recast_media", OPT_BOOL | OPT_EXPERT, { &recast_media }, + "recast stream type in order to force a decoder of different media type" }, { "c", HAS_ARG | OPT_STRING | OPT_SPEC | OPT_INPUT | OPT_OUTPUT, { .off = OFFSET(codec_names) }, "codec name", "codec" },