You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
subtitles parser doesn't handle time codes that include more than 3 digits in the milliseconds field #1997
notice that all time codes have 6 digits in the milliseconds field
ex: 00:00:00.000000 --> 00:00:00.100000
I didn't dig into the code to see how the parser is processing this field, but I can tell you that in ExoPlayer.. no subtitles show for a while.. and then (at about 7 minutes) a giant dump of text covers the screen
quick test:
I downloaded the file
opened it in a text editor
performed the following regex operation on its contents:
search: (\.\d{3})\d{3}
replace: $1
note: this effectively truncates the milliseconds field from 6 digits to 3 digits
loaded the resulting vtt file in ExoPlayer
issue fixed.. captions play as expected
note: I haven't yet tested their SRT captions; I suspect the same time code format. TBD..
I just checked a few previous episodes, and they all include both SRT and VTT captions having 3 decimal millisecond fields..
only the episode on 12/23 is different.. only offering VTT captions (no SRT), and the format being.. as described.
on the one hand, hopefully PBS will fix itself.
on the other hand, it illustrated a bug in ExoPlayer that should be easily fixed.
The change linked above tightens ExoPlayer's parsing to completely ignore cues with more or less than 3 decimal places (rather than render them at an incorrect time).
Activity
warren-bank commentedon Dec 24, 2024
[off-topic] quick observation regarding PBS..
I just checked a few previous episodes, and they all include both SRT and VTT captions having 3 decimal millisecond fields..
only the episode on 12/23 is different.. only offering VTT captions (no SRT), and the format being.. as described.
on the one hand, hopefully PBS will fix itself.
on the other hand, it illustrated a bug in ExoPlayer that should be easily fixed.
warren-bank commentedon Dec 24, 2024
quick update..
I can confirm that 6 digit millisecond fields in SRT files are also not parsed correctly..
experiencing slightly different behavior
to reproduce the sample SRT files, I performed the following steps to convert the VTT to SRT:
pbs-0.vtt)^(\d\d:\d\d:\d\d)\.(\d{6})(\s+-->\s+)(\d\d:\d\d:\d\d)\.(\d{6})$1\n$1,$2$3$4,$5pbs-0.srtpbs-0.srt)(,\d{3})\d{3}$1pbs-1.srtattachments:
warren-bank commentedon Dec 24, 2024
code trace for VTT
https://github.com/androidx/media/blob/1.5.1/libraries/extractor/src/main/java/androidx/media3/extractor/text/webvtt/WebvttCueParser.java#L200
https://github.com/androidx/media/blob/1.5.1/libraries/extractor/src/main/java/androidx/media3/extractor/text/webvtt/WebvttCueParser.java#L346-L349
https://github.com/androidx/media/blob/1.5.1/libraries/extractor/src/main/java/androidx/media3/extractor/text/webvtt/WebvttParserUtil.java#L67
fix for VTT
warren-bank commentedon Dec 24, 2024
code trace for SRT
https://github.com/androidx/media/blob/1.5.1/libraries/extractor/src/main/java/androidx/media3/extractor/text/subrip/SubripParser.java#L135-L142
https://github.com/androidx/media/blob/1.5.1/libraries/extractor/src/main/java/androidx/media3/extractor/text/subrip/SubripParser.java#L288-291
fix for SRT
icbaker commentedon Jan 2, 2025
This isn't a bug in the library, the media is invalid (and therefore any player behaviour is undefined), see further reasoning in #1999 (comment).
Restrict SubRip and WebVTT parsing to exactly 3 decimal places
icbaker commentedon Jan 7, 2025
The change linked above tightens ExoPlayer's parsing to completely ignore cues with more or less than 3 decimal places (rather than render them at an incorrect time).