From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 7ECBE497B3 for ; Wed, 20 Mar 2024 14:37:50 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3449968D472; Wed, 20 Mar 2024 16:37:48 +0200 (EET) Received: from mail-lj1-f181.google.com (mail-lj1-f181.google.com [209.85.208.181]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E281568D44E for ; Wed, 20 Mar 2024 16:37:41 +0200 (EET) Received: by mail-lj1-f181.google.com with SMTP id 38308e7fff4ca-2d687da75c4so21174061fa.0 for ; Wed, 20 Mar 2024 07:37:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710945460; x=1711550260; darn=ffmpeg.org; h=user-agent:in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date:from:to:cc :subject:date:message-id:reply-to; bh=GYEcLNqseqSm5REUhKrqaLz6dLYd1Sb6mHaEJdvrsS4=; b=JAkfsUgOn263m37aPqEfzdxXmo/TfNU2bR94NmPRw85WjoFiqA1IeipRHQV/3WY8XN Z4WRKH+/SsiPXi+8JVOBAsflB6SlSZFUlWxVysAsLEvqF/4lta/B0RPb5WH6vTQXKBOn Kp5+iC/mJMmGx6F00hQSmYmyxJHJp65z9tKUE4gviE0eaMsfo4/bRjet/SULRgamhFf8 L8VD6YdNNuQkcx/RaG1oxSceaYhkLt6P1hzB29pPXrzgcL0UZZVhcG+gjNUYSESLNzsK 0SvaMCAEeFb3U/Zh6vngW9zhmO2y+5VOIyoKvw5tYaN7+wARC/N/wSmfxBcicY68wO4w GCog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710945460; x=1711550260; h=user-agent:in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=GYEcLNqseqSm5REUhKrqaLz6dLYd1Sb6mHaEJdvrsS4=; b=ccxIUVM2ILLRfQhBTk6ts3ZRf4r/qxmnsc10N8uyiIoY/8TJ4JJYi+Y+Un1l8GOr1U 43fQUgk5U3A3ZPPXq0frjBbp74ooFbrSnNo1RmXk88qy7XLi8StikeBx1sz9ZXUBKotI F2gWerLypeSeU3+jeeyIBUD86+eK8sW6mserRoDucMQO+WigUvuGFEGRTXfWNRHrUgDp kr1Zclm9doX1LvCiPdcDeXd91sbefjNF58CL6LWo53AX7advm3vp7jTdLF3Lh/mwMTXg nGSqE843C0a+wIzV1VYO3VqogZUtXHV7k0KHB3apsM1Xmrpj8s5zkG01sWv2oJLogool RNxg== X-Gm-Message-State: AOJu0Yz6IALnhoVkoC0p8cqs+K3igjjm5+BJl/sZmiZAvk0vjztKRygF dOUZzI2yxSK58gWWMORqLPOWNVWzEFFF1U7m0sHQRjLC0H7Jsw5oMrcREzIO X-Google-Smtp-Source: AGHT+IFK7o7qNzPrZ77fV/5irGPfIfyZzvVVmUX5JSD4gnmnPvUSntuZpi0C09TWhzMy5lYty1jncQ== X-Received: by 2002:a2e:b16c:0:b0:2d4:61b6:7a2a with SMTP id a12-20020a2eb16c000000b002d461b67a2amr12419226ljm.1.1710945459984; Wed, 20 Mar 2024 07:37:39 -0700 (PDT) Received: from mariano ([188.210.239.0]) by smtp.gmail.com with ESMTPSA id o13-20020a05600c4fcd00b004141250b36fsm2379138wmq.11.2024.03.20.07.37.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Mar 2024 07:37:39 -0700 (PDT) Received: by mariano (Postfix, from userid 1000) id 41C1ABFCDC; Wed, 20 Mar 2024 15:37:38 +0100 (CET) Date: Wed, 20 Mar 2024 15:37:38 +0100 From: Stefano Sabatini To: FFmpeg development discussions and patches Message-ID: Mail-Followup-To: FFmpeg development discussions and patches , Marth64 References: <20240319224429.3133701-1-marth64@proxyid.net> <20240319224429.3133701-2-marth64@proxyid.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240319224429.3133701-2-marth64@proxyid.net> User-Agent: Mutt/2.1.4 (2021-12-11) Subject: Re: [FFmpeg-devel] [PATCH v6 1/4] avformat/rcwtdec: add RCWT Closed Captions demuxer 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 Cc: Marth64 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On date Tuesday 2024-03-19 17:44:26 -0500, Marth64 wrote: > Raw Captions With Time (RCWT) is a format native to ccextractor, a commonly > used open source tool for processing 608/708 Closed Captions (CC) sources. > RCWT can be used to archive the original CC bitstream. The muxer was added > in January 2024. In this commit, add the demuxer. > > One can now demux RCWT files for rendering in ccaption_dec or interoperate > with ccextractor (which produces RCWT). Using the muxer/demuxer combination, > the CC bits can be kept for further processing or rendering with either tool. > This can be an effective approach to backup original CC presentations. > > Prior to this, the next best solution was FFmpeg's SCC muxer, but SCC itself > is not compatible with ccextractor (which is a de facto OSS CC processing tool) > and it is a proprietary format. > > Tests will follow. > > Signed-off-by: Marth64 > --- > Changelog | 2 +- > libavformat/Makefile | 1 + > libavformat/allformats.c | 1 + > libavformat/rcwtdec.c | 150 +++++++++++++++++++++++++++++++++++++++ missing docs in the update? > 4 files changed, 153 insertions(+), 1 deletion(-) > create mode 100644 libavformat/rcwtdec.c > > diff --git a/Changelog b/Changelog > index e3ca52430c..abe5f79b85 100644 > --- a/Changelog > +++ b/Changelog > @@ -19,7 +19,7 @@ version : > - lavu/eval: introduce randomi() function in expressions > - VVC decoder > - fsync filter > -- Raw Captions with Time (RCWT) closed caption muxer > +- RCWT (Raw Captions with Time) Closed Captions muxer and demuxer > - ffmpeg CLI -bsf option may now be used for input as well as output > - ffmpeg CLI options may now be used as -/opt , which is equivalent > to -opt > > diff --git a/libavformat/Makefile b/libavformat/Makefile > index 94a949f555..a6de720d8c 100644 > --- a/libavformat/Makefile > +++ b/libavformat/Makefile > @@ -493,6 +493,7 @@ OBJS-$(CONFIG_QOA_DEMUXER) += qoadec.o > OBJS-$(CONFIG_R3D_DEMUXER) += r3d.o > OBJS-$(CONFIG_RAWVIDEO_DEMUXER) += rawvideodec.o > OBJS-$(CONFIG_RAWVIDEO_MUXER) += rawenc.o > +OBJS-$(CONFIG_RCWT_DEMUXER) += rcwtdec.o subtitles.o > OBJS-$(CONFIG_RCWT_MUXER) += rcwtenc.o subtitles.o > OBJS-$(CONFIG_REALTEXT_DEMUXER) += realtextdec.o subtitles.o > OBJS-$(CONFIG_REDSPARK_DEMUXER) += redspark.o > diff --git a/libavformat/allformats.c b/libavformat/allformats.c > index e15d0fa6d7..3140018f8d 100644 > --- a/libavformat/allformats.c > +++ b/libavformat/allformats.c > @@ -391,6 +391,7 @@ extern const FFInputFormat ff_qoa_demuxer; > extern const FFInputFormat ff_r3d_demuxer; > extern const FFInputFormat ff_rawvideo_demuxer; > extern const FFOutputFormat ff_rawvideo_muxer; > +extern const FFInputFormat ff_rcwt_demuxer; > extern const FFOutputFormat ff_rcwt_muxer; > extern const FFInputFormat ff_realtext_demuxer; > extern const FFInputFormat ff_redspark_demuxer; > diff --git a/libavformat/rcwtdec.c b/libavformat/rcwtdec.c > new file mode 100644 > index 0000000000..0d9eba025a > --- /dev/null > +++ b/libavformat/rcwtdec.c > @@ -0,0 +1,150 @@ > +/* > + * RCWT (Raw Captions With Time) demuxer > + * > + * This file is part of FFmpeg. > + * > + * FFmpeg is free software; you can redistribute it and/or > + * modify it under the terms of the GNU Lesser General Public > + * License as published by the Free Software Foundation; either > + * version 2.1 of the License, or (at your option) any later version. > + * > + * FFmpeg is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + * Lesser General Public License for more details. > + * > + * You should have received a copy of the GNU Lesser General Public > + * License along with FFmpeg; if not, write to the Free Software > + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA > + */ > + > +/* > + * RCWT (Raw Captions With Time) is a format native to ccextractor, a commonly > + * used open source tool for processing 608/708 Closed Captions (CC) sources. > + * > + * This demuxer implements the specification as of March 2024, which has > + * been stable and unchanged since April 2014. > + * > + * A free specification of RCWT can be found here: > + * @url{https://github.com/CCExtractor/ccextractor/blob/master/docs/BINARY_FILE_FORMAT.TXT} > + */ > + > +#include "avformat.h" > +#include "demux.h" > +#include "internal.h" > +#include "subtitles.h" > +#include "libavutil/intreadwrite.h" > + > +#define RCWT_CLUSTER_MAX_BLOCKS 65535 > +#define RCWT_BLOCK_SIZE 3 > +#define RCWT_HEADER_SIZE 11 > + > +typedef struct RCWTContext { > + FFDemuxSubtitlesQueue q; > +} RCWTContext; > + > +static int rcwt_read_header(AVFormatContext *avf) > +{ > + RCWTContext *rcwt = avf->priv_data; > + > + AVPacket *sub = NULL; > + AVStream *st; > + uint8_t header[RCWT_HEADER_SIZE] = {0}; > + int nb_bytes = 0; > + > + /* validate the header */ > + nb_bytes = avio_read(avf->pb, header, RCWT_HEADER_SIZE); > + if (nb_bytes != RCWT_HEADER_SIZE) { > + av_log(avf, AV_LOG_ERROR, "Header does not have the expected size " > + "(expected=%d actual=%d)\n", > + RCWT_HEADER_SIZE, nb_bytes); > + return AVERROR_INVALIDDATA; > + } > + > + if (AV_RB16(header + 6) != 0x0001) { > + av_log(avf, AV_LOG_ERROR, "RCWT format version is not compatible " > + "(only version 0.001 is known)\n"); > + return AVERROR_INVALIDDATA; > + } > + > + av_log(avf, AV_LOG_DEBUG, "RCWT writer application: %02X version: %02x\n", > + header[3], header[5]); > + > + /* setup AVStream */ > + st = avformat_new_stream(avf, NULL); > + if (!st) > + return AVERROR(ENOMEM); > + > + st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE; > + st->codecpar->codec_id = AV_CODEC_ID_EIA_608; > + > + avpriv_set_pts_info(st, 64, 1, 1000); > + > + /* demux */ > + while (!avio_feof(avf->pb)) { > + int64_t cluster_pts = AV_NOPTS_VALUE; > + int cluster_nb_blocks = 0; > + int cluster_size = 0; do you need to init these ones? [...] Looks good to me otherwise. _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".