From patchwork Tue Aug 31 18:07:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas George X-Patchwork-Id: 29925 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2a4a:0:0:0:0 with SMTP id k10csp5155470iov; Tue, 31 Aug 2021 11:09:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwR2tYqXQ1SAbNuxoha9BcNkpCyZ2Jsx3cnuByCuWC4SBlA8ydQpNUTRaC+ypEa8ZQNSS8y X-Received: by 2002:a17:906:314e:: with SMTP id e14mr32699340eje.165.1630433363640; Tue, 31 Aug 2021 11:09:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630433363; cv=none; d=google.com; s=arc-20160816; b=cIkhQlwJiUkPHpyL2muwpCHNglfQyMuTKqc49v8J8ECmp4UHbDAYfCtLTcxIUDNuAG y7aQWh4EQE6CQaIj234JV4k0aMvNMo7eu/AFxpSaphU2RIZfz1t/uNtXjc4SHz95H4Q8 2lP6Z8vUuuhqEg4VTCygWyDuYMP0CgO83MlCOyD3XSRAJbZJgw0diQRmQ6wORxQTZLnE pE6QK9gMHxnBC8MW0on7h7JIUhtYt0rI0K+3vrNo3GVzEm9tL1cLU0At4V2eP/WuZZ8x v4UoYKoy+08nLqt6KOULjXMZkqC6sij6xkLXc1YNz0NsISSAezMg5po8t+nzooWZ7OcC J7CA== 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=z5H4eaTk06elVJxFKv6hiEv6c6oMgMQXKj2p5AJclnA=; b=CeZT5reDJVxR99Y8434cvIsCtxvpCh54JnPcwPYV9Tl/dZME7ZJ9iUjeQbjNQcYqb+ VnspAHlNhpGtKbblwPQP77CgMX15ooY4CB6/6aoytR0vWyBMwY6c53oLUaahyYLe63le 3ZjludU7/m6ipr9II2OB3hI2SpINz2ICw875C29QhJLDbKNRYShO0SeqI9N0GWl8EVPA /EC4Hb1AzofkpxM3yQUbD+a7nyZ2lYxmj75fz2ATHad9tL4Sp1068bXmu2b4F9nw3DL6 Hoz0AN2eDnx+mRH/+izmy3jairo+61ldaZnQ7Y9eIQ9GM6Ve1XJLxtLOOzU+0JnfpHMw e3aA== 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 q2si592163eds.540.2021.08.31.11.09.23; Tue, 31 Aug 2021 11:09:23 -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 68C5868A543; Tue, 31 Aug 2021 21:07:58 +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 DC56868A3AE for ; Tue, 31 Aug 2021 21:07:45 +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 17VI7jdi030775 for ; Tue, 31 Aug 2021 20:07:45 +0200 Received: by phare.normalesup.org (Postfix, from userid 1001) id 1A0E7EB5BC; Tue, 31 Aug 2021 20:07:45 +0200 (CEST) From: Nicolas George To: ffmpeg-devel@ffmpeg.org Date: Tue, 31 Aug 2021 20:07:36 +0200 Message-Id: <20210831180739.873390-9-george@nsup.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210831180739.873390-1-george@nsup.org> References: <20210831180739.873390-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 20:07:45 +0200 (CEST) Subject: [FFmpeg-devel] [PATCH 09/12] lavf/concat: add support for chapters 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: Xj+CjTGrTVIa Signed-off-by: Nicolas George --- doc/demuxers.texi | 4 ++++ libavformat/concatdec.c | 12 +++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/doc/demuxers.texi b/doc/demuxers.texi index 6bb0574e94..0c347e3f47 100644 --- a/doc/demuxers.texi +++ b/doc/demuxers.texi @@ -184,6 +184,10 @@ Can be present multiple times. @item @code{stream_codec @var{value}} Codec for the stream. +@item @code{cahpter @var{id} @var{start} @var{end}} +Add a chapter. @var{id} is an unique identifier, possibly small and +consecutive. + @end table @subsection Options diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c index a0d68d51cc..0dd39a149e 100644 --- a/libavformat/concatdec.c +++ b/libavformat/concatdec.c @@ -408,7 +408,7 @@ static int concat_read_close(AVFormatContext *avf) return 0; } -#define MAX_ARGS 2 +#define MAX_ARGS 3 #define NEEDS_UNSAFE (1 << 1) #define NEEDS_FILE (1 << 1) #define NEEDS_STREAM (1 << 2) @@ -432,6 +432,7 @@ typedef enum ParseDirective { DIR_EXSID, DIR_STMETA, DIR_STCODEC, + DIR_CHAPTER, } ParseDirective; static const ParseSyntax syntax[] = { @@ -447,6 +448,7 @@ static const ParseSyntax syntax[] = { [DIR_EXSID ] = { "exact_stream_id", "i", NEEDS_STREAM }, [DIR_STMETA ] = { "stream_meta", "ks", NEEDS_STREAM }, [DIR_STCODEC ] = { "stream_codec", "k", NEEDS_STREAM }, + [DIR_CHAPTER ] = { "chapter", "idd", 0 }, }; static int concat_parse_script(AVFormatContext *avf) @@ -457,6 +459,7 @@ static int concat_parse_script(AVFormatContext *avf) uint8_t *cursor, *keyword; ConcatFile *file = NULL; AVStream *stream = NULL; + AVChapter *chapter = NULL; unsigned line = 0, arg; const ParseSyntax *dir; char *arg_kw[MAX_ARGS]; @@ -609,6 +612,13 @@ static int concat_parse_script(AVFormatContext *avf) break; } + case DIR_CHAPTER: + chapter = avpriv_new_chapter(avf, arg_int[0], AV_TIME_BASE_Q, + arg_int[1], arg_int[2], NULL); + if (!chapter) + return AVERROR(ENOMEM); + break; + default: FAIL(AVERROR_BUG); }