Creating Scripts for DaVinci Resolve

Get answers to your questions about color grading, editing and finishing with DaVinci Resolve.
  • Author
  • Message
Offline
User avatar

Igor Riđanović

  • Posts: 1596
  • Joined: Thu Jul 02, 2015 5:11 am
  • Location: Los Angeles, Calif.

Re: Creating Scripts for DaVinci Resolve

PostFri Apr 21, 2023 7:16 pm

I'm trying to remember how that worked. Did it move only the media associated with a timeline or a project? Did it relink to the media at the new location? I think both those are possible to achieve, although I'd have to test the relinking. I'm not sure that I ever attempted that.

Would Resolve Collect not work for you: https://www.niwa.nu/resolve-collect/
www.metafide.com - DaVinci Resolve™ Apps
Offline

jjsereday

  • Posts: 40
  • Joined: Thu May 26, 2022 8:58 am
  • Real Name: JJ Sereday

Re: Copy Timeline Clip Markers to Media Pool

PostMon Apr 24, 2023 1:44 am

Wow incredible to see this thread. Really hoping to see more functionality with the API!

I've been racking my brain trying to find/figure out how to convert used clips in a timeline into marker durations within the media pool.

its easy 2 step process manually but with hundreds of clips in a timeline, a script to do so would be life changing...
Offline

dahya.mistry

  • Posts: 67
  • Joined: Wed Mar 03, 2021 5:29 pm
  • Real Name: Dahya Mistry

Re: Creating Scripts for DaVinci Resolve

PostMon Apr 24, 2023 10:33 am

FYI in case people don't spot it:

Forum Suggestion: Add a DR Scripts Forum
https://forum.blackmagicdesign.com/viewtopic.php?f=21&t=180039
Offline
User avatar

roger.magnusson

  • Posts: 3398
  • Joined: Wed Sep 23, 2015 4:58 pm

Timeline Clips to Media Pool Duration Markers

PostMon Apr 24, 2023 11:06 am

A bit too much on my plate right now to make it a fully finished script. But this might get you started at least.

Code: Select all
local project = resolve:GetProjectManager():GetCurrentProject()
local timeline = project:GetCurrentTimeline()
local marker_colors = table.pack("Blue", "Cyan", "Green", "Yellow", "Red", "Pink", "Purple", "Fuchsia", "Rose", "Lavender", "Sky", "Mint", "Lemon", "Sand", "Cocoa", "Cream")

for track_index = 1, timeline:GetTrackCount("video") do
   local track_name = timeline:GetTrackName("video", track_index)

   for _, timeline_item in ipairs(timeline:GetItemListInTrack("video", track_index)) do
      local media_pool_item = timeline_item:GetMediaPoolItem()
      media_pool_item:AddMarker(timeline_item:GetLeftOffset(), marker_colors[(track_index - 1) % #marker_colors + 1], "Track: "..track_name, "", timeline_item:GetDuration())
   end
end


It's "dumb" in the sense that it doesn't clear existing media pool item markers, doesn't check if the same in point is used more than once (which will make it ignore that timeline clip) and it only looks at video, not audio.

One thing to note is that the visual out point of a marker isn't inclusive of the frame duration. So it will look like it's one frame short even though the numbers are correct. If you want to change it for some reason, just replace timeline_item:GetDuration() with timeline_item:GetDuration() + 1.
Offline

jjsereday

  • Posts: 40
  • Joined: Thu May 26, 2022 8:58 am
  • Real Name: JJ Sereday

Re: Creating Scripts for DaVinci Resolve

PostThu Apr 27, 2023 3:47 pm

Wow Roger thanks for this - even in it's raw form it works for my needs.

I tweaked it to also add markers for tracks 2 and so on, which is a great way to add specific labels to all the clips selected.

When pulling usable selects I keep them on track one and label the track "Selects" and move favorites to track 2 and label the track "Selects Favorites"

and after running the script the duration markers are applied with those titles :o

I feel like this has so much more potential for choosing marker colors and even labeling which timeline media is used until Blackmagic gives us that feature.
Offline

robgwilson

  • Posts: 7
  • Joined: Thu Mar 26, 2015 2:26 am

Re: Creating Scripts for DaVinci Resolve

PostThu Apr 27, 2023 6:27 pm

You know what script would be super helpful? If you could extract the Date Created metadata from the file and generate timecode off that for a file. I've got a camera card I just inherited that ran continuous timecode but I'm trying to make it TOD. Even if I could get it close, I could sync from there. Right now it's just a mess.
Offline
User avatar

Uli Plank

  • Posts: 21764
  • Joined: Fri Feb 08, 2013 2:48 am
  • Location: Germany and Indonesia

Re: Creating Scripts for DaVinci Resolve

PostFri Apr 28, 2023 12:26 am

Can't offer such a script, but there's external software offering just that, like EditReady.
Now that the cat #19 is out of the bag, test it as much as you can and use the subforum.

Studio 18.6.6, MacOS 13.6.6, 2017 iMac, 32 GB, Radeon Pro 580
MacBook M1 Pro, 16 GPU cores, 32 GB RAM and iPhone 15 Pro
Speed Editor, UltraStudio Monitor 3G
Offline
User avatar

roger.magnusson

  • Posts: 3398
  • Joined: Wed Sep 23, 2015 4:58 pm

Re: Creating Scripts for DaVinci Resolve

PostFri Apr 28, 2023 12:52 pm

That's an easy change for the "Set Timecode for Media Pool Clips" script. I have added a checkbox that lets you create timecode from the "Date Created" metadata field instead.

Image
Post: Set Timecode for Media Pool Clips [Download]
Offline
User avatar

iddos-l

  • Posts: 799
  • Joined: Sat Mar 30, 2019 7:55 pm
  • Real Name: iddo lahman

Re: Creating Scripts for DaVinci Resolve

PostThu May 18, 2023 2:25 pm

Can anyone confirm there is no method to get or set the TimelineItem speed? I'm trying to find all clips in a timeline that have a speed change but can't find any method in the API.
Offline
User avatar

Igor Riđanović

  • Posts: 1596
  • Joined: Thu Jul 02, 2015 5:11 am
  • Location: Los Angeles, Calif.

Re: Creating Scripts for DaVinci Resolve

PostFri May 19, 2023 5:46 pm

Last time I needed that maybe three years ago there wasn't one. I don't recall seeing it added. I think you can get enough information to calculate it yourself, but you can't calculate if there are keyframed speed ramps.
www.metafide.com - DaVinci Resolve™ Apps
Offline
User avatar

roger.magnusson

  • Posts: 3398
  • Joined: Wed Sep 23, 2015 4:58 pm

Re: Creating Scripts for DaVinci Resolve

PostTue May 23, 2023 10:22 am

If you export the timeline to an OpenTimelineIO file (a JSON file) in 18.5 Beta 3 or later, you can get both the clip speed and keyframes.

Code: Select all
local project = resolve:GetProjectManager():GetCurrentProject()
local timeline = project:GetCurrentTimeline()
timeline:Export([[D:\Temp\timeline.otio]], resolve.EXPORT_OTIO)
Offline
User avatar

Robert Niessner

  • Posts: 5024
  • Joined: Thu Feb 21, 2013 9:51 am
  • Location: Graz, Austria

Re: Creating Scripts for DaVinci Resolve

PostTue May 23, 2023 10:56 am

Resolve 18.5 Beta 2 has added those improvements to the scripting API:

• Scripting API support to create subtitles from timeline audio.
• Scripting API support to transcribe source clips.

Resolve 18.5 Beta 3 has added another few improvements to the scripting API:

• Scripting API support to trigger object mask tracking.
• Scripting API support to trigger stabilization.
• Scripting API support to invoke scene cut detection in timelines.
• Scripting API support to enable smart reframe for clips.
• Scripting API support to export current frame as still.
• Scripting API for adding subclips to the media pool.
• Scripting API support to export and import OpenTimelineIO files.
• Scripting API support to render PNG and JPEG image sequences.
Last edited by Robert Niessner on Tue May 23, 2023 1:27 pm, edited 1 time in total.
Saying "Thx for help!" is not a crime.
--------------------------------
Robert Niessner
LAUFBILDkommission
Graz / Austria
--------------------------------
Blackmagic Camera Blog (German):
http://laufbildkommission.wordpress.com

Read the blog in English via Google Translate:
http://tinyurl.com/pjf6a3m
Offline
User avatar

roger.magnusson

  • Posts: 3398
  • Joined: Wed Sep 23, 2015 4:58 pm

Re: Creating Scripts for DaVinci Resolve

PostTue May 23, 2023 11:15 am

Isn't it strange to have a Stabilize() function that doesn't allow you to set any of the stabilization parameters? I wonder what the use case is here.

They've added some useful functions to Timeline Items, but there's no way through the API to find out which items are selected on the timeline. So how would it be used?
Offline
User avatar

Robert Niessner

  • Posts: 5024
  • Joined: Thu Feb 21, 2013 9:51 am
  • Location: Graz, Austria

Re: Creating Scripts for DaVinci Resolve

PostTue May 23, 2023 11:33 am

roger.magnusson wrote:Isn't it strange to have a Stabilize() function that doesn't allow you to set any of the stabilization parameters? I wonder what the use case is here.


My guess is this is just a result of the new ability to do batch stabilization of selected clips. Hopefully this gets improved with parameter settings.
Saying "Thx for help!" is not a crime.
--------------------------------
Robert Niessner
LAUFBILDkommission
Graz / Austria
--------------------------------
Blackmagic Camera Blog (German):
http://laufbildkommission.wordpress.com

Read the blog in English via Google Translate:
http://tinyurl.com/pjf6a3m
Offline
User avatar

iddos-l

  • Posts: 799
  • Joined: Sat Mar 30, 2019 7:55 pm
  • Real Name: iddo lahman

Re: Creating Scripts for DaVinci Resolve

PostTue May 23, 2023 12:07 pm

roger.magnusson wrote:If you export the timeline to an OpenTimelineIO file (a JSON file) in 18.5 Beta 3 or later, you can get both the clip speed and keyframes.

Code: Select all
local project = resolve:GetProjectManager():GetCurrentProject()
local timeline = project:GetCurrentTimeline()
timeline:Export([[D:\Temp\timeline.otio]], resolve.EXPORT_OTIO)
Nice!
Thank you
Offline
User avatar

iddos-l

  • Posts: 799
  • Joined: Sat Mar 30, 2019 7:55 pm
  • Real Name: iddo lahman

Creating Scripts for DaVinci Resolve

PostTue May 23, 2023 12:08 pm

roger.magnusson wrote:They've added some useful functions to Timeline Items, but there's no way through the API to find out which items are selected on the timeline. So how would it be used?
I guess you can setup markers to flag the clips and then set the playhead to the timecode and get the timeline items that way.
Offline

GarryFrey

  • Posts: 2
  • Joined: Tue May 23, 2023 8:51 pm
  • Real Name: Garry Frey

Re: Creating Scripts for DaVinci Resolve

PostTue May 23, 2023 9:12 pm

Is there a program that supports regular expressions for writing code quickly?
Offline
User avatar

Igor Riđanović

  • Posts: 1596
  • Joined: Thu Jul 02, 2015 5:11 am
  • Location: Los Angeles, Calif.

Re: Creating Scripts for DaVinci Resolve

PostTue May 23, 2023 10:01 pm

roger.magnusson wrote:If you export the timeline to an OpenTimelineIO file (a JSON file) in 18.5 Beta 3 or later, you can get both the clip speed and keyframes.

Code: Select all
local project = resolve:GetProjectManager():GetCurrentProject()
local timeline = project:GetCurrentTimeline()
timeline:Export([[D:\Temp\timeline.otio]], resolve.EXPORT_OTIO)


That's a pretty decent workaround.
www.metafide.com - DaVinci Resolve™ Apps
Offline

Lucius Snow

  • Posts: 643
  • Joined: Sun Nov 24, 2013 1:19 pm

Re: Creating Scripts for DaVinci Resolve

PostWed May 24, 2023 5:00 pm

Scripting API support to render PNG

I wish this for so long! Anyone would develop the script?
Offline

Steve Swisz

  • Posts: 66
  • Joined: Tue Aug 11, 2015 1:51 am

Re: Creating Scripts for DaVinci Resolve

PostTue May 30, 2023 8:04 pm

Igor Riđanović wrote:I'm trying to remember how that worked. Did it move only the media associated with a timeline or a project? Did it relink to the media at the new location? I think both those are possible to achieve, although I'd have to test the relinking. I'm not sure that I ever attempted that.

Would Resolve Collect not work for you: https://www.niwa.nu/resolve-collect/



Thanks Igor I am going to play around with this!
Offline

4EvrYng

  • Posts: 652
  • Joined: Sat Feb 19, 2022 12:45 am
  • Warnings: 1
  • Real Name: Alexander Dali

Re: Creating Scripts for DaVinci Resolve

PostWed May 31, 2023 12:15 am

roger.magnusson wrote:Scripting is a great feature in DaVinci Resolve. With the exception of a few brave souls that have shared their scripts the forum isn't exactly overflowing with them so I thought I'd make a few contributions on the subject.

Thank you!!!
Offline

Dani Urdiales

  • Posts: 18
  • Joined: Mon Jan 13, 2020 6:57 pm
  • Real Name: Dani Urdiales

Re: Creating Scripts for DaVinci Resolve

PostThu Jun 01, 2023 8:48 pm

roger.magnusson wrote:Isn't it strange to have a Stabilize() function that doesn't allow you to set any of the stabilization parameters? I wonder what the use case is here.

They've added some useful functions to Timeline Items, but there's no way through the API to find out which items are selected on the timeline. So how would it be used?
Drx can save specific stabilizer parameters if i remember correctly.
So we could apply a dummy drx with the preferred parameters.

Enviado desde mi Mi 9 Lite mediante Tapatalk
Offline
User avatar

Robert Niessner

  • Posts: 5024
  • Joined: Thu Feb 21, 2013 9:51 am
  • Location: Graz, Austria

Re: Creating Scripts for DaVinci Resolve

PostThu Jun 15, 2023 11:19 am

Resolve 18.5 Beta 4 has added those improvements to the scripting API:

• Support to add, delete, enable and lock timeline tracks.
• Support to delete and link timeline clips.
• Support to specify target track and record frame to add clips to timeline.
• Support to specify record frame to create timeline from media pool clips.
Saying "Thx for help!" is not a crime.
--------------------------------
Robert Niessner
LAUFBILDkommission
Graz / Austria
--------------------------------
Blackmagic Camera Blog (German):
http://laufbildkommission.wordpress.com

Read the blog in English via Google Translate:
http://tinyurl.com/pjf6a3m
Offline
User avatar

roger.magnusson

  • Posts: 3398
  • Joined: Wed Sep 23, 2015 4:58 pm

Re: Creating Scripts for DaVinci Resolve

PostThu Jun 15, 2023 11:28 am

Those were available even before 18.5 but undocumented. They were removed in Beta 3. Thankfully they are now officially available and documented.
Offline
User avatar

Robert Niessner

  • Posts: 5024
  • Joined: Thu Feb 21, 2013 9:51 am
  • Location: Graz, Austria

Re: Creating Scripts for DaVinci Resolve

PostThu Jun 22, 2023 9:46 am

I got an idea for a hopefully useful script for many users:

The problem:
I have created lower third templates for different purposes, with two text+ inputs for "name" and "function". That works great, no problem.
But I have to fill in the inputs over and over again when having the same people in different projects.

It would be cool to have a script which reads from a text file all names and functions and let me select from a list for semi-auto fill in the lower thirds.

The text file could e.g. consist of something like this:

[groupname]
<first name> <last name>, <function>;
<first name> <last name>, <function>;
.
.
.
<first name> <last name>, <function>;
[/groupname]

Then if the lower third comp is selected start the script and get a drop down list with all groups to select one from and then the list of names (sorted by last name). If selected a name and hit enter you get the lower third's inputs populated.

It'd be cool if entering a character a-z (and special characters like umlaut or what ever other languages have) selection would jump in the list to that last name beginning with that character.

And make a checkbox for the name fill in order: <first name> <last name> or <last name> <first name>
Maybe another checkbox to make <last name> all caps optionally.

I have seen there is some groundwork already there in this thread:
https://www.steakunderwater.com/wesuckl ... 208#p12208

I have no idea if this would be a lot of coding work or if this could be done quite fast (for myself would need a long time because I would have to start learning scripting first again).

Looking forward what others think about this. Maybe this already exists, but I haven't found anything like that so far, but I can't be the only one wanting something like this to improve working with lower thirds and minimizing typing errors and such.
Saying "Thx for help!" is not a crime.
--------------------------------
Robert Niessner
LAUFBILDkommission
Graz / Austria
--------------------------------
Blackmagic Camera Blog (German):
http://laufbildkommission.wordpress.com

Read the blog in English via Google Translate:
http://tinyurl.com/pjf6a3m
Offline

alexfry

  • Posts: 7
  • Joined: Tue Apr 17, 2018 6:03 am
  • Real Name: Alex Fry

Re: Creating Scripts for DaVinci Resolve

PostFri Jul 28, 2023 1:01 am

@roger.magnusson

Do you (or anyone else here) have any working examples of basic UI windows and widgets being instatiated from python? (rather than lua)
Offline
User avatar

Robert Niessner

  • Posts: 5024
  • Joined: Thu Feb 21, 2013 9:51 am
  • Location: Graz, Austria

Re: Creating Scripts for DaVinci Resolve

PostThu Sep 14, 2023 6:49 pm

Resolve 18.6 has added those improvements to the scripting API:

• Scripting API support to import and export render and data burn presets.
• Scripting API support to import stills and list powergrades.
• Scripting API support for per-timeline Resolve Color Management.
Saying "Thx for help!" is not a crime.
--------------------------------
Robert Niessner
LAUFBILDkommission
Graz / Austria
--------------------------------
Blackmagic Camera Blog (German):
http://laufbildkommission.wordpress.com

Read the blog in English via Google Translate:
http://tinyurl.com/pjf6a3m
Offline
User avatar

Andrew Hazelden

  • Posts: 536
  • Joined: Sat Dec 06, 2014 12:10 pm
  • Location: West Dover, Nova Scotia, Canada

Re: Creating Scripts for DaVinci Resolve

PostFri Sep 15, 2023 2:28 am

alexfry wrote:Do you (or anyone else here) have any working examples of basic UI windows and widgets being instatiated from python?


Here is a collection of Python-based UI Manager GUI creation examples. It comes from the Reactor package manager's "UI Manager Examples" atom package.
Mac Studio M2 Ultra / Threadripper 3990X | Fusion Studio 18.6.4 | Kartaverse 6
Offline

im_gldn

  • Posts: 16
  • Joined: Wed May 19, 2021 5:56 am
  • Real Name: Lionel Golden

Re: Creating Scripts for DaVinci Resolve

PostMon Sep 18, 2023 4:49 am

Im amazed at how much work is being done here. Im not a programmer so ill ask for help here.

Since DR now has API support for creating sutbtitles from timeline audio. Is it possible to create a script the makes longer blocks of text. So instead of creating 60 characters per line max, to being able to put together a timed amount (say 5 minutes) of subtitles in one block.

My use case is this. I have a 8x 2 hour interviews that was subtitled. I converted the subtitle.SRT to Timeline Index and import back into resolve just so i can search using the INDEX. However the Timeline markers brings in about 2500 markers on average. Which immediatley bogs the system down making it unusable.

Possible solutions:
1. Create longer subtitle blocks that capture more text.
2. Have the ability to search subtitles (as is in DR) to filter and list by search, while still being able to move to timecoded area.

Thanks for the assitance in advance.
Offline

Andy Mees

  • Posts: 3259
  • Joined: Wed Aug 22, 2012 7:48 am

Re: Creating Scripts for DaVinci Resolve

PostWed Sep 20, 2023 9:08 pm

As BMD doesn't yet provide a built-in method to find / filter subtitle track contents...

Screenshot 2023-09-26 113951.jpg
Screenshot 2023-09-26 113951.jpg (31.94 KiB) Viewed 5049 times

Andy's Subvigator is a helper that displays the active timeline's subtitles (from a chosen subtitle track) together with a case-insensitve text filter for searching those subtitles. Selecting any subtitle/block in the Subvigator window moves the timeline playhead to the start of the corresponding subtitle/block (for editing the source in the timeline). Search options are Contains, Exact, Starts With, Ends With and Wildcard (using asterisks). Enabling the 'Dynamic search text' option will update the search results as you type... great if you don't have too many subtitles to filter, otherwise just press <Enter> or <Return> to trigger the search. The 'Combine Subs' option groups and navigates subtitles as blocks, the number of subtitles per block being the number you choose... useful when working with massive subtitle lists (it acts like a speed multiplier!) but note that, when used, navigational accuracy is effectively reduced by the same factor. If working in a Drop Frame timeline, enable the the 'DF navigation' option (functionality courtesy of Roger Magnusson's Libavutil code posted earlier in this thread).
Finally, the manual 'Refresh' button rebuilds the list to reflect any changes in the timeline.

[Save to your Scripts or Workflow Integration folder]

For the adventurous, apart from cleaning up and optimising my lazy code, this basic helper could be updated to support: editing the displayed subtitles, adding a 'find and replace' function, adding spellcheck functionality and whatever else you might want to have a go at, then sending those changes back to the project via SRT).

Hope its useful
Cheers
Andy
Last edited by Andy Mees on Tue Sep 26, 2023 11:10 am, edited 2 times in total.
Offline

im_gldn

  • Posts: 16
  • Joined: Wed May 19, 2021 5:56 am
  • Real Name: Lionel Golden

Re: Creating Scripts for DaVinci Resolve

PostThu Sep 21, 2023 1:18 pm

Andy Mees wrote:Here's a (Lua driven) helper to search & navigate subtitles:

Screenshot 2023-09-20 220617.jpg

BMD doesn't yet provide a built-in method to find / filter subtitle track contents... this helper displays subtitles as a static list in a separate window and adds that missing text search capability. Clicking any row move's the timeline playhead to the selected subtitle (for editing the source in the timeline). The manual 'Refresh' button rebuilds the list to reflect any changes.

[Save to your Scripts or Workflow Integration folder]

For the adventurous, apart from cleaning up and optimising my lazy code, this basic helper could be updated to support: editing the displayed subtitles, adding a 'find and replace' function, adding spellcheck functionality and whatever else you might want to have a go at, then sending those changes back to the project via SRT).

Fair warning: I've only used this on 25p projects.... the timecode conversion routine will need help to work accurately on fractional timebases.

Hope its useful
Cheers
Andy


***edit***


Thanks for offering this Andy. It works as it should. I wished it worked more efficiently in the workflow. But im sure someone will find this useful.

Thanks again. I appreciate the work you guys do here. Picked up a couple aswesome scripts here. If i wanted to learn to create stuff like this where could find some resources.

Thanks Golden
Offline

Andy Mees

  • Posts: 3259
  • Joined: Wed Aug 22, 2012 7:48 am

Re: Creating Scripts for DaVinci Resolve

PostThu Sep 21, 2023 2:16 pm

im_gldn wrote:It works as it should
Cool.
FYI, I just updated the script to add a 'Use dynamic filter' checkbox control to the UI (default status: off) When working with large numbers of subtitles, having dynamic filtering turned off helps responsiveness dramatically... instead of triggering the filter to rebuild itself after every keypress, it waits for you enter all search text first, then manually trigger the filter by pressing <Enter> or <Return>.

im_gldn wrote:If i wanted to learn to create stuff like this where could find some resources.
If you go to Resolve's Help menu > Documentation > Developer it will take you to the Support / Developer folder in your Resolve install which contains many scripting and workflow integration code samples. Especially, check the 'ReadMe' file in the Scripting folder. If that whets your appetite, you should join the WeSuckLess forum where there's a world of super helpful people with lots of relevant code that' s freely shared.
Offline

Videoneth

  • Posts: 1710
  • Joined: Fri Nov 13, 2020 11:03 pm
  • Warnings: 1
  • Real Name: Maxwell Allington

Re: Creating Scripts for DaVinci Resolve

PostSun Sep 24, 2023 7:12 pm

Just installed Andy's script
Thanks to you and Roger
Windows 10
19b
nVidia 3090 - 552.22
Offline

im_gldn

  • Posts: 16
  • Joined: Wed May 19, 2021 5:56 am
  • Real Name: Lionel Golden

Re: Creating Scripts for DaVinci Resolve

PostSun Sep 24, 2023 7:50 pm

Thanks Andy. I'll give it another shot.
Offline

im_gldn

  • Posts: 16
  • Joined: Wed May 19, 2021 5:56 am
  • Real Name: Lionel Golden

Re: Creating Scripts for DaVinci Resolve

PostMon Sep 25, 2023 5:15 am

UPDATE.

Rafael at editingtools.io made some changes to merge subtitles.

1. Create subtitles from Audio in Davinci Resolve. Filetype:SRT
Rafael at editingtools.io made it possible to set a time in seconds to merge subtitles.
2. Go to https://editingtools.io/subtitles/ and convert the SRT file to 15 seconds merged SRT. Remember to click "remove tags".
3. Go to https://editingtools.io/marker and convert Merged SRT to Timeline Markers. Check the "Swap marker name..." Filetype: EDL
4. Select Timeline in the BIN in DR, right click and import Timeline Markers.
i. If you are using (Andy's Subvigator) to subtitle search import merged subtitle and add to timeline.
ii. use Andy's Subvigator to search subtitles with "Use dynamic..." UNCHECKED.
5. You can use the index in DR to navigate by search.

Performance should be better since the number of indexes are reducded, based on the seconds selected to merge in Step 2.

Andy thanks again for the script & Rafael at editingtools.io


**ORIGINAL POST**
Just wanted to leave some feedback for reference.

Thanks for the update on the script it has definitely increased productivity.

The following is the workaround. It involves a bit of round-tripping.

(Create Subtitle)
1. Create subtitles from Audio in Davinci Resolve. Filetype:SRT
(Reduce the amount of Subtitles make longer text blocks. My project was reduced from 2500 to 498 subtitles)
2. Go to https://editingtools.io/marker/ and convert subtitles to Timeline Markers. Check the "Swap marker name..." and "Merge marker 10 seconds" This step removes tags and reduces the amount of subtitle lines generated for the timeline markers. Filetype: EDL
(Only way to have converted subtitles that'll keep text and timecode location)
3. Select Timeline in the BIN in DR, right click and import Timeline Markers.
4. Right click on Timeline again and export Timeline Markers. Filetype:EDL
5. Go back to editingtools.io and convert EDL to SRT
6. Import SRT into DR and drag to timeline.
7. Use Andy's Subvigator to search subtitles with "Use dynamic..." UNCHECKED.

Andy thanks again for the script & Rafael at editingtools.io
Offline

Raphael_D

  • Posts: 6
  • Joined: Tue May 12, 2020 8:26 am
  • Real Name: Raphaël Dubach

Re: Creating Scripts for DaVinci Resolve

PostTue Oct 24, 2023 1:43 pm

Hi Folks,

I'm an On/Near Set DIT working on TV show and feature with SilverStack Lab, LiveGrade, Avid Media Composer, Davinci Resolve, Base Light an many more.

Fist I wanted to thank Roger Magnusson for the Timeline Clips Batch Timecode Script, wich realy realy rocks in peculiars workflows where you need to batch offset TC from already imported Audio File inside Resolve MediaPool before Sync.
For now Resolve "Import with offset" doesn't work for audio files, only video clips. And Roger you made it possible since 2015!

As I have realy poor knowlege of Python and Lua, I wonder if there is an easy way to implement another option in the "mode" dropdown menuof the script. An option called "Audio Offset" that would add, substract or even set the existing clip audio Offset column (for now you can only do it by hand and clip per clip)
That way the TC would not be touch but you'll still get the offset correction directly on the synced clips. Modifed TC could be a great deal when exporting clips for Post-Production houses that would have trouble to correctly relink the clip to the original one if the Resolve TC is changed on Proxy or other exported files.

If you guide me maybe I would be able to add that change in the existing script.

Thank again
Offline

cat99_0

  • Posts: 16
  • Joined: Sun Feb 12, 2023 6:25 pm
  • Real Name: Danniel Ni

Re: Creating Scripts for DaVinci Resolve

PostSat Nov 04, 2023 3:01 am

Genius!!! Thank you so much for the really useful script!!
Offline

cat99_0

  • Posts: 16
  • Joined: Sun Feb 12, 2023 6:25 pm
  • Real Name: Danniel Ni

Re: Creating Scripts for DaVinci Resolve

PostSat Nov 04, 2023 9:00 am

I tested "Grab Stills at Markers.lua" on mac in18.6. It does not work now.
截屏2023-11-04 16.53.34.png
截屏2023-11-04 16.53.34.png (70.56 KiB) Viewed 4434 times
Offline
User avatar

Vojta Filipi

  • Posts: 57
  • Joined: Wed May 18, 2022 4:24 pm
  • Real Name: Vojtěch Filipi

script for putting media from media pool to Timeline

PostTue Dec 12, 2023 10:01 am

I would love to create a script where you can with a shortcut put single specific item on timeline to playhead, ideally from power bins, but I found only a option to do it from the media pool.

I´m trying to learn coding and scripting in Davinci, so my code probably have terrible mistakes in it, sorry :lol:

Here is my attempt just for putting file on the timeline:
Code: Select all
# Import the DaVinci Resolve Scripting module
import DaVinciResolveScript as dvr_script

# Get the Resolve object
resolve = dvr_script.scriptapp("Resolve")

# Get the current project
project = resolve.GetProjectManager().GetCurrentProject()

# Get the adios meme clip from the media pool
resolve.MediaPool.AppendToTimeline(["adios.mkv"])
Offline
User avatar

Igor Riđanović

  • Posts: 1596
  • Joined: Thu Jul 02, 2015 5:11 am
  • Location: Los Angeles, Calif.

Re: Creating Scripts for DaVinci Resolve

PostWed Dec 13, 2023 2:02 am

That would not have worked here is an updated version:

Code: Select all
# You don't need these two lines if running the script from inside Resolve
#import DaVinciResolveScript as dvr_script
#resolve = dvr_script.scriptapp("Resolve")

# Get the current project and media pool
project = resolve.GetProjectManager().GetCurrentProject()
mediaPool = project.GetMediaPool()

# You must make an instance of a media pool item (clip) first. You could
# use GetClips() on a bin instance for example.

# Get the adios meme clip from the media pool
mediaPool.AppendToTimeline(clip)


The important thing is that you can't use a string that represents the clip name to append the timeline. You have to use the clip object.

See in this video how I use GetClips() to do the exact thing you're trying to do. The beginning of the tutorial is a little out of date. I recorded it 5 years ago,

www.metafide.com - DaVinci Resolve™ Apps
Offline
User avatar

Vojta Filipi

  • Posts: 57
  • Joined: Wed May 18, 2022 4:24 pm
  • Real Name: Vojtěch Filipi

Re: Creating Scripts for DaVinci Resolve

PostMon Dec 18, 2023 5:02 pm

Igor Riđanović wrote:That would not have worked here is an updated version:

Code: Select all
# You don't need these two lines if running the script from inside Resolve
#import DaVinciResolveScript as dvr_script
#resolve = dvr_script.scriptapp("Resolve")

# Get the current project and media pool
project = resolve.GetProjectManager().GetCurrentProject()
mediaPool = project.GetMediaPool()

# You must make an instance of a media pool item (clip) first. You could
# use GetClips() on a bin instance for example.

# Get the adios meme clip from the media pool
mediaPool.AppendToTimeline(clip)


The important thing is that you can't use a string that represents the clip name to append the timeline. You have to use the clip object.

See in this video how I use GetClips() to do the exact thing you're trying to do. The beginning of the tutorial is a little out of date. I recorded it 5 years ago,



Thanks for helping dude! I was trying to get it to work, but I´m still getting NameError: name 'clip' is not defined error.

And in the Scripting manual, I found that GetClips() is in Deprecated Resolve API Functions section.
Offline
User avatar

Igor Riđanović

  • Posts: 1596
  • Joined: Thu Jul 02, 2015 5:11 am
  • Location: Los Angeles, Calif.

Re: Creating Scripts for DaVinci Resolve

PostMon Dec 18, 2023 5:48 pm

Yes, it may or may not work dependong on the version.
If Resolve you're using. The replacement is GetClipsList(). Or maybe it's singular GetClipList() I don't have the Readme doc in front of me.

Igor Riđanović
www.metafide.com - DaVinci Resolve™ Apps
Offline

JeanCall

  • Posts: 12
  • Joined: Tue Dec 19, 2023 3:38 pm
  • Real Name: Jean Callisti

Re: Creating Scripts for DaVinci Resolve

PostThu Dec 21, 2023 10:29 am

Reviving this great thread.

While I'm at it, the github link has changed. It is now :
https://rogmag.github.io/
https://github.com/rogmag/rogmag.github.io/

I'm trying to script in Python. My Python scripts end up in the Scripts menu or Resolve's UI. Good!

Problem: When I run a script nothing seems to happen. I tried making the simplest script that just does "print("hello world"). But I can't seem to figure out where the standard output goes. Either that, or there's an error during script execution but it gets silently ignored. Either way I need to know where the output goes!

How can I investigate that?
I'm on Windows. I've tried running Resolve from the Terminal (command line) but even there, no output (neither messages nor errors)

Where do the scripts write? Into a log file maybe?
Offline
User avatar

Igor Riđanović

  • Posts: 1596
  • Joined: Thu Jul 02, 2015 5:11 am
  • Location: Los Angeles, Calif.

Re: Creating Scripts for DaVinci Resolve

PostTue Dec 26, 2023 6:05 pm

If you execute a script from the Resolve dropdown menu the stdout goes to Resolve Console.

If you execute from an external shell the stdout goes to that shell.
www.metafide.com - DaVinci Resolve™ Apps
Offline

JeanCall

  • Posts: 12
  • Joined: Tue Dec 19, 2023 3:38 pm
  • Real Name: Jean Callisti

Re: Creating Scripts for DaVinci Resolve

PostThu Dec 28, 2023 7:32 am

Igor Riđanović wrote:If you execute from an external shell the stdout goes to that shell.


Like I said : I've tried. Saw no output.
I would compare with other projects but I've yet to find a full example of external Python configuration and scripting on the forums.
Offline
User avatar

Igor Riđanović

  • Posts: 1596
  • Joined: Thu Jul 02, 2015 5:11 am
  • Location: Los Angeles, Calif.

Re: Creating Scripts for DaVinci Resolve

PostThu Dec 28, 2023 7:34 am

JeanCall wrote:
Igor Riđanović wrote:If you execute from an external shell the stdout goes to that shell.


Like I said : I've tried. Saw no output.
I would compare with other projects but I've yet to find a full example of external Python configuration and scripting on the forums.
Try running the code examples that come with Resolve.

Igor Riđanović
www.metafide.com - DaVinci Resolve™ Apps
Offline

oguz_k

  • Posts: 1
  • Joined: Tue Jan 23, 2024 10:49 am
  • Real Name: Oğuz Kılınç

Re: Creating Scripts for DaVinci Resolve

PostTue Jan 23, 2024 11:14 am

TiDa wrote:
And this is the Code:
Code: Select all
-- To convert (by MacOS) clips into subclips, you can follow these steps:
-- 1. Install https://github.com/socsieng/sendkeys
-- 2. Assign the keyboard shortcut "Control+Command+s" to "Create SubClip".
-- 4. In the Edit Page, drag and drop the desired clips into a separate bin.
-- 5. Go to the bin in the Media Pool and sort the clips according to
--    "Clip Name" in descending order.
-- 6. Run this Script.
-- 7. Finally, delete non-subclips.


Thank you sharing this TiDa.
I'm novice about script in Davinci Resolve and when I follow the steps you said, the the script does not work. There must be something I'm missing.

I am having a problem like that; If there are 5 clips in the bin, it creates 5 subclips from only one clip. Mostly, the subclips is the clip that is open in the source panel even if the clip in the source panel is in another folder.

I am using Davinci Resolve version 18.6
Thank you.
Offline
User avatar

Vojta Filipi

  • Posts: 57
  • Joined: Wed May 18, 2022 4:24 pm
  • Real Name: Vojtěch Filipi

Re: Creating Scripts for DaVinci Resolve

PostSun Feb 04, 2024 9:54 pm

Igor Riđanović wrote:Yes, it may or may not work dependong on the version.
If Resolve you're using. The replacement is GetClipsList(). Or maybe it's singular GetClipList() I don't have the Readme doc in front of me.

Igor Riđanović


Thank you! In the end, I was able to do it by writing the script from the scratch according to your video. GetClips() is working even when it is on Deprecated Resolve API Functions list
Last edited by Vojta Filipi on Sun Feb 04, 2024 10:09 pm, edited 1 time in total.
Offline
User avatar

Vojta Filipi

  • Posts: 57
  • Joined: Wed May 18, 2022 4:24 pm
  • Real Name: Vojtěch Filipi

Re: Creating Scripts for DaVinci Resolve

PostSun Feb 04, 2024 10:07 pm

The new problem I´m facing now is that I want to place the clip to my playhead (in the same way as pasting by ctrl+v) but the AppendToTimeline is placing the clip behind the latest clip on the timeline instead. :cry:

I have created a whole plugin with GUI for automation for clips that you use frequently. You can assign any number of hotkeys you want for the clips that you choose.
But after completing it, I just tested that AppendToTimeline have this behaviour :lol:
Offline
User avatar

Igor Riđanović

  • Posts: 1596
  • Joined: Thu Jul 02, 2015 5:11 am
  • Location: Los Angeles, Calif.

Re: Creating Scripts for DaVinci Resolve

PostMon Feb 05, 2024 12:01 am

That what Append to Timeline does. The same behavior as when used the normal way, outside of the API.
www.metafide.com - DaVinci Resolve™ Apps
PreviousNext

Return to DaVinci Resolve

Who is online

Users browsing this forum: Bing [Bot], David E King, MSN [Bot], oxysoft and 203 guests