zezo010 / Elgindy-VTT-to-SRT-Subtitle-Converter

A tool for converting Web Video Text Tracks Format (WebVTT) subtitle to srt one. As most of video players support srt subtitles and can't open vtt subtitles, We should convert vtt to srt or sub subtitles but it's not easy to do that.
90 stars 14 forks source link

Timestamp not converted correctly #8

Open LiohMoeller opened 3 years ago

LiohMoeller commented 3 years ago

It appears that in a segmented VTT the timestamp is indicated by the MPEGTS value, which is offset by 1 second (90000). The correct start time (in seconds) could therefore be calculated by dividing the MPEG-TS by 90000, less one. Elgindy-VTT-to-SRT-Subtitle-Converter seems to use the local time, which in a segmented WebVTT is always zero.

WEBVTT
X-TIMESTAMP-MAP=MPEGTS:900000,LOCAL:00:00:00.000

WEBVTT
X-TIMESTAMP-MAP=MPEGTS:13204800,LOCAL:00:00:00.000

1
00:00:00.000 --> 00:00:03.440
<i>First Sentence.</i>

WEBVTT
X-TIMESTAMP-MAP=MPEGTS:13514400,LOCAL:00:00:00.000

2
00:00:01.480 --> 00:00:03.560
<i>Second Sentence.</i>
zezo010 commented 2 years ago

Elgindy VTT uses the same time in the vtt file then convert it and save it in srt file. But MPEGTS time needs specific converting.