mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-10-07 11:12:17 +00:00
subparse: accept WebVTT timestamps without an hour component
https://www.w3.org/TR/webvtt1/#webvtt-timestamp mm:ss,000 is a valid WebVTT timestamp
This commit is contained in:
parent
d5ee11fb36
commit
0739fafd62
1 changed files with 12 additions and 2 deletions
|
@ -903,9 +903,19 @@ parse_subrip_time (const gchar * ts_string, GstClockTime * t)
|
||||||
|
|
||||||
GST_LOG ("parsing timestamp '%s'", s);
|
GST_LOG ("parsing timestamp '%s'", s);
|
||||||
if (sscanf (s, "%u:%u:%u,%u", &hour, &min, &sec, &msec) != 4) {
|
if (sscanf (s, "%u:%u:%u,%u", &hour, &min, &sec, &msec) != 4) {
|
||||||
|
/* https://www.w3.org/TR/webvtt1/#webvtt-timestamp
|
||||||
|
*
|
||||||
|
* The hours component is optional with webVTT, for example
|
||||||
|
* mm:ss,500 is a valid webVTT timestamp. When not present,
|
||||||
|
* hours is 0.
|
||||||
|
*/
|
||||||
|
hour = 0;
|
||||||
|
|
||||||
|
if (sscanf (s, "%u:%u,%u", &min, &sec, &msec) != 3) {
|
||||||
GST_WARNING ("failed to parse subrip timestamp string '%s'", s);
|
GST_WARNING ("failed to parse subrip timestamp string '%s'", s);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
*t = ((hour * 3600) + (min * 60) + sec) * GST_SECOND + msec * GST_MSECOND;
|
*t = ((hour * 3600) + (min * 60) + sec) * GST_SECOND + msec * GST_MSECOND;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
Loading…
Reference in a new issue