[MPlayer-dev-eng] A patch for subtitle colors with missing quotation marks

Clément Bœsch ubitux at gmail.com
Thu Aug 2 14:02:08 CEST 2012


On Thu, Aug 02, 2012 at 08:01:13AM -0300, Federico Kereki wrote:
> Hi!
> 
> I've come across many subtitles files with constructs such as
> 
> 1
> 00:00:04,669 --> 00:00:08,669
> <font color=#00ff00>The Closer 7x19</font>
> <font color=#00ffff>Last Rites</font>
> Original Air Date on July 30, 2012
> 
> where the font color is given in hex notation, but without the required
> enclosing quotation marks. This isn't allowed, and the viewer gets
> something like:
> 
> [image: Inline image 1]
> 
> This patch allows for these <font> definitions, and now rather shows:
> 
> [image: Inline image 2]
> 
> I also refactored a "while(...)" loop, substituting a "for(...)" loop
> instead.
> 
> Best regards,
> Federico Kereki
> 
> 
> 
> --- subassconvert.original      2012-08-01 22:05:37.609711324 -0300
> +++ subassconvert.c     2012-08-01 22:08:23.621333241 -0300
> @@ -194,9 +194,8 @@
>              int has_valid_attr = 0;
> 
>              *tag = tag[-1]; // keep values from previous tag
> -            line += 6;
> 
> -            while (*line && *line != '>') {
> +            for (line += 6; *line && *line != '>'; line++) {
>                  if (strncmp(line, "size=\"", 6) == 0) {
>                      line += 6;
>                      tag->size = strtol(line, &line, 10);
> @@ -204,6 +203,19 @@
>                          break;
>                      append_text(&new_line, "{\\fs%d}", tag->size);
>                      has_valid_attr = 1;
> +
> +                } else if (strncmp(line, "color=#", 7) == 0) {

What if "color=yellow", will that work?

I think you are the 3rd guy to propose a patch for this... Wasn't the last
one approved?

It might be interesting to replace this code with the FFmpeg API which
might handle that in a better way.

[...]

-- 
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20120802/79074b51/attachment.asc>


More information about the MPlayer-dev-eng mailing list