Python Script to extend clips with still frames

Ask software engineering and SDK questions for developers working on Mac OS X, Windows or Linux.
  • Author
  • Message
Offline

CharlesSimon

  • Posts: 2
  • Joined: Mon Sep 02, 2024 4:33 pm
  • Real Name: Charles Simon

Python Script to extend clips with still frames

PostTue Sep 03, 2024 3:20 pm

I am an experienced programmer but new to Blackmagic API.

In Resolve, it would be nice to have a function to automatically extend the last (or first) frame of a clip as a still. I can do this in about 10 clicks but I do it a lot. ChatGPT shows this as ~20 lines of python.

1. Is there a repository of existing python routines where I can check to see if anyone has already written such a script?
2. Is there a URL which describes how to create a python script which works on Resolve? I have followed the directions from ChatGPT but the script does not appear in the Workspaces scripts menu.
3. Is this a reasonable thing to do or am I working in the wrong direction?

Thanks for any input.
Charles
Offline

francisqureshi

  • Posts: 18
  • Joined: Wed Dec 23, 2020 2:49 pm
  • Real Name: Francis Qureshi

Re: Python Script to extend clips with still frames

PostWed Sep 04, 2024 6:03 pm

Hey Charles,

In Resolve, on the Menubar, go to Help > Documentation > Developer

It will open files/explorer/finder window to the Resolve Developer folder, then go to Scripting and check out the readme.txt this has all the API calls you can use and documents how to set up paths etc. Also in the /examples folder are some scripts to get you started!

I wish there was something like what you have described, there are few things around this forum like Roger's thread:

viewtopic.php?f=21&t=175315&p=920798#p920414

Getting the last frame of a shot is something I've been wanting to properly figure out for a long time... its weirdly hard to do even with a fairly large API... and it gets very complicated if the shot is retimed...

But for what you are trying to do, it could be easier to script your keyboard actions with something like AutoHotkey or Keyboard Maestro... I would do:

1. Press ; or ' key to go to first or end frame of the current shot
2. Go 1 frame fwd or back via left/right arrow key
3. ctrl/cmd + B to cut/razor
4. Move to newly cut frame left/right x1
5. Shift + R to freeze frame (I think that's a standard keyboard shortcut?)

6. Pull the freeze-framed shot out to its desired length with mouse

I think you could script/make steps 1-5 in AHK or KBM fairly painlessly...
System:
Intel 14900K | RTX 4090 24GB | Asus z790 ProArt | Mellanox CX6 | Ultrastudio 4k Mini TB3 | Rocky 9.4
Offline

CharlesSimon

  • Posts: 2
  • Joined: Mon Sep 02, 2024 4:33 pm
  • Real Name: Charles Simon

Re: Python Script to extend clips with still frames

PostWed Sep 04, 2024 7:00 pm

Thanks FrancisQ... I'll check out your suggestions.

BTW, ChatGPT says to grab the last frame in python with (I have no idea if this is correct):

# Get the end frame of the selected clip
clip_end_frame = selected_clip.GetEnd()

# Go to the last frame of the selected clip
timeline.SetCurrentTimecode(clip_end_frame)

# Grab a still from the last frame
media_pool = resolve.GetMediaPool()
gallery = resolve.OpenFusionPage().GetGallery()
still = gallery.GrabStill()

Return to Software Developers

Who is online

Users browsing this forum: No registered users and 6 guests