+/*Parsing WebVTT */
+static int ParseVTT( demux_t *p_demux, subtitle_t *p_subtitle, int i_idx )
+{
+ VLC_UNUSED( i_idx );
+
+ demux_sys_t *p_sys = p_demux->p_sys;
+ text_t *txt = &p_sys->txt;
+ char *psz_text;
+
+ for( ;; )
+ {
+ const char *s = TextGetLine( txt );
+ int h1 = 0, m1 = 0, s1 = 0, d1 = 0;
+ int h2 = 0, m2 = 0, s2 = 0, d2 = 0;
+
+ if( !s )
+ return VLC_EGENERIC;
+
+ if( sscanf( s,"%d:%d:%d.%d --> %d:%d:%d.%d",
+ &h1, &m1, &s1, &d1,
+ &h2, &m2, &s2, &d2 ) == 8 ||
+ sscanf( s,"%d:%d:%d.%d --> %d:%d.%d",
+ &h1, &m1, &s1, &d1,
+ &m2, &s2, &d2 ) == 7 ||
+ sscanf( s,"%d:%d.%d --> %d:%d:%d.%d",
+ &m1, &s1, &d1,
+ &h2, &m2, &s2, &d2 ) == 7 ||
+ sscanf( s,"%d:%d.%d --> %d:%d.%d",
+ &m1, &s1, &d1,
+ &m2, &s2, &d2 ) == 6 )
+ {
+ p_subtitle->i_start = ( (int64_t)h1 * 3600 * 1000 +
+ (int64_t)m1 * 60 * 1000 +
+ (int64_t)s1 * 1000 +
+ (int64_t)d1 ) * 1000;
+
+ p_subtitle->i_stop = ( (int64_t)h2 * 3600 * 1000 +
+ (int64_t)m2 * 60 * 1000 +
+ (int64_t)s2 * 1000 +
+ (int64_t)d2 ) * 1000;
+ if( p_subtitle->i_start < p_subtitle->i_stop )
+ break;
+ }
+ }
+
+ /* Now read text until an empty line */
+ psz_text = strdup("");
+ if( !psz_text )
+ return VLC_ENOMEM;
+
+ for( ;; )
+ {
+ const char *s = TextGetLine( txt );
+ int i_len;
+ int i_old;
+
+ i_len = s ? strlen( s ) : 0;
+ if( i_len <= 0 )
+ {
+ p_subtitle->psz_text = psz_text;
+ return VLC_SUCCESS;
+ }
+
+ i_old = strlen( psz_text );
+ psz_text = realloc_or_free( psz_text, i_old + i_len + 1 + 1 );
+ if( !psz_text )
+ return VLC_ENOMEM;
+
+ strcat( psz_text, s );
+ strcat( psz_text, "\n" );
+ }
+}
+
+/* Matches filename.xx.srt */
+static char * get_language_from_filename( const char * psz_sub_file )
+{
+ char *psz_ret = NULL;
+ char *psz_tmp, *psz_language_begin;
+
+ if( !psz_sub_file ) return NULL;
+ char *psz_work = strdup( psz_sub_file );