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

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.
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.


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:

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

send, !{right}
loop, 4 {
send, ^c
loop, 10 {
send, {PgDn}
send, b
sleep, 1000
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!

No, I have not seen this post. I will definitely check it out. All of this is so cool!

Made a slight modification to my original script after looking at Master JonRay’s script.

SetKeyDelay, 200
^M:: ; This sets CTRL + M as the “hotkey” (trigger).
send, !{right} ; sends playhead to the right edge of the clip
Loop, 5 ; number of iterations

send, ^c ; Copies the clip.

;send, ^+{PgDn} ; Ctrl+Shift+Page Down to advance playhead 10 seconds.

send, {PgDn 4}{right 5} ;PgDn 4X right 5x

send, ^v ; Pastes the clip.

sleep, 200
send, !{left} ; After the loop ends, sends playhead to the left edge of the clip.

The send !{left} before the return puts the PH at the left edge of the last clip. If the loop needs to be repeated the PH will be positioned correctly.

1 Like

I am so geeked Sauron. After playing around with your script a bit I finally got the end result that I was seeking!!! Initially I ran into issues when I ran the script because I had an unnecessary color clip on track V2 which affected how much space I had to paste my 100 clips (I had placed this here when I was attempting a different solution). The clips started overlapping and Shotcut got hosed up and stop responding. I end up exiting out of the script, exiting out of shotcut, then restarting shotcut to start over. I made sure to remove the unnecessary color clip from the end of track V2, I already had a long video clip on track V1 so I was set in that regard. Then I reran the script and viola it worked! I sat in watched in awe as my computer pasted all 100 clips in a matter of a few minutes! I am so excited! I am also grateful to you for all your help. I really could not have accomplished this without you. Next I am going to play round with Jonray’s script and see what I can learn from it. I think it is so cool that there is more than one way to write a script to perform a repetitive action. I am really diggin this. Now I want to script all the things! LOL! :laughing:

Right on! This awesome. I will study this script as well because I need all the help I can get to learn how to write good scripts. And again, I think it is so cool how many different ways a script can be written to perform the same action. Love it! :+1::+1::+1:

I am so happy I ran into your Youtube video! This video has started something and now I want to script all the things!!! :heart_eyes:

1 Like

Your enthusiasm is infectious, @treuben !! You might like to take a look at the two threads below for more uses of AHK/Shotcut. Also search this forum (magnifying glass, top right) for “autohot key”…

1 Like

I definitely will Jonray. Thank you! :smile:

My pleasure! :smiley:

Hi Sauron,

I tried out this script to see how it would go and it is not working right for me.

This script has the playhead being advance 10 seconds (in line 9) and 4.2 seconds (line 11).

When I first posted my question asking for a script that would copy a clip, advance 10 seconds, then paste another clip, all looped a certain number of times, I just threw out 10 seconds as a random number.

Then I tried to be more specific with my request by stating that I actually needed a script that would copy my clip, advance the playhead 4.2 seconds, paste it, all for x number of times.

This script, appears to me to combine both these different scenarios unnecessarily, unless I am reading and understanding this script incorrectly.

When I ran it all it did was copy and paste my clip, back to back, 5 times, at the very end of track V1.

I tried to modify the script by deleting out line 9 ( ;send, ^+{PgDn} ; Ctrl+Shift+Page Down to advance playhead 10 seconds), because this was just a throw away example I gave when I initially posted the question. What I actually wanted to be able to select my clip, copy it, advance the playhead 4 seconds ( or 2 seconds, or 4.5 seconds, or whatever number of seconds I require) then paste it again for x amount of times, (which is line 11).

How would this script be written so that a clip would first be copied, then the playhead advanced a certain amount of time ( ex: 10 seconds, or 4 seconds, or 4.2 seconds), then pasted, for 5 iterations?

I tried to modify it by deleting out line 9 and it simply did not work.

Thanks again for all your help. I really am learning alot with all this!

The script should have worked with no modification.:confused:

The semi-colon that I put at the beginning of the line that advances the clip 10 seconds should disable that line. Here’s the working script. I removed that line. If you need to change the duration of the gap between clips modify line 12.
When the script ends, the PH is moved to the left edge of the last clip. If the loop needs to be repeated the clips won’t get pasted back to back at the end of the timeline.

Copy Paste.ahk.txt (418 Bytes)

When using the modified script the clip should be selected and the PH needs to be on the clip but not at the end of the clip.


OMG Sauron! I think you uncovered my error with your original script. I was selecting the clip, then hitting alt + right arrow to send the playhead to the right edge of the the clip, then I hit control M. I did not know I was not supposed to do that. So I am going to retry both your original modified script and your new modified script and see what happens.

Thank you for being patient with me and taking the time to help me out all this. I am really grateful.

I am so frustrated right now. Not one of these scripts is working for me correctly. The script that Sauron wrote the very first time worked for me once, which was awesome. Now I am trying to create another video using different clips and now none of the clips are pasting right. Not Sauron’s scripts or Jonray’s scripts. I tried all of them. I don’t know what is going on. I have done everything. I started the project over at least a dozen times. From scratch. Scripts didn’t work correctly. I shut my computer all the way down, reloaded Shotcut, and started my project again from scratch. No go. I switched from using the latest version of Shotcut back down to an older version Shotcut. No go. I attempted to use the scripts as written, to see if maybe my tinkering with scripts is the reason for them not working. Nope. Still didn’t work right. I tried using other video clips. No go. I closed out of all other running programs and documents and made sure only Shotcut, Notepad and this here webpage were running. Still could not get any of these scripts to behave correctly. Running the scripts results in the clips being pasted in the wrong position or not at all. I am trying everything to get them to run correctly and they just wont. I dont understand why. Sauron’s very first script he wrote up worked for me the other day so I don’t know what gives. My laptop is old, but not that old. Its going on 4 years old I believe. Maybe it is my laptop. I dont know, but it could be Shotcut itself because one issue I have with it is it is laggy as all get out. Or it will completely crash. I do like the software, but it has not been easy for me to use. The lag is bad. I dont know if this is Shotcut or my computer. I don’t know if this lag is what is causing the scripts to not run right any more. I am so frustrated right now. It’s like I don’t want to go bed until I fix what ever this issue is because I really need this script to work right again. I am going to keep playing around with it. Man I am sad and frustrated :frowning:

Hi @treuben ! Poor you! I just ran @sauron’s modified script and it works fine. I can’t be here to help for a while now because I’m off to work but just wanted you to know it works Ok for me. Hope that may help a little. Good luck…