Convert WebVTT file to SRT format (VTT to SRT)

Lately, I have been creating lots of how-to videos for my colleagues at work.  I like to include subtitles since some people may prefer to read the words I am saying.  We use Microsoft Stream to host the videos since it is part of our Office 365 subscription.

One of the great things about Microsoft Stream is that it will automatically generate captions (subtitles) from the audio in the video file.  You can edit the captions right in the web interface as you watch the video.  Microsoft did a great job on this user experience.

Today, I needed to burn the subtitles into the video because of limitations of the customers computers.    Handbrake does this well, but it does not understand the WebVTT format.  There are several online converters, but I do not like giving my content to unknown internet services, so I starting learning about the difference between the formats.  JBI Studios have a very helpful explanation about the differences.  I was able to use it to develop the commands to do the conversion in my favorite text editor, vim.  See below for my process that is specifically for the VTT files produced by Microsoft Stream.

Change the delimiter for microseconds from period to comma

:%smagic/\(\d\d:\d\d\).\(\d\+\) --> \(.*\)\(\d\d\)\.\(\d\+\)/\1,\2 --> \3\4,\5/

Replace Stream's identifiers with index numbers

:let t=[]  
:%s/^........-....-....-....-............$/\=len(add(t,1))/ 

Remove all the NOTE metadata lines

:g/\vNOTE/d

Remove header information

Just delete all the lines before index 1.

Save the file, and it is ready for use in Handbrake.

Comments

Popular posts from this blog

iChat IRC transport with OpenFire and Kraken

Save kerberos password in keychain for use with kinit on MacOS (was OS X) for use with network drives

Recording the iPhone screen and Mac screen at the same time in one video