Instant Subtitles! (Creating subtitles automatically as if by magic)

Hi folks,
I thought of a way of automating a process in Shotcut whereby you can create a whole series of subtitle clips (or any text) just by pressing a couple of keys (“hotkeys”) to start the process.

The method uses Shotcut in conjunction with AutoHotKey, a free keyboard macro program.

It’ a little complex to explain, (but well worth it when you get it going), so I just made this tutorial video and put it on Youtube:

It works by running a short AutoHotKey script. Try it out yourself - the script is here. It’s a .txt file, so you’ll need to change the extension to .ahk once downloaded:

INSTANT LYRICS SUBTITLES script (by Jonray).txt (524 Bytes)

I’ve also uploaded the AHK file to GoogleDrive:

Please let me know what you think! And also if I’ve made any glaring errors in my tutorial video…

4 Likes

Fantastic work.
I use to add Lyrics to a song within the Rocksmith 2014 game, the Ultrastar Song Creator software.
I never knew if the result obtained in Ultrastar could be implemented in Shotcut.

Ultrastar creator

That’s nice. Can someone add a video here that was created using this technique?

Video made with @jonray’s “instant subtitles” technique.


https://streamable.com/j1zc9

Took little over 30 minutes to make.

Modifying the AHK script to work with my layout took a while. Once it was running, worked like a charm.

This script works with AHK to keep notepad or any other application on top.

On Top.ahk.txt (59 Bytes)

Keyboard shortcut is Ctrl + Shift + Space.

2 Likes

Fantastic! Great video, I’ve been hip-hopping around to this all morning - and singing along… Not pretty…:smile::smile:

@sauron, thanks for trying it out - I was hoping for someone to test it.

Did you just have to change the mouse positions? Did the keyboard shortcuts all work for you OK?

That’s ingenious - I never thought of doing it with another AHK script. Thank you.

Just an aside - how did you make the Ctrl Shift and Space icons come out with the grey boundary boxes in your post above? Looks cool…

Only the mouse positions. The shortcuts worked fine.

I use a virtual desktop application that has an always keep on top function. Searched for a way to keep windows on top found the AHK script here.

Copied and pasted from this page.

Thanks @sauron, some useful tips there.

I had fun making this little tutorial video yesterday and today - @sauron and @elusien (plus a few others) may remember the “ALIEN SONG” clip which was featured in a thread about 2 years ago (!) (when discussing @elusien’s subtitle generator)…

https://streamable.com/nxkog

If you haven’t seen the Alien Song video, it’s so funny…

2 Likes

surround each word with <kbd></kbd> Here is a silly example. More work than needed in my opinion, but I might start using it in the documentation.

1 Like

Thanks @shotcut. Cool! Just wondering if there is a list somewhere of all the tags which can format the text on this forum, apart from the usual bold, italic, lists?

See here for a definitive list of all HTML tags, including those for formatting:

https://www.w3schools.com/tags/ref_byfunc.asp

e.g.

<del> STRIKEOUT
<h1>

HEADING


<sub> subscript
<sup> superscript
1 Like

Thanks @elusien and @shotcut. Helpful as ever :+1:

Hello, Jonray,

I am currently attempting to try out your script for myself. But I am struggling with something. I don’t wish to actually paste multiple subtitles. I have already create a clip in Shotcut with the subtitle I want on it. Now, I would like to modify this script to just do the following: Copy the selected clip, move to the right of the selected clip a certain amount of time (lets say 10 seconds for example), and then paste. So in essence I would like this script to paste this one selected clip repeatedly, with each clip being 10 seconds apart, for however many times. I have been scouring the web and numerous Youtube videos for two days now, doing follow alongs and what not, trying to figure out for myself how to correctly write this but I can’t figure it out. Would you help me please? Thank you.

I made an AHK script that will do what you want.
For the script to work property you will need to add a long color clip on a track below the clip you want to duplicate.
image
Before you run the script, select the clip, and put the play head at the end of the clip with Alt+right arrow.
Run the script. The clip will be copied. Play head will advance 10 seconds, then the clip will be pasted. The loop is set to 5 iterations. The Hotkey is Ctrl M.

image

If there is no clip below the clip you want to duplicate, the script will work but there will be not be a 10 second gap between the clips.

Copy Paste.ahk.txt (292 Bytes)

1 Like

Oh man!!! Thank you so much Sauron!!! This works perfectly. The way I tried to modify Jonray’s script was way off and did not work at all. It is very clear I have ALOT to learn about how to write scripts, but I am slowly learning.

Another quick question…

Pressing 'Ctrl+Shift+Page Down advances the playhead 10 seconds. This was just an random time I selected for the sake of the asking the question.

So my question is…

If I wanted to change the amount of time the playhead advances how do I modify the script to do that? Let’s say I wanted to advance the playhead intricately like 4.2 seconds, How would I do that?

If I was to do this manually in Shotcut I would put the play head at the end of the clip with Alt + right arrow, then press the right arrow over 4.2 seconds to paste the next clip. How do I write a script for this? Or is there a better way?

Thank you again for all your help. I am so excited to be learning how to write my own scripts!

To do that you need to change the code on line 10 to:

send, {PgDn 4}{right 5} this sends PgDn 4 times to move the PH forward 4 seconds, then sends Right arrow 5 times to move the PH 5 frames which equals 0.2 when the video frame rate is 25 fps.

These scripts are useful for automating repetitive tasks. Like splitting a clip 100 times every 2 seconds.

Look at Shotcut keyboard shortcuts.

The AHK quick reference is where you can learn more about scripting…

1 Like

Thank you for this Sauron! I have actually been on AHK quick reference page all day today going through reading and recreating the example scripts myself trying to teach myself how to write scripts. It’s alot. It is like I know what I want the script to do, but finding the information that will help me write it up has been a challenge.

It is crazy. Up until a few days ago I didn’t even know what scripting was. Then one day I decided I wanted to make a meditation video that flashed a word of my choosing over and over for a select number of times. I started making this video in shot cut, but then I got stuck because I didn’t want to manually copy and paste one clip 100 times. I knew there had to be an easier way. My research led me to Jonray’s video. When I first watched this video I was like there is no way I can do that. But the thought of trying to cut and paste a video clip 4.2 seconds apart 100 times, made me reconsider learning this scripting thing. And that is what I have been doing for the last 2 or 3 days. Reading, watching youtube, videos, copying and running scripts. Finding out that scripting can be used to automate repetitive tasks like the one I was trying to do was just a God send. Now I want learn and do more. But for now I can’t wait to finish my video. Thank you so very much for helping me with the scripts for my project and for providing the link to the Shotcut keyboard shortcuts. I see how you incorporated the shortcuts into the scripts you wrote. I plan on playing around with some more and see what I can make happen. Okay then. Thanks again Sauron. You rock!

Hi @treuben, I reading your post with interest! I was otherwise engaged today so didn’t see your post earlier. Thanks to @sauron for stepping in with an excellent reply.

(Yes, @sauron does, indeed, ROCK ! :smiley::+1:.)

I created a very similar script to sauron’s . They are actually two scripts, one triggered by CTRL+J, the other triggered by CTRL+Q. I used the “loop” feature to press Page Down 10 times. The second (CTRL+Q) has “loop, 4” , which encloses the script which repeats the whole process 4 times. Sauron’s answer is a little simpler than mine but I’ posting it so you might like to analyse what’s going on. Begin by selecting the clip and making sure the playhead intersects it.
Here’s the script:

SetKeyDelay,200
 ^j::
 send, !{right}   ; sends playhead to the right edge of the clip
send, ^c
loop, 10 {
send, {PgDn}
}
send, b
return

^q::
send, !{right}
loop, 4 {
send, ^c
loop, 10 {
send, {PgDn}
}
send, b
sleep, 1000
}
return
1 Like

PS @treuben I presume you also saw this post?

1 Like

Thank you for this Jonray! I will definitely give this a go. If I run into any problems or have any questions I will definitely let you know! Thanks again!