From patchwork Tue Aug 31 12:22:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas George X-Patchwork-Id: 29907 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2a4a:0:0:0:0 with SMTP id k10csp4873722iov; Tue, 31 Aug 2021 05:23:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwIN6jtUVc9kWl3igWu5XzMK3pQPY5OhZcFzrs0tnlBSP8x61N5EbFWfXj/AB8xKuuKAbb5 X-Received: by 2002:aa7:cb92:: with SMTP id r18mr29993434edt.282.1630412580461; Tue, 31 Aug 2021 05:23:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630412580; cv=none; d=google.com; s=arc-20160816; b=fst/Yrq67qnoQQb9t1LwFMM7/atwbUC0pz0ObZi6e7m0O6P3cjyBjJxCVcKON4FCsz xkpipMto3hiXopuR/xz8gFMr5FmoiV12i47oTLtKFi2kcnsl+QumD6ZXYZ/+aKfGSHEq wC35D2yaGbAmGBO6fXotYv8QCpaCnTHLuRKzO32khFG/RoR12QkgTWJ2zj6vM0JlmOaa Dz1xbg27uHSSd/n/76Q8dXqbxd3erfbn4gm/YcdWiNyX6Q3AxHr6XeaUYB2EFY/I2DOe RmBoL2BtAyo7EOcRUd23gui1w8BCMT01+9KjbTJQLijy+VkhtugMmYbi+ftlcJox56Jl JeYA== 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=uDgoipOMqa/+08BDACZp4U93CUy/0kyuErnytuVlG+E=; b=Ysb9lqdFNF/bP7jzrd0nkF8RU3zacGupzDinP82Rikc+iOU+WbSgYznpJJy67vHsRj bUVyuSGekSZ7FLGAbWpSDVkZYqm/lv6yD9uJ7zzSyrNktO/C4fq0n2L+PuacmJ83xB3I 2DG1b2Mcv7BQ0jqtt+cq272gPImVci4d/nymd34LMATfDZz1GmtEeyPVHdMmtF5b8Vl8 sVgBjzBZsJyKwO5it0YhcK/22b+14DiICszLCKvtvVc4inEyXNcLPsrI29FJNX0T3k4i 7UcdX111Lppj5jOmWQsYW+fwpAlfoSJKV3lLraY9DKbh8OB/yfo/Vlo0SJEFl3xd+sPi uo/Q== 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 g1si9048884edy.542.2021.08.31.05.22.57; Tue, 31 Aug 2021 05:23:00 -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 D325E68A3AE; Tue, 31 Aug 2021 15:22:24 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from nef.ens.fr (nef2.ens.fr [129.199.96.40]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8AC24680087 for ; Tue, 31 Aug 2021 15:22:13 +0300 (EEST) X-ENS-nef-client: 129.199.129.80 ( name = phare.normalesup.org ) Received: from phare.normalesup.org (phare.normalesup.org [129.199.129.80]) by nef.ens.fr (8.14.4/1.01.28121999) with ESMTP id 17VCMCVu019261 for ; Tue, 31 Aug 2021 14:22:13 +0200 Received: by phare.normalesup.org (Postfix, from userid 1001) id C47F6EB5BD; Tue, 31 Aug 2021 14:22:12 +0200 (CEST) From: Nicolas George To: ffmpeg-devel@ffmpeg.org Date: Tue, 31 Aug 2021 14:22:07 +0200 Message-Id: <20210831122209.586348-4-george@nsup.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210831122209.586348-1-george@nsup.org> References: <20210831122209.586348-1-george@nsup.org> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3 (nef.ens.fr [129.199.96.32]); Tue, 31 Aug 2021 14:22:13 +0200 (CEST) Subject: [FFmpeg-devel] [PATCH 4/6] lavf/concatdec: support stream metadata. 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: j1657zgnYXa+ Signed-off-by: Nicolas George --- doc/demuxers.texi | 4 ++++ libavformat/concatdec.c | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/doc/demuxers.texi b/doc/demuxers.texi index fd06be3195..87e4d0319a 100644 --- a/doc/demuxers.texi +++ b/doc/demuxers.texi @@ -177,6 +177,10 @@ subfiles will be used. This is especially useful for MPEG-PS (VOB) files, where the order of the streams is not reliable. +@item @code{stream_meta @var{key} @var{value}} +Metadata for the stream. +Can be present multiple times. + @end table @subsection Options diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c index 2981c7c27f..5ebac49b97 100644 --- a/libavformat/concatdec.c +++ b/libavformat/concatdec.c @@ -430,6 +430,7 @@ typedef enum ParseDirective { DIR_OPTION, DIR_STREAM, DIR_EXSID, + DIR_STMETA, } ParseDirective; static const ParseSyntax syntax[] = { @@ -443,6 +444,7 @@ static const ParseSyntax syntax[] = { [DIR_OPTION ] = { "option", "ks", NEEDS_FILE | NEEDS_UNSAFE }, [DIR_STREAM ] = { "stream", "", 0 }, [DIR_EXSID ] = { "exact_stream_id", "i", NEEDS_STREAM }, + [DIR_STMETA ] = { "stream_meta", "ks", NEEDS_STREAM }, }; static int concat_parse_script(AVFormatContext *avf) @@ -452,6 +454,7 @@ static int concat_parse_script(AVFormatContext *avf) AVBPrint bp; uint8_t *cursor, *keyword; ConcatFile *file = NULL; + AVStream *stream = NULL; unsigned line = 0, arg; const ParseSyntax *dir; char *arg_kw[MAX_ARGS]; @@ -569,11 +572,18 @@ static int concat_parse_script(AVFormatContext *avf) arg_str[1] = NULL; break; case DIR_STREAM: - if (!avformat_new_stream(avf, NULL)) + stream = avformat_new_stream(avf, NULL); + if (!stream) FAIL(AVERROR(ENOMEM)); break; case DIR_EXSID: - avf->streams[avf->nb_streams - 1]->id = arg_int[0]; + stream->id = arg_int[0]; + break; + case DIR_STMETA: + ret = av_dict_set(&stream->metadata, arg_kw[0], arg_str[1], AV_DICT_DONT_STRDUP_VAL); + if (ret < 0) + FAIL(ret); + arg_str[1] = NULL; break; default: FAIL(AVERROR_BUG);