sandflow / ttconv

Subtitle conversion. Converts STL, SRT, TTML and SCC into TTML, WebVTT and SRT.
BSD 2-Clause "Simplified" License
181 stars 22 forks source link

Is WebVTT support planned? #249

Closed davemevans closed 2 years ago

davemevans commented 3 years ago

Do you have support for WebVTT output on your roadmap? If so, do you have a totally non-committal date when it might be expected to land?

Thanks for building such an awesome tool!

palemieux commented 3 years ago

Do you have support for WebVTT output on your roadmap?

Not so far. Contributions/support are welcome.

In any event, it will be essential to specify which flavor(s) of WebVTT to support, e.g. level of styling, region support, etc.

Converting the current SRT output to a WebVTT-compatible output should be trivial. Is that sufficient?

davemevans commented 3 years ago

Ok, thanks for the update.

Agreed that manipulating the SRT would probably give a passable result. I will also take a look to try to understand what would be required to add more support.

Understood on the flavour - I guess some clients will not support STYLE blocks and would prefer inline styling, and probably even less will support REGION.

palemieux commented 3 years ago

https://github.com/silviapfeiffer/silviapfeiffer.github.io/blob/master/index.html seems to provide an algorithm to convert SRT to WebVTT. Would that work? If so, it could easily added.

davemevans commented 3 years ago

Apologies for the delayed response.

I think that algorithm is ok but I'm not convinced the inline styling that might remain makes a lot of sense, and of course it would not have any positioning information

To be honest, I think the minimum that would be required for meaningful use would be STYLE blocks and cue settings (as opposed to full REGION support)

I took a look at how this might be added today. I am currently struggling to understand the internal model to be honest but, that aside, I don't think it would be too hard to add these features - I have managed to get unstyled VTT out with not too much hackery.

palemieux commented 3 years ago

Ok. Let me know if/how I can help.

I am currently struggling to understand the internal model to be honest

I would duplicate src/python/ttconv/srt to get started. DM me if you would like to chat over zoom. I have also created a discord channel at https://discord.gg/pgykPWGhd4

palemieux commented 2 years ago

@davemevans Did you ever have a chance to work on a WebVTT writer?

@xchange11 This thread might be of interest.

davemevans commented 2 years ago

@palemieux Apologies for the lack of updates. I was able to get basic VTT out as suggested above, but was unable to spend the time getting translation of styling into something usable, and I am not currently able to spend any time on this. Sorry to have got hopes up!

xchange11 commented 2 years ago

@davemevans @palemieux The least that should be supported are colors as they are used in many countries to identify the speaker. WebVTT defines default classes for colors (section 5.1. Default text colors and section 5.2 Default test background colors). To be on the safe side an "internal stylesheet" should be added that matches the class names, e.g. for the text colors:

::cue(.white) {
    color: #ffffff;
}
::cue(.lime) {
    color: #00ff00;
}
::cue(.cyan) {
    color: #00ffff;
}
::cue(.red) {
    color: #ff0000;
}
::cue(.yellow) {
    color: #ffff00;
}
::cue(.magenta) {
    color: #ff00ff;
}
::cue(.blue) {
    color: #0000ff;
}
::cue(.black) {
    color: #000000;
}

It makes also sense to add some defaults for font characteristics e.g.:

 ::cue {
    font-family: Verdana, Arial, Tiresias;
    line-height: 125%;
}

(Values taken from the WebVTT implementation of the SCF)

If alignment and vertical positioning are not implemented all WebVTT subs could have the common defaults of bottom-centered subtitles.