Conversion script between the TTML & SRT subtitle formats. This is particularly useful with Adobe Premiere, as it doesn't understand the SRT format (which is joyously simple and interoperable). TTML-XML is probably the most straightforward subtitle format it does understand, hence this tool.
Note that due to the simplicity of the SRT format, this conversion is extremely lossy for all the bells and whistles supported by TTML. Not like you'd want fixed-pixel font sizes etc in your subtitles anyway, but you've been warned.
- Install Node.js
- Install libxmljs somewhere where
node
can find it (if you don't know what this means, consider installing globally withnpm install -g libxmljs
) - Run
node premiere-subtitle-convert.js path/to/inputfile.xml > path/to/outputfile.srt
(or the other way around with the file types) - Profit
This basically just shell wizardry, but for completeness, here's how one could accomplish the rather common scenario where a bunch of files need to be converted in one go:
ls "*.xml" | while read f
do
node /path/to/premiere-subtitle-convert.js "$f" > "$(echo $f | sed s/.xml/.srt/)"
done
This also properly handles white-spaces in file names.
License: MIT
@jareware Thank you so so much for this useful script. You save my life! Thanks!
It works perfectly for the captions from MVA.