Re: [FFmpeg-devel] [PATCH v10 2/5] avformat/rcwtdec: add RCWT Closed Captions demuxer

2024-04-01 Thread Marth64
Sorry for the delay, v11 coming shortly with the fix.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH v10 2/5] avformat/rcwtdec: add RCWT Closed Captions demuxer

2024-03-31 Thread Michael Niedermayer
On Sat, Mar 30, 2024 at 03:55:13PM +0100, Stefano Sabatini wrote:
> On date Saturday 2024-03-30 01:23:53 +0100, Michael Niedermayer wrote:
> > On Thu, Mar 28, 2024 at 03:11:29PM -0500, Marth64 wrote:
> > [...]
> > 
> > > +static int rcwt_probe(const AVProbeData *p)
> > > +{
> > > +return p->buf_size > RCWT_HEADER_SIZE   &&
> > > +   AV_RB16(p->buf) == 0x&&
> > > +   AV_RB8(p->buf + 2) == 0xED   &&
> > > +   AV_RB16(p->buf + 6) == 0x0001? 50 : 0;
> > > +}
> > > +
> > > +const FFInputFormat ff_rcwt_demuxer = {
> > > +.p.name = "rcwt",
> > > +.p.long_name= NULL_IF_CONFIG_SMALL("RCWT (Raw Captions With 
> > > Time)"),
> > > +.p.extensions   = "bin",
> > 
> 
> > this causes a mp3 i have to be misdetected
> > ~/videos/sbQ9.bin
> > (this is a actual file i had not a file crafted for this)
> > 
> > i think the entry for extensions should be removed (which fixes this)
> > having a ".bin" is not a strong indication that its rcwt
> 
> Is this blocking or can it be addressed later? Also, if this needs to

droping the "bin" from the demuxer should be trivial to do, the extension
is IIRC used mainly for probing and its wrong for probing to associate bin with
any specific format.


> be modified the muxer should be as well.

maybe, yes

thx

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

What does censorship reveal? It reveals fear. -- Julian Assange


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH v10 2/5] avformat/rcwtdec: add RCWT Closed Captions demuxer

2024-03-30 Thread Marth64
> i think the entry for extensions should be removed (which fixes this)
> having a ".bin" is not a strong indication that its rcwt

> Is this blocking or can it be addressed later? Also, if this needs to
> be modified the muxer should be as well.

I can address both today in a new set. .bin is pretty generic
(although it is what ccextractor uses), so I get it. Thanks.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH v10 2/5] avformat/rcwtdec: add RCWT Closed Captions demuxer

2024-03-30 Thread Stefano Sabatini
On date Saturday 2024-03-30 01:23:53 +0100, Michael Niedermayer wrote:
> On Thu, Mar 28, 2024 at 03:11:29PM -0500, Marth64 wrote:
> [...]
> 
> > +static int rcwt_probe(const AVProbeData *p)
> > +{
> > +return p->buf_size > RCWT_HEADER_SIZE   &&
> > +   AV_RB16(p->buf) == 0x&&
> > +   AV_RB8(p->buf + 2) == 0xED   &&
> > +   AV_RB16(p->buf + 6) == 0x0001? 50 : 0;
> > +}
> > +
> > +const FFInputFormat ff_rcwt_demuxer = {
> > +.p.name = "rcwt",
> > +.p.long_name= NULL_IF_CONFIG_SMALL("RCWT (Raw Captions With 
> > Time)"),
> > +.p.extensions   = "bin",
> 

> this causes a mp3 i have to be misdetected
> ~/videos/sbQ9.bin
> (this is a actual file i had not a file crafted for this)
> 
> i think the entry for extensions should be removed (which fixes this)
> having a ".bin" is not a strong indication that its rcwt

Is this blocking or can it be addressed later? Also, if this needs to
be modified the muxer should be as well.

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH v10 2/5] avformat/rcwtdec: add RCWT Closed Captions demuxer

2024-03-29 Thread Michael Niedermayer
On Thu, Mar 28, 2024 at 03:11:29PM -0500, Marth64 wrote:
[...]

> +static int rcwt_probe(const AVProbeData *p)
> +{
> +return p->buf_size > RCWT_HEADER_SIZE   &&
> +   AV_RB16(p->buf) == 0x&&
> +   AV_RB8(p->buf + 2) == 0xED   &&
> +   AV_RB16(p->buf + 6) == 0x0001? 50 : 0;
> +}
> +
> +const FFInputFormat ff_rcwt_demuxer = {
> +.p.name = "rcwt",
> +.p.long_name= NULL_IF_CONFIG_SMALL("RCWT (Raw Captions With Time)"),
> +.p.extensions   = "bin",

this causes a mp3 i have to be misdetected
~/videos/sbQ9.bin
(this is a actual file i had not a file crafted for this)

i think the entry for extensions should be removed (which fixes this)
having a ".bin" is not a strong indication that its rcwt

thx

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

During times of universal deceit, telling the truth becomes a
revolutionary act. -- George Orwell


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH v10 2/5] avformat/rcwtdec: add RCWT Closed Captions demuxer

2024-03-29 Thread Marth64
Tomas Härdin :
> once I get my srtdec patchset through there will
> be something to follow.
I see the patch now. I agree, this looks like a good step. Thank you!

> Nah it can be done at a later point as an enhancement if you prefer
Yes, please. I am happy to do it, but I think will be
smoother to do after an example is there (since it introduces
a new pattern for subtitles). Thank you for understanding.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH v10 2/5] avformat/rcwtdec: add RCWT Closed Captions demuxer

2024-03-29 Thread Tomas Härdin
fre 2024-03-29 klockan 09:28 -0500 skrev Marth64:
> Tomas Härdin:
> > Can we please get away from this way of reading subtitles? Every
> > other
> > type of media (audio, video) are capable of being streamed, but not
> > subtitles, precisely because all of them do all parsing in the
> > read_header() call. We have a perfectly good generic index and
> > seeking
> > functionality. My recent experiment with srt shows it's possible to
> > read packets in read_packet() like every other demuxer..
> 
> Is there an example I can follow?

Not yet, but perhaps once I get my srtdec patchset through there will
be something to follow. Might follow it up with a similar patch for
webvttdec

> Is this something that can be fixed
> in an enhancement patch or is it a deal-breaker to merge this?

Nah it can be done at a later point as an enhancement if you prefer

/Tomas
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH v10 2/5] avformat/rcwtdec: add RCWT Closed Captions demuxer

2024-03-29 Thread Marth64
Tomas Härdin:
> Can we please get away from this way of reading subtitles? Every other
> type of media (audio, video) are capable of being streamed, but not
> subtitles, precisely because all of them do all parsing in the
> read_header() call. We have a perfectly good generic index and seeking
> functionality. My recent experiment with srt shows it's possible to
> read packets in read_packet() like every other demuxer..

Is there an example I can follow?  Is this something that can be fixed
in an enhancement patch or is it a deal-breaker to merge this?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH v10 2/5] avformat/rcwtdec: add RCWT Closed Captions demuxer

2024-03-29 Thread Tomas Härdin
> +    /* demux */
> +    while (!avio_feof(avf->pb)) {

Can we please get away from this way of reading subtitles? Every other
type of media (audio, video) are capable of being streamed, but not
subtitles, precisely because all of them do all parsing in the
read_header() call. We have a perfectly good generic index and seeking
functionality. My recent experiment with srt shows it's possible to
read packets in read_packet() like every other demuxer..

/Tomas

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v10 2/5] avformat/rcwtdec: add RCWT Closed Captions demuxer

2024-03-28 Thread Marth64
RCWT (Raw Captions With Time) is a format native to ccextractor,
a commonly used OSS tool for processing 608/708 Closed Captions (CC).
RCWT can be used to archive the original extracted 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 interop
with ccextractor (which produces RCWT). Using the muxer/demuxer combo,
the CC bits can be kept for processing or rendering with either tool.
This can be an effective way to backup an original CC stream, including
format extensions like EIA-708 and overall original presentation.

Signed-off-by: Marth64 
---
 doc/demuxers.texi|  30 ++
 libavformat/Makefile |   1 +
 libavformat/allformats.c |   1 +
 libavformat/rcwtdec.c| 123 +++
 4 files changed, 155 insertions(+)
 create mode 100644 libavformat/rcwtdec.c

diff --git a/doc/demuxers.texi b/doc/demuxers.texi
index b70f3a38d7..04293c4813 100644
--- a/doc/demuxers.texi
+++ b/doc/demuxers.texi
@@ -1038,6 +1038,36 @@ the command:
 ffplay -f rawvideo -pixel_format rgb24 -video_size 320x240 -framerate 10 
input.raw
 @end example
 
+@anchor{rcwtdec}
+@section rcwt
+
+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.
+For more information on the format, see @ref{rcwtenc,,,ffmpeg-formats}.
+
+This demuxer implements the specification as of March 2024, which has
+been stable and unchanged since April 2014.
+
+@subsection Examples
+
+@itemize
+@item
+Render CC to ASS using the built-in decoder:
+@example
+ffmpeg -i CC.rcwt.bin CC.ass
+@end example
+Note that if your output appears to be empty, you may have to manually
+set the decoder's @option{data_field} option to pick the desired CC substream.
+
+@item
+Convert an RCWT backup to Scenarist (SCC) format:
+@example
+ffmpeg -i CC.rcwt.bin -c:s copy CC.scc
+@end example
+Note that the SCC format does not support all of the possible CC extensions
+that can be stored in RCWT (such as EIA-708).
+@end itemize
+
 @section sbg
 
 SBaGen script demuxer.
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 44aa485029..5d77cba7f1 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 9df42bb87a..ae925dcf60 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 00..91f994c3ab
--- /dev/null
+++ b/libavformat/rcwtdec.c
@@ -0,0 +1,123 @@
+/*
+ * 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_HEADER_SIZE11
+
+typedef