Menu

I wrote an SRT-to-WebVTT converter in ~35 lines because players lie about subtitle support
📰

I wrote an SRT-to-WebVTT converter in ~35 lines because players lie about subtitle support

DEV Community: android·hammi·1 day ago
#MlGxZMAg
#devtoandroid#devto#dev#lines#webvtt
Reading 0:00
15s threshold

i'm building RKMovies , a 0.91 MB Android media client. the streams come with subtitle files, and the internet almost always hands you SRT. the problem: the <video> element only renders WebVTT properly, and SRT is not WebVTT.

the differences that actually bite:

timestamps. SRT uses 00:00:01,000 . WebVTT demands 00:00:01.000 . one comma and the whole cue silently disappears.

cue indexes. SRT blocks start with a numeric counter line. WebVTT treats that as a cue id, which is fine, but sloppy files skip or repeat numbers.

markup. SRT files carry HTML-ish tags ( <i> , <font color=...> ) and ASS override tags ( {\an8} , {\pos(...)} ). browsers render some of it, choke on the rest, and the override tags show up as literal text.

BOM and \r\n .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.