cdown / srt

A simple library and set of tools for parsing, modifying, and composing SRT files.
MIT License
465 stars 44 forks source link

WebVTT and microseconds format #66

Closed Smolky closed 3 years ago

Smolky commented 3 years ago

Hi. First of all, thanks very much for this tool. I found it quite useful

I am trying to use it to create subtitles compatibles with WEBVTT

Some of the adaptations needed to create the WebVTT are easy for me. For example, I could attach esaly the voices in the cues prepending <v speaker_1> or by including the WEBVTT header at top of the file.

Howerver, according to this example: https://developer.mozilla.org/en-US/docs/Web/API/WebVTT_API

Subtitles have some form of:

WEBVTT

00:01.000 --> 00:04.000
- Never drink liquid nitrogen.

00:05.000 --> 00:09.000
- It will perforate your stomach.
- You could die.

As you can notice, microseconds are displayed with dots "." rather than commas ",". However, I notice that the "comma" is hardcode in the code so it is not easy for me to change it. I suposse that I could parse the file after generated and change it by using regular expressions.

Does it makes sense to make the timedelta format parametrizable?

cdown commented 3 years ago

Hey! Looking at that document, I suspect supporting VTT would entail inviting compatibility changes of unknown scope. Unless it's demonstrable that these are the only changes that will ever be needed, I'm inclined to suggest just using ffmpeg to change it:

ffmpeg -i x.srt x.vtt
cdown commented 3 years ago

I'm going to close this for now on that basis, but let me know if there's anything else I can help with.

Smolky commented 3 years ago

No problem. I'll give it a try to ffmpeg

Kind regards and thanks for your time