pbs / pycaption

Python module to read/write popular video caption formats
Apache License 2.0
256 stars 136 forks source link

BUG: Repeated commands in SCC file should be ignored #194

Closed ozt860071 closed 3 years ago

ozt860071 commented 4 years ago

Caption control commands in SCC are often repeated for redundancy. Pycaption should ignore the second command as it is specified the rule. Most other tools handle this properly.

From http://www.theneitherworld.com/mcpoodle/SCC_TOOLS/DOCS/SCC_FORMAT.HTML

Format of Pop-on Captions Pop-on captions have a set format, as described below, made up of commands (always 2-byte words) and characters (usually single bytes). If the caption is to be broadcast, each of the commands are doubled up for redundancy in case the signal is garbled in transmission (garbled data is usually displayed as character 7f, the solid block). The decoder is programmed to ignore a second command when it is the same as the first.

Pycaption does not ignore the repeated command and the second command is also executed. This results in errors like this.

image

Here is a snippet that generates the example above. (repeated commands are in bold)

00:00:29:04 9420 1370 97a1 1370 97a1 91ae 5b52 6164 e9ef 20f2 e570 eff2 f4e5 f25d 94d0 97a1 94d0 97a1 91ae 5468 e520 49ad 31b0 20d3 616e f461 20cd ef6e e9e3 6120 46f2 e5e5 f761 7980 9470 97a1 9470 97a1 91ae f7e5 73f4 62ef 756e 6420 e973 20ea 616d 6de5 642c 9420 942c 942f 9420 94d0 97a2 94d0 97a2 91ae 6475 e520 f4ef 2061 20f4 68f2 e5e5 ade3 61f2 2061 e3e3 e964 e56e f480 9470 97a2 9470 97a2 91ae 62ec efe3 6be9 6e67 20ec 616e e573 2031 2061 6e64 2032

This generates WebVTT output like this. (Similar result in SRT as well)

WEBVTT

00:30.897 --> 00:30.897 align:left position:0%,start line:80% size:100%
<i>[Radio reporter]

00:30.897 --> 00:30.897 align:left position:0%,start line:86.67% size:100%
Th</i>

00:30.897 --> 00:30.897 align:left position:0%,start line:86.67% size:100%
<i>e I-10 Santa Monica Freeway

00:30.897 --> 00:30.897 align:left position:0%,start line:93.33% size:100%
we</i>

00:30.897 --> 00:30.897 align:left position:0%,start line:93.33% size:100%
<i>stbound is jammed,</i>

00:30.897 --> 00:32.098 align:left position:0%,start line:86.67% size:100%
<i>due to a three-car accident

00:30.897 --> 00:32.098 align:left position:0%,start line:93.33% size:100%
bl</i>

00:30.897 --> 00:32.098 align:left position:0%,start line:93.33% size:100%
<i>ocking lanes 1 and 2</i>

If repeating commands are properly ignored, the WebVTT output would be like this. This will show the correct caption.

WEBVTT

00:30.697 --> 00:30.697 align:left position:0%,start line:80% size:100%
<i>[Radio reporter]
The I-10 Santa Monica Freeway
westbound is jammed,</i>

00:30.697 --> 00:31.765 align:left position:0%,start line:86.67% size:100%
<i>due to a three-car accident
blocking lanes 1 and 2</i>