Create an MLT File Containing Subtitles From a Subrip (.srt) File

A couple of years ago @KKnBB created a utility to do this, but the link no longer works. Also, several people couldn’t get it to work as it required Admin privileges to install, which they did not have, while several others said their anti-virus prevented it from running. Also, if you wanted a different font, you had to edit the resulting.mlt file.

So, since I am needing something like this I decided to create my own utility. I’ve done it as a web utility - it is a single HTML file and it has a nice interface (see below), where you can tailor all of the parameters. I will use it in conjuction with my web utility Subrip (.srt) Generator, that will create the .srt file and the new utility will hardcode (burn) the subtitles into the video.

If you atre interested in using these utitlities, the .srt file generator can be found here: SubRip SRT Subtitles Generator (elusien.co.uk) and the SRT to MLT converter can be found here: Resources for Shotcut (elusien.co.uk). Both utilities can be downloaded (they are each a single HTML file that you run in a browser) and run locally without needing access to the internet.

3 Likes

Thanks. :slightly_smiling_face:

Just a couple of things:

I think the first step of the instructions in the link above for the SRT to MLT converter is confusing:

  1. Finish your Shotcut project and export the complete video.

But as the rest of the instructions go, it’s the MLT project file that you need not the exported video of the project without the subtitles.

Another thing, I tested with a 4K video file and the size of the font for the subtitles in the web app didn’t reflect how it actually looked like in the 4K project when I brought it to Shotcut. They were much, much smaller.

Thanks for the feedback.

I will try to explain this better on the webpage. Yes it’s the project file I need for this web utility, but to create the subtitles in Aegisub, Subtitle Edit, or my utility you’ll in general need the exported video as these need to play the video as you add subtitles.

The display in the app is not proportional to the dimensions in the project, which is why I wote “similar to”. However, having thought about it, I can change the code to make it proportional, its just a bit fiddly with the font-size and padding.

@DRM OK, I have done the following:

When you start the web app the preview window is as it was before, not to scale and the subtitle text says:

Not to scale.

When you open the MLT file at this point I know what the width and height of your project is, so I change the subtitle text to say:

Not to scale. Click on this subtitle to use the project size (1920 x 1080)

When you click on the subtitle it blows the preview window up to the size of your project’s resolution and changes the subtitle text to:

Actual size. Click on this subtitle to use a smaller preview (592 x 410)

Of course the actual resolutions depend on your project and computer screen size.

P.S. the description webpage has been modified to make it clear that the video is not needed by my app, only by those apps used to synchronise subtitles with the video’s dialogue.

I;ve just corrected a minor error in the utility. Subtitles were being generated 66% too large!

Super Tool.
It should somehow be integrated into Shotcut.

Unfortunately, the result of my test is not perfect:

a) The font size changes depending on the length of the text line.
Long text line = Small text size
Short text line = Large text size

The text size should remain the same if possible, or alternatively an option button should be built into the tool.

b) What should also be changed:
If you have changed the text of an existing .srt (e.g. line width, or text), this .srt cannot be loaded separately into the tool.
The tool has to be completely reloaded and therefore everything has to be started from the beginning.

This is not supposed to happen and does not happen for me. I have the filter parameter setting:

<property name="shotcut:usePointSize">1</property>

which is designed to prevent this. Could you post your SRT MLT file, so I could try to debug it?

Here it is:
Instagram 1-1 Badminton-Angel Einleitung und Längenerklärung Subtitles.mlt (11.2 KB)

To upload the .srt is not possible (upload error).

Cause my stream looks not good with the tool, i made the subrips with Text: Rich

The problem is that your lines are too long to fit on one line at the font-size you have chosen. Shotcut’s Text:Simple filter keeps the text the size that you specify until that text exceeds the width, then the filter decreases the size of the font so that the whole of the line of text fits within the width.

You need to split the long lines of text in your .srt file into 2 or more lines. e,g,

1
00:02:16,612 --> 00:02:19,376
This is a very long line of text that need to be split over several lines in the SRT file

becomes:

1
00:02:16,612 --> 00:02:19,376
This is a very long line of text
that need to be split over
several lines in the SRT file

Quite a few resources recommend that Subrip line lengths should be no longer than 50 characters.

If all you are doing is creating subtitles for videos that are to be uploaded to YouTube you should not burn the subtitles into the video. Instead, just upload the SRT file to the Youtube page of your video. You can upload several SRT files in different languages this way too. Just login to you YouTube channel and navigate to the YouTube Creator Studio. Then click on “Subtitles” in the right menu.
Also see here:

For instructions on how to do this for Instagram see here Redirecting...