McPoodle
31st March 2004, 22:27
Is anyone here interested in writing a fast tool to mux closed captions into MPEG files? I've written a tool in Perl, but as it appears to process 1 MB per hour, it is not very practical. The usefulness of this tool is that it will allow closed captions to be added to DVDs using any authoring tool out there (as opposed to the current situation, where captions can only be added by Sonic Scenarist, Spruce DVDMaestro or Apple DVD Studio Pro).
I've got the requirements and some sample files available for download here (http://www.geocities.com/mcpoodle43/SCC_TOOLS/dvd_cc.zip). Here's the short version:
Closed captions are stored in the form of user data packets in the video MPEG file (because this increases the size of the file, you'll either have to work with video elementary streams or else perform some de-muxing and re-muxing of program streams behind the scenes). The closed captions will be provided in the form of .SCC files, which are nothing more than hex dumps with timestamps. Closed captions transmit two bytes worth of data every frame, and the majority of these words are 8080, the closed caption code for "do nothing". The use of timecodes in SCC files allow the long stretches of 8080 to be skipped between timecodes.
Closed caption user data packets are inserted after each GOP packet (header 00 00 01 b8) and before the first picture header of that GOP (00 00 01 00). After the user data header (00 00 01 b2) comes the DVD closed caption header (43 43 01 f8), followed by an attribute byte (number of frames in the GOP times 2, plus 0x80). This is followed by a six-byte sequence for each frame in the GOP. The sequence begins with 0xff, followed by a two-byte word taken from the SCC file (or 80 80 if the file has run out), followed by 0xfe, followed by 00 00 (this was to support a second closed captioning stream, which I've never seen used for DVDs). There is no filler between the end of the last sequence and the beginning of the first picture packet.
The output file will be about 200 bytes larger than the input for each second of video, about 1.3 MB for a two-hour movie.
As you see, the process is not very complicated, but hardly the kind of job that Perl is suited for, and that's the only programming language I'm comfortable with. I could ask for the additional ability to mux using the ReplayTV 4000 and 5000 series formats (which are rather different that the DVD format), but I figure that's just pressing my luck.
My sincere thanks in advance to anyone willing to take up this task.
I've got the requirements and some sample files available for download here (http://www.geocities.com/mcpoodle43/SCC_TOOLS/dvd_cc.zip). Here's the short version:
Closed captions are stored in the form of user data packets in the video MPEG file (because this increases the size of the file, you'll either have to work with video elementary streams or else perform some de-muxing and re-muxing of program streams behind the scenes). The closed captions will be provided in the form of .SCC files, which are nothing more than hex dumps with timestamps. Closed captions transmit two bytes worth of data every frame, and the majority of these words are 8080, the closed caption code for "do nothing". The use of timecodes in SCC files allow the long stretches of 8080 to be skipped between timecodes.
Closed caption user data packets are inserted after each GOP packet (header 00 00 01 b8) and before the first picture header of that GOP (00 00 01 00). After the user data header (00 00 01 b2) comes the DVD closed caption header (43 43 01 f8), followed by an attribute byte (number of frames in the GOP times 2, plus 0x80). This is followed by a six-byte sequence for each frame in the GOP. The sequence begins with 0xff, followed by a two-byte word taken from the SCC file (or 80 80 if the file has run out), followed by 0xfe, followed by 00 00 (this was to support a second closed captioning stream, which I've never seen used for DVDs). There is no filler between the end of the last sequence and the beginning of the first picture packet.
The output file will be about 200 bytes larger than the input for each second of video, about 1.3 MB for a two-hour movie.
As you see, the process is not very complicated, but hardly the kind of job that Perl is suited for, and that's the only programming language I'm comfortable with. I could ask for the additional ability to mux using the ReplayTV 4000 and 5000 series formats (which are rather different that the DVD format), but I figure that's just pressing my luck.
My sincere thanks in advance to anyone willing to take up this task.