From patchwork Wed Aug 23 16:48:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "pkv.stream" X-Patchwork-Id: 4809 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.137.29 with SMTP id o29csp2172864jaj; Wed, 23 Aug 2017 09:48:34 -0700 (PDT) X-Received: by 10.28.173.195 with SMTP id w186mr1974939wme.10.1503506914535; Wed, 23 Aug 2017 09:48:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503506914; cv=none; d=google.com; s=arc-20160816; b=TvPvkOgjlTyNpxKzTc95twK+HkOxPKzNjXGTYaSOUBiZECZC9h4bbb6dba+QL8ujuh mu5HCZQhCYInSkFsfz8bQrJdWRV7iNRfuiKF4990LMo8C0sU15Yzri6nLD44gbDMsOfm kM/1K0pdtzSocZskpMkRgKdni5kDc4f1/y6h9FMcdMiNxDfwDpdr9GPDeaWVuuqG2b3z qACL0titrB7bphoxuv8WQZLLssxyqZG7DhH1zaaO7OEDGRqNCJj7kZMMR+1vx4T0e6Mq 8IKQnSjslLITrQML5e5MAb35L1WkNU/br2rVV35rAyf5cW27CXNEPdSDrCo99KbDH/0o FuDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject :content-language:mime-version:user-agent:date:message-id:from:to :dkim-signature:delivered-to:arc-authentication-results; bh=0fsXirnR03rbiXbFsKMpLMrcutsZkxg2xNqupEwFvvA=; b=UT3jyg9Yl8hIkFcudawbtgP1KoXtVwTPZroyNRX9pwHdCwlqr3E1aTHbsDuyj9MLiy 4f/fhSeWqFDLtt2aXL2hyLYWfLlt9oJCPCXbYTpxiZgdL6EMuxizUpD42oyYN9eJyOGX wZZg8p/Aif5ujA4OHrgpqKF7k20XwvvpplBqADPiwUtqMqDNUgZPLzgiOIJ+i9BtKTvD cEzqQ6Gl4//F+8fGzoqqvo4SXhiF0LriDm1FovfDd9VsePxA1iH2QcKYO6zCWMyCEcpN Qa1kN0rI2GkqEv5cJUmYbPljiANG0bkVL7CeyXVl7/fvdmSOZda4tA5Xi6S7rqO7T/Ju iTdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=i3xgh22T; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id k84si1682418wmh.61.2017.08.23.09.48.28; Wed, 23 Aug 2017 09:48:34 -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; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=i3xgh22T; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id BA2116807B8; Wed, 23 Aug 2017 19:48:17 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm0-f48.google.com (mail-wm0-f48.google.com [74.125.82.48]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5B289680624 for ; Wed, 23 Aug 2017 19:48:11 +0300 (EEST) Received: by mail-wm0-f48.google.com with SMTP id a70so887853wmd.1 for ; Wed, 23 Aug 2017 09:48:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:from:subject:message-id:date:user-agent:mime-version :content-language; bh=0APPJcouce0nGsPMOw/RSqYhYJBKXdTkGMwSLR0Hc7A=; b=i3xgh22TiLw22nkY2lD0ZrNZKtHXFFZosWGKndqpj/9YN6mIdb+iIDqgt6j122NJG7 mbqvbUUIOcAkV6ykT0rsGzTh41Ljfd27/MtRzbi3Uy51EoWhTCG/pF4mX+75ofGfjsK2 O4IjQLZJMv/xS8zAIy4R/TPRzWMPA3yQ5ZE7eolQXYngzXfvlJgmX7wWK+RJfxC/Wp3E eAK4H6MvqK4xoAvdl4hk+IhFPYORANDHmkTTS0/h0ijDPMUTLrKBqXNvkiPT8A6kJGXl iypsEE/ddLBH/ohHTkpBfzHUu4aypEacRJ7uuHBAYHet7FUawy0d59XzWB2+VcSTh3hK m5eA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version:content-language; bh=0APPJcouce0nGsPMOw/RSqYhYJBKXdTkGMwSLR0Hc7A=; b=HewJOf5NDen/759ZbFFznfOlvg3xeNCW0LsxwvoP6Mh0jhvWfN0qukN9yYAFYZFiTs Iz6/Cj4cSd/TpQIMo+vmcWAl0My0TXNMb6RzEFtF6H04Ydcd2xv7a9gS7tn5raPknf3H oTCAk/CAsZlHlWi36hJzu0Q6HtcLVGsNJCtnvqV6myC9IF7AEwbQzmpyLjTKhRciob1K AdhsLZP2+c9/ZZlV0z5qvWUjQJdnYXOyBzUKCeGFInAm+vlXEPqZX6m973mwUcaoqIrm 62ylanEDYkiLraiCAz943QcwqDrKaKXEyPgs90XA/ETtiXsLlo0acDqXQXCntnNTVXun okfg== X-Gm-Message-State: AHYfb5jpcKtPmuAkqqWkJHp6WHqCS1jXlpUF1XDLKRg7eRtN+iULNJGJ FSc+kndV7FhAsVIz X-Received: by 10.80.212.133 with SMTP id s5mr3814589edi.95.1503506898436; Wed, 23 Aug 2017 09:48:18 -0700 (PDT) Received: from [192.168.0.2] ([176.159.7.188]) by smtp.googlemail.com with ESMTPSA id t2sm1040601edj.76.2017.08.23.09.48.16 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Aug 2017 09:48:17 -0700 (PDT) To: ffmpeg-devel@ffmpeg.org From: "pkv.stream" Message-ID: Date: Wed, 23 Aug 2017 18:48:14 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 Content-Language: fr Subject: [FFmpeg-devel] [PATCH] ffmpeg options: Enable trailing ? for map_channel X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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" Hello, the following patch allows one to add a trailing ? to -map_channel as in -map option. E.g: -map_channel 0.0.2? so that if the channel does not exist, the command does not stop. This is similar to what one can do with -map. Thanks for any input. From 07959dfe79816d03c30b8027f45b41d60078b3fa Mon Sep 17 00:00:00 2001 From: pkviet Date: Tue, 22 Aug 2017 11:30:45 +0200 Subject: [PATCH] ffmpeg options: Enable trailing ? for map_channel The -map option allows for a trailing ? so that an error is not thrown if the input stream does not exist. This capability is extended to the map_channel option. This allows a ffmpeg command not to break if an input channel does not exist, which can be of use (for instance, scripts processing audio channels with sources having unset number of audio channels). --- ffmpeg_opt.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c index 1c4a11e..6b3912f 100644 --- a/ffmpeg_opt.c +++ b/ffmpeg_opt.c @@ -405,7 +405,12 @@ static int opt_map_channel(void *optctx, const char *opt, const char *arg) int n; AVStream *st; AudioChannelMap *m; - + char *allow_unused; + char *mapchan; + mapchan = av_strdup(arg); + if (!mapchan) + return AVERROR(ENOMEM); + GROW_ARRAY(o->audio_channel_maps, o->nb_audio_channel_maps); m = &o->audio_channel_maps[o->nb_audio_channel_maps - 1]; @@ -450,10 +455,21 @@ static int opt_map_channel(void *optctx, const char *opt, const char *arg) m->file_idx, m->stream_idx); exit_program(1); } + /* allow trailing ? to map_channel */ + if (allow_unused = strchr(mapchan, '?')) + *allow_unused = 0; if (m->channel_idx < 0 || m->channel_idx >= st->codecpar->channels) { - av_log(NULL, AV_LOG_FATAL, "mapchan: invalid audio channel #%d.%d.%d\n", - m->file_idx, m->stream_idx, m->channel_idx); - exit_program(1); + if (allow_unused) { + av_log(NULL, AV_LOG_VERBOSE, "mapchan: invalid audio channel #%d.%d.%d\n", + m->file_idx, m->stream_idx, m->channel_idx); + } + else { + av_log(NULL, AV_LOG_FATAL, "mapchan: invalid audio channel #%d.%d.%d\n" + "To ignore this, add a trailing '?' to the map_channel.\n", + m->file_idx, m->stream_idx, m->channel_idx); + exit_program(1); + } + } return 0; }