1 /*
2 * RCWT (Raw Captions With Time) muxer
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 /*
22 * RCWT (Raw Captions With Time) is a format native to ccextractor, a commonly
23 * used open source tool for processing 608/708 Closed Captions (CC) sources.
24 *
25 * This muxer implements the specification as of March 2024, which has
26 * been stable and unchanged since April 2014.
27 *
28 * This muxer will have some nuances from the way that ccextractor muxes RCWT.
29 * No compatibility issues when processing the output with ccextractor
30 * have been observed as a result of this so far, but mileage may vary
31 * and outputs will not be a bit-exact match.
32 *
33 * Specifically, the differences are:
34 * (1) This muxer will identify as "FF" as the writing program identifier, so
35 * as to be honest about the output's origin.
36 *
37 * (2) This muxer will not alter the extracted data except to remove invalid
38 * packets in between valid CC blocks. On the other hand, ccextractor
39 * will by default remove mid-stream padding, and add padding at the end
40 * of the stream (in order to convey the end time of the source video).
41 *
42 * A free specification of RCWT can be found here:
43 * @url{https://github.com/CCExtractor/ccextractor/blob/master/docs/BINARY_FILE_FORMAT.TXT}
44 */
45
51
52 #define RCWT_CLUSTER_MAX_BLOCKS 65535
53 #define RCWT_BLOCK_SIZE 3
54
60
62 {
65 }
66
68 {
70
75 }
76
78 }
79
81 {
83
84 /* magic number */
87
88 /* program version (identify as ffmpeg) */
91
92 /* format version, only version 0.001 supported for now */
94
95 /* reserved */
98
100
101 return 0;
102 }
103
105 {
107
109 return 0;
110
111 /* new PTS, new cluster */
115 }
116
119 return 0;
120 }
121
123 uint8_t cc_valid;
124 uint8_t cc_type;
125
129 }
130
131 cc_valid = (
pkt->
data[
i] & 0x04) >> 2;
133
134 if (!(cc_valid || cc_type == 3)) {
136 continue;
137 }
138
142 }
143
144 return 0;
145 }
146
148 {
150
151 return 0;
152 }
153
167 };