From patchwork Thu Jan 21 23:00:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jan_Ekstr=C3=B6m?= X-Patchwork-Id: 25065 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 96E5D44A6DD for ; Fri, 22 Jan 2021 01:26:31 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 73AE4689E7D; Fri, 22 Jan 2021 01:26:31 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ed1-f50.google.com (mail-ed1-f50.google.com [209.85.208.50]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5B26268008A for ; Fri, 22 Jan 2021 01:26:25 +0200 (EET) Received: by mail-ed1-f50.google.com with SMTP id s11so4533011edd.5 for ; Thu, 21 Jan 2021 15:26:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=ggTNv4SuuuITw6W7cYYGj6c712JfQWUP+rwYs4fjC0Y=; b=ajlQ0dbxXiiVLgkquXznF6E8PVEuGCUfI6F0NxSRZ4KNKAagF3KHN4Rweoazcp7F8D U1nCayYsS706GhAnwdsV5SDm+oKxSCF2vTKPVhWXErS4xjrBhgLS8eop+iwcma0q48YE aw4jwbj98nSSQ4rrznSfSVLDqObFOodvqJpHjdK6wU/gUepLAZfzaHw+5yVOFBE8exS/ Kmeh3L2Kg3U4TfDIZdcTfDrl2fYgEheApIgZ6cBejcN6MoAS2waG2Xavzsx6TuehBl+6 DEGwfMMfdLYizl/Oaj8vg/d9u8hPgRWZoL+uzG0V5no/03R8f3PNNxeWyAZ9h2s9gYN2 gGbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=ggTNv4SuuuITw6W7cYYGj6c712JfQWUP+rwYs4fjC0Y=; b=BkNXetZfN2O1JelB0OLAt1KkZnqEduzmS+qsEapDr+lNroAsH/y9JW3PZkLmXhkHGa CDf5RGOi44pb19FHvY/3pCv+T4h+ppYC8BijRkAi7cFbumbQNmjkbZ4qG5EJVrlaQnKV 2/kB6XHjXw1SdE/GvLspvrQj4T0fAOKFG0GdwRSuKF4ifOW4mT1UcMiDDsqZWMzrPIXP AhLN+7G/QATP3RAM7gMGdk4DixIr4ZSCluZoxf7x0uzkZ2f4Af/AuehZIJ51newjwvaS 8IhuDI27vP0upHp9ksaEUBo1B42+opbfBIagnaK1Woli8rA6IMhdaqYJsHenQr6NIP0C pw3w== X-Gm-Message-State: AOAM533d0mxZ4oh+u34jD4lW677D4a0X1hclh3ObtfwljrqKcLKr8H7m 6scaVrbak6cNEcz8G/I0+L02I9BQ694= X-Google-Smtp-Source: ABdhPJwYTxIWi4BIV9YQw2I2ioqNGHSSVxxsPfuhT+p5wHN5WKBkTF4Mg+TfmScjKc5pMUYE3FQmGA== X-Received: by 2002:a2e:3e02:: with SMTP id l2mr788879lja.301.1611270016431; Thu, 21 Jan 2021 15:00:16 -0800 (PST) Received: from localhost.localdomain (91-159-194-103.elisa-laajakaista.fi. [91.159.194.103]) by smtp.gmail.com with ESMTPSA id k19sm673575lfj.229.2021.01.21.15.00.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Jan 2021 15:00:15 -0800 (PST) From: =?utf-8?q?Jan_Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Fri, 22 Jan 2021 01:00:13 +0200 Message-Id: <20210121230013.22751-1-jeebjp@gmail.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avformat/concatdec: add support for setting input options 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" This way protocol or format related options can be set for all of the files opened during concatenation. --- libavformat/concatdec.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c index 6d5b9914f9..3c81d9fea6 100644 --- a/libavformat/concatdec.c +++ b/libavformat/concatdec.c @@ -66,6 +66,7 @@ typedef struct { ConcatMatchMode stream_match_mode; unsigned auto_convert; int segment_time_metadata; + AVDictionary *input_options; } ConcatContext; static int concat_probe(const AVProbeData *probe) @@ -329,6 +330,7 @@ static int open_file(AVFormatContext *avf, unsigned fileno) { ConcatContext *cat = avf->priv_data; ConcatFile *file = &cat->files[fileno]; + AVDictionary *options = NULL; int ret; if (cat->avf) @@ -344,12 +346,31 @@ static int open_file(AVFormatContext *avf, unsigned fileno) if ((ret = ff_copy_whiteblacklists(cat->avf, avf)) < 0) return ret; - if ((ret = avformat_open_input(&cat->avf, file->url, NULL, NULL)) < 0 || + if (cat->input_options && + (ret = av_dict_copy(&options, cat->input_options, 0) < 0)) + return ret; + + if ((ret = avformat_open_input(&cat->avf, file->url, NULL, &options)) < 0 || (ret = avformat_find_stream_info(cat->avf, NULL)) < 0) { av_log(avf, AV_LOG_ERROR, "Impossible to open '%s'\n", file->url); avformat_close_input(&cat->avf); + av_dict_free(&options); return ret; } + + if (av_dict_count(options)) { + AVDictionaryEntry *en = NULL; + + while ((en = av_dict_get(options, "", en, AV_DICT_IGNORE_SUFFIX))) { + av_log(avf, AV_LOG_WARNING, + "Option '%s' set to '%s' was ignored when opening %s " + "with the %s reader!\n", + en->key, en->value, file->url, cat->avf->iformat->name); + } + } + + av_dict_free(&options); + cat->cur_file = file; file->start_time = !fileno ? 0 : cat->files[fileno - 1].start_time + @@ -764,6 +785,9 @@ static const AVOption options[] = { OFFSET(auto_convert), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, DEC }, { "segment_time_metadata", "output file segment start time and duration as packet metadata", OFFSET(segment_time_metadata), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DEC }, + { "input_options", + "set options for all opened inputs using a :-separated list of key=value pairs", + OFFSET(input_options), AV_OPT_TYPE_DICT, { .str = NULL }, 0, 0, DEC }, { NULL } };