Page 1 of 1

Lord of the Rings fan cut and Resolve transition scripting

PostPosted: Thu May 01, 2025 3:19 pm
by cjl4hd
Hi everyone! I'm new to the forum and have a script I would like to share! I'm working on an open source fan cut of Lord of the Rings that cuts out violence and scary scenes so that kids at a younger age can still enjoy the trilogy. Its written as a script with input options to cut the movie based on how much violence and scary scenes you want to filter out. This allows you to make your own cut that filters less as your child grows!

One challenge of this has been keeping the scene transitions feeling natural while making cuts with the script. Audio transitions get us most of the way there, but Resolve doesn't natively support audio transitions in scripting. I've gotten around this in Python by importing the keyboard library and automating keyboard shortcuts to add cross fading in the timeline.

I wanted to share this in case its useful to anyone else, and also get feedback on how it can be improved!

Its not 100% reliable, as it makes assumptions about edit point that may not be true. It also doesn't have any way to check key press success, so we just wait 200ms and its consistently been enough for me. Knowing all of this, I still definitely prefer it over nothing.

Link to Lord of the Rings cut Github project page with the transition insertion: github /cjl4hd/Lord-Of-The-Rings-Lukas-Cut

Example function calls if you don't want to follow the link:
Code: Select all
#setup code
import keyboard
import time

#editPointStatus tracks the edit point orientation. -1=left, 0=center, 1=right
#assume we've freshly loaded resolve and edit point is in the center
editPointStatus = 0

#This function changes the orientation of the edit point,
#allowing audio transitions at the beginning, midpoint, and end
def setEditPoint(newPoint):
    global editPointStatus
    loopCount = 0
    while ((editPointStatus != newPoint) and loopCount<3):
        loopCount = loopCount + 1
        if loopCount == 3:
            print("Error: setEditPoint failure")
            print(editPointStatus)
            print(newPoint)
        keyboard.send("u")#change edit point orientation
        time.sleep(0.2)
        if editPointStatus == 0:
            editPointStatus = 1
        elif editPointStatus == 1:
            editPointStatus = -1
        elif editPointStatus == -1:
            editPointStatus = 0

#This function adds the audio transition into the timeline at the beginning of the last clip
def addAudioTransition(editPoint):
    global generated_timeline
    #add some delay between keypresses to give DR time to do the action. 0.2s works well on my laptop
    sleep_time = 0.2
    time.sleep(sleep_time)
    keyboard.send('ctrl+4')#focus on timeline
    time.sleep(sleep_time)
    keyboard.send('end')#go to end of timeline
    time.sleep(sleep_time)
    keyboard.send('up')#lets go back to the beginning of the most recently added clip
    time.sleep(sleep_time)
    keyboard.send('v')#select nearest edit point
    time.sleep(sleep_time)
    setEditPoint(editPoint)#modify which side of edit point we'll add the transition
    time.sleep(sleep_time)
    keyboard.send("shift+t")
    keyboard.send('end')
    time.sleep(sleep_time)