Script Request: Merging Video and Subtitle Files

Currenty there is no way to add subtitles to videos on DEVONthink.

But I figured out that there is a way to soft encode subtitles to videos via terminal. Source: HRH George J Rickle IV's answer to What is the best free (no watermark) subtitle adding software? - Quora

In short, I should run following command after replacing X,Y and Zs according to instructions:

ffmpeg -i XXXX.mp4 -i -c copy -c:s mov_text ZZZZ.mp4

XXXX: mp4 name
YYYY: srt name
ZZZZ: output mp4 name (since DT allows files with same names in a group, my preference is making this same as original mp4 name, ie XXXX)

The problem is, I have hundreds of video-subtitle pairs, and running this code manually would take enormous time.

It would be great if I select a pair of video and subtitle files and run a script via toolbar, and see output file in the same group. Can someone please share the script or lead me through the way how a AppleScript novice like me can achieve this?

Currenty there is no way to add subtitles to videos on DEVONthink.

This is beyond the scope of DEVONthink and the first request I’ve ever seen.

Regarding the script: Do you have a link to a video and also can you compress and upload the .srt file for it?

Thanks for the reply.

I’ve both video and srt files on my database. They are part of a paid course, so I believe there will be copyright issue if I upload them in here.

They are just regular video and srt files. Do you still need to access them? If so, I can email it to you.


I will see if I can hunt down some examples that wouldn’t violate any copyright. Thanks.

A looping shell script ?

1 Like

If XXXX and YYYY are different, how would the script know which subtitle file matches which movie?

Also, you don’t mention whether the ffmpeg command actually works for any of your files.

I thought script would know which is which if I select both files simultaneously, is it not possible?

Yes, I tried and it works perfectly.

Yes, it could be done if you were manually selecting both files but you mentioned having hundreds to process, which would slow the process obviously.

Yes you are right, but it is still much more faster than the alternative, which is typing to terminal manually.

If there was some unique connection between each of the paired files (e.g. both in the same sub-folder, same name but different extension, etc…) then automation could process them in a batch. (As an aside, if the names were identical then many players would automatically play the subtitle.)

Or even a unique number… for example, if you grab a batch of videos and rename them by prepending a 3-digit number, then grab the matching set of subtitles in the same order and do the same, then it would be simple to match them in a script.