gfuentesdev / google-cast-sdk

Automatically exported from code.google.com/p/google-cast-sdk
0 stars 0 forks source link

TTML parsing does not support time-expressions in "offset-time" format #244

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

1. Clone https://github.com/googlecast/CastMediaPlayerStreamingDRM
2. Adjust captions.ttml file, change "00:00:38.608" to "38.608s"
3. Try to use the TTML file

What is the expected output? What do you see instead?
Expecting same subtitles, instead they are not picked up at all.

Please use labels and text to provide additional information.

Time expressions as per 
http://www.w3.org/TR/ttaf1-dfxp/#timing-value-timeExpression can be specified 
either as clock-time (00:01:10.343) or as offset-time (70.343s). 

0.5.0/media_player.js seems only able to parse clock-time, rendering all our 
subs unusable.
Looking at the obfuscated file, there is a function "pe" which is hardcoded to 
assume clock-time format is used, doing split(":") and parseInt on the groups 
and so on.
(Is the non-obfuscated version available somewhere? :))

Original issue reported on code.google.com by head...@gmail.com on 25 Apr 2014 at 7:48

GoogleCodeExporter commented 8 years ago
A "patch" against the obfuscated code, which should work for both expression 
formats (except offset expressions with unit "ticks"):

    reClock = /(\d\d):(\d\d):(\d\d)(?:(\.\d+)|:(\d+))?/,
    reOffset = /(\d+)(\.\d+)?(h|ms|m|s|f|t)/,
    pe = function (b, fps) {
        var d,c;
        if((c = b.match(reClock)) != null) {
            // hours ":" minutes ":" seconds ( fraction | ":" frames ( "." sub-frames )? )?
            d = 3600 * parseInt(c[1], 10) + 60 * parseInt(c[2], 10) + parseFloat(c[3]);
            if(c[4]) // fractions as ".\d+"
                d+= parseFloat(c[4]);
            else if(c[5]) // frames
                d += (parseInt(c[5], 10) / fps);
        }else if ((c = b.match(reOffset)) != null) {
            // time-count fraction? metric
            d = parseInt(c[1], 10);
            if(c[2]) // Fractions as  ".\d+"
                d+= parseFloat(c[2], 10);

            switch(c[3]) {
                case 'h': d*=3600; break;
                case 'm': d*=60; break;
                //case 's': break;
                case 'ms': d/=1000; break;
                case 'f': d/=fps; break;
                case 't': throw new Error("no ticks support in TTML parser");
            }
        }
        return d;
    },

Note that fps is from parameter here instead of this.somevariable. 

Original comment by head...@gmail.com on 25 Apr 2014 at 5:13

GoogleCodeExporter commented 8 years ago
Thanks, an internal issue was opened. I will keep this ticket updated with the 
new info when it is available.

Original comment by anad...@google.com on 4 May 2014 at 7:51

GoogleCodeExporter commented 8 years ago
This is now supported in MPL 1.0

//www.gstatic.com/cast/sdk/libs/mediaplayer/1.0.0/media_player.js

Original comment by vadi...@chromium.org on 25 Sep 2014 at 4:33

GoogleCodeExporter commented 8 years ago
This has been fixed. See the above comment.

Original comment by and...@google.com on 8 Oct 2014 at 4:33