summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathieu Duponchelle <mathieu@centricular.com>2020-03-11 01:01:34 +0100
committerTim-Philipp Müller <tim@centricular.com>2020-09-20 11:41:27 +0100
commit2ac6fbbb8b51e456eeed5ee9eea4554ee83fa029 (patch)
treea6e07bb64d1cae9093119a905ba6fe659c05a460
parent75d91a0958f8f9fa4ba64558df18e04b1a5af75a (diff)
downloadgstreamer-plugins-base-2ac6fbbb8b51e456eeed5ee9eea4554ee83fa029.tar.gz
subparse: accept WebVTT timestamps without an hour component
https://www.w3.org/TR/webvtt1/#webvtt-timestamp mm:ss,000 is a valid WebVTT timestamp
-rw-r--r--gst/subparse/gstsubparse.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/gst/subparse/gstsubparse.c b/gst/subparse/gstsubparse.c
index 425415874..beb987c3e 100644
--- a/gst/subparse/gstsubparse.c
+++ b/gst/subparse/gstsubparse.c
@@ -903,8 +903,18 @@ parse_subrip_time (const gchar * ts_string, GstClockTime * t)
GST_LOG ("parsing timestamp '%s'", s);
if (sscanf (s, "%u:%u:%u,%u", &hour, &min, &sec, &msec) != 4) {
- GST_WARNING ("failed to parse subrip timestamp string '%s'", s);
- return FALSE;
+ /* 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);
+ return FALSE;
+ }
}
*t = ((hour * 3600) + (min * 60) + sec) * GST_SECOND + msec * GST_MSECOND;