mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 20:21:24 +00:00
subparse: WebVTT Cue identifiers are optional
Don't require a cue identifier preceding the time range line when parsing WebVTT. We could also store the CueID, but it's not using anywhere, so just ignore it for now.
This commit is contained in:
parent
4a9be62ec6
commit
c27df799bf
1 changed files with 14 additions and 6 deletions
|
@ -977,15 +977,19 @@ parse_webvtt_cue_settings (ParserState * state, const gchar * settings)
|
|||
static gchar *
|
||||
parse_subrip (ParserState * state, const gchar * line)
|
||||
{
|
||||
int subnum;
|
||||
gchar *ret;
|
||||
|
||||
switch (state->state) {
|
||||
case 0:
|
||||
/* looking for a single integer */
|
||||
if (sscanf (line, "%u", &subnum) == 1)
|
||||
case 0:{
|
||||
char *endptr;
|
||||
|
||||
/* looking for a single integer as a Cue ID, but we
|
||||
* don't actually use it */
|
||||
(void) strtol (line, &endptr, 10);
|
||||
if (endptr != line && *endptr == '\0')
|
||||
state->state = 1;
|
||||
return NULL;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
GstClockTime ts_start, ts_end;
|
||||
|
@ -1082,7 +1086,10 @@ parse_lrc (ParserState * state, const gchar * line)
|
|||
static gchar *
|
||||
parse_webvtt (ParserState * state, const gchar * line)
|
||||
{
|
||||
if (state->state == 1) {
|
||||
/* Cue IDs are optional in WebVTT, but not in subrip,
|
||||
* so when in state 0 (cue ID), also check if we're
|
||||
* already at the start --> end time marker */
|
||||
if (state->state == 0 || state->state == 1) {
|
||||
GstClockTime ts_start, ts_end;
|
||||
gchar *end_time;
|
||||
gchar *cue_settings = NULL;
|
||||
|
@ -1733,7 +1740,8 @@ handle_buffer (GstSubParse * self, GstBuffer * buf)
|
|||
/* Set segment on our parser state machine */
|
||||
self->state.segment = &self->segment;
|
||||
/* Now parse the line, out of segment lines will just return NULL */
|
||||
GST_LOG_OBJECT (self, "Parsing line '%s'", line + offset);
|
||||
GST_LOG_OBJECT (self, "State %d. Parsing line '%s'", self->state.state,
|
||||
line + offset);
|
||||
subtitle = self->parse_line (&self->state, line + offset);
|
||||
g_free (line);
|
||||
|
||||
|
|
Loading…
Reference in a new issue