Welcome to WSL!

New to the forum? Please read this and this.

Resolve Scripting Essentials

User avatar
SecondMan
Site Admin
Posts: 4904
Joined: Thu Jul 31, 2014 5:31 pm
Answers: 31
Location: Vancouver, Canada
Been thanked: 53 times
Contact:

Re: Resolve Scripting Essentials

#76

Post by SecondMan »

pixelstuff wrote: Sun Feb 09, 2020 6:56 amHi
Hi :)

Forgive the sidestepping for a second, but could I please ask you (and everyone) to not quote long posts in their entirety, unless you really need to? More info here (it's the last little bit in the post) - https://www.steakunderwater.com/wesuckl ... 2250#p2250

Thanks!

User avatar
JPBotta
Posts: 1
Joined: Sun Jul 26, 2020 12:17 am

Re: Resolve is just a GUI to an Sqlite3 Media Database

#77

Post by JPBotta »

Good Day,
Thank you for thos information's about SQL3.
I got it connected to the Project.db and could extract needed information's about the clips in the project.
But I could not find the table with the Metadata.
Coming from PPR, I have developed a dB with all Metadata per clip extracted from PPR.
It helps me to find any clip in all projects.
I just would do the same with Resolve 16.

Can you please help me, thanks in advance?

Regards, JPB

User avatar
SirEdric
Fusionator
Posts: 2384
Joined: Tue Aug 05, 2014 10:04 am
Answers: 12
Real name: Eric Westphal
Been thanked: 4 times
Contact:

Re: Resolve Scripting Essentials

#78

Post by SirEdric »

Hi guys.
Been away for a looong time (1300+ unread posts....:-/), sorry for that. Things will hopefully change in the near future...

Here's one Resolve scripting thingy I wasn't able to figure out:
When you have 2 clips on top of each other in the edit page, select them, and create a new Fusion compositon,
MediaIn1 and MediaIn2 Just show 'Fusion Clip 1' as the ClipName.
Also, the scaling of the timeline is applied to all MediaIn's.

Is there any way to find the *original* media from those MediaIn's in the media pool via script?

Cheers.

Eric.

User avatar
UserNoah
Fusioneer
Posts: 195
Joined: Mon Mar 09, 2020 11:43 am
Been thanked: 6 times
Contact:

Re: Resolve Scripting Essentials

#79

Post by UserNoah »

I don't have any help right now only a question.
I was asked if it was possible to create a script that creates stills in the Color Page (and sort them in the Gallery). As far as I can see, there is nothing in the Class Browser to indicate any possibilities to automate stuff in the Color Page right now. But maybe somebody else knows if it is possible or not?

User avatar
white_wizard
Fusioneer
Posts: 72
Joined: Wed Sep 18, 2019 3:53 pm

Re: Resolve Scripting Essentials

#80

Post by white_wizard »

+1 I'm also wondering if the color page and/or delivery page are accessible for scripting.

User avatar
TheBloke
Fusioneer
Posts: 159
Joined: Wed Jun 17, 2020 6:02 am
Answers: 1
Been thanked: 1 time

Re: Resolve Scripting Essentials

#81

Post by TheBloke »

white_wizard wrote: Sat Sep 12, 2020 2:15 pm delivery page are accessible for scripting.
There's quite a lot of rendering options - this is one area that's moderately well covered (though still far from complete):

Code: Select all

Project
  GetRenderJobList()                              --> [render jobs...]   # Returns a list of render jobs and their information.
  GetRenderPresetList()                           --> [presets...]       # Returns a list of render presets and their information.
  StartRendering(index1, index2, ...)             --> Bool               # Starts rendering for given render jobs based on their indices.
  StartRendering([idxs...], isInteractiveMode = False) --> Bool          # Starts rendering for given render jobs based on their indices.
                                                                         # Optional field "isInteractiveMode". It is Bool Type and it defaults to False. "isInteractiveMode" indicates whether there should be display of error dialog during rendering.
  StartRendering(isInteractiveMode = False)       --> Bool               # Starts rendering for all render jobs.
                                                                         # Optional field "isInteractiveMode". It is Bool Type and it defaults to False. "isInteractiveMode" indicates whether there should be display of error dialog during rendering.
  StopRendering()                                 --> None               # Stops rendering for all render jobs.
  IsRenderingInProgress()                         --> Bool               # Returns true is rendering is in progress.
  AddRenderJob()                                  --> Bool               # Adds render job to render queue.
  DeleteRenderJobByIndex(idx)                     --> Bool               # Deletes render job based on given job index (int).
  DeleteAllRenderJobs()                           --> Bool               # Deletes all render jobs.
  LoadRenderPreset(presetName)                    --> Bool               # Sets a preset as current preset for rendering if presetName (text) exists.
  SaveAsNewRenderPreset(presetName)               --> Bool               # Creates a new render preset by given name if presetName(text) is unique.
  SetRenderSettings({settings})                   --> Bool               # Sets given settings for rendering. Settings is a dict, with support for the keys: "SelectAllFrames", "MarkIn", "MarkOut", "TargetDir", "CustomName".
  GetRenderJobStatus(idx)                         --> {status info}      # Returns a dict with job status and completion percentage of the job by given job index (int).
  GetRenderFormats()                              --> {render formats..} # Returns a dict (format -> file extension) of available render formats.
  GetRenderCodecs(renderFormat)                   --> {render codecs...} # Returns a dict (codec description -> codec name) of available codecs for given render format (string).
  GetCurrentRenderFormatAndCodec()                --> {format, codec}    # Returns a dict with currently selected format 'format' and render codec 'codec'.
  SetCurrentRenderFormatAndCodec(format, codec)   --> Bool               # Sets given render format (string) and render codec (string) as options for rendering.
It's possible to render a timeline, or a portion of a timeline, with customised render settings. Active rendering progress can be monitored, as can be the status of any job.

It's rather limited in terms of setting advanced render settings - eg I'm not sure if you can set set Individual Clips mode, Export Alpha etc, directly. However you can load from a pre-saved Render Preset, and those presets can include those settings, so it should be possible to do more advanced renders if the presets are set up in advance.

And you can specify the CustomName, which means you could start a render with a custom output filename that was decided by metadata or whatever else, which I imagine is one of the things you were looking for.

User avatar
white_wizard
Fusioneer
Posts: 72
Joined: Wed Sep 18, 2019 3:53 pm

Re: Resolve Scripting Essentials

#82

Post by white_wizard »

@TheBloke Oh great. That gives me some hope. I'm trying to either pass a timeline markername as a CustomName per individual clip, or pass a stored string from within a fusion macro to CustomName.

The goal is to export individual clips from a vfx master timeline and have each separate exported clip have it's correct filename. (eg. vfx21_2, vfx31_1, etc). Resolve has %variables for custom names which include the option for markernames, however the feature is broken or something.

User avatar
TheBloke
Fusioneer
Posts: 159
Joined: Wed Jun 17, 2020 6:02 am
Answers: 1
Been thanked: 1 time

Re: Resolve Scripting Essentials

#83

Post by TheBloke »

Looking at the API, it looks like all the required calls are there to do something like that.

So you'd have one big timeline with sequential clips on it, and each clip on that timeline would have a marker named "VFX21_2" or "VFX31_1" etc?

And then you'd want Individual Clips rendering, with each clip rendered to a separate file, with that filename matching the clip's marker? Or rather, you'd want to end up with one file per clip - I suppose Individual Clips rendering is not a requirement, so long as the output is achieved OK?

Is that all correct?

User avatar
white_wizard
Fusioneer
Posts: 72
Joined: Wed Sep 18, 2019 3:53 pm

Re: Resolve Scripting Essentials

#84

Post by white_wizard »

TheBloke wrote: Sat Sep 12, 2020 2:44 pmLooking at the API, it looks like all the required calls are there to do something like that.

So you'd have one big timeline with sequential clips on it, and each clip on that timeline would have a marker named "VFX21_2" or "VFX31_1" etc?

And then you'd want Individual Clips rendering, with each clip rendered to a separate file, with that filename matching the clip's marker? Or rather, you'd want to end up with one file per clip - I suppose Individual Clips rendering is not a requirement, so long as the output is achieved OK?

Is that all correct?
Yeah, exactly.

It seems like this functionality was intended to be built in as evidenced by the %markername CustomName variable, but as myself and others have discovered it seems to be broken.

I'm getting acquainted with Resolve's scripting API so I can hack a workaround together. Any other tips are appreciated.

User avatar
white_wizard
Fusioneer
Posts: 72
Joined: Wed Sep 18, 2019 3:53 pm

Re: Resolve Scripting Essentials

#85

Post by white_wizard »

Getting scripting to work in Resolve was a pain, but I managed. The documentation on pathlibs is lacking, but I managed to get it all working by replacing the pathlib variables with the full filepaths. For me this looked like:

PYTHONPATH C:\ProgramData\Blackmagic Design\DaVinci Resolve\Support\Developer\Scripting\Modules\
RESOLVE_SCRIPT_API C:\ProgramData\Blackmagic Design\DaVinci Resolve\Support\Developer\Scripting\
RESOLVE_SCRIPT_LIB C:\Program Files\Blackmagic Design\DaVinci Resolve\fusionscript.dll

I struggled with my initial attempt to create a script that will work using mark in and out points, so I instead opted for a different method, which ends up working better for my needs anyway. The way the script works, is you set up markers for each clip, making sure to provide a name and duration. The name will be used to create the rendered filename.

You then designate a color in the script parameters section: marker_filter. When the script is run, it will only consider markers matching the color you chose. You can also set your render preset in the script's parameter section as well.

The script will find the clips you've markered for rendering and add them to the render queue, using the marker name as the filename. Keep in mind there are timeline markers and clip markers; this script uses timeline markers.
Code: [Select all] [Expand/Collapse] [Download] (vfx_master_timeline_render.py)
  1. #!/usr/bin/env python
  2. import DaVinciResolveScript as dvr_script
  3.  
  4. #######CUSTOM PARAMETERS########
  5. marker_filter = 'Purple' #choose which marker color to render. Empty quotes will render all markers.
  6. render_preset_name = 'vfx_render' #change this to the name of your render preset
  7. ################################
  8.  
  9. resolve = dvr_script.scriptapp("Resolve")
  10. fusion = resolve.Fusion()
  11. pm = resolve.GetProjectManager()
  12. project = pm.GetCurrentProject()
  13. timeline = project.GetCurrentTimeline()
  14.  
  15. #set render preset
  16. render_preset = project.LoadRenderPreset(render_preset_name)
  17.  
  18. #Get Markers
  19. marker_offset = timeline.GetStartFrame()
  20. markers = timeline.GetMarkers()
  21.  
  22. def renderjob_create( vfx_name, start_frame, end_frame ):
  23.     render_settings = project.SetRenderSettings({'CustomName': vfx_name, 'MarkIn': start_frame, 'MarkOut': end_frame})
  24.     project.AddRenderJob()  #add renderjob
  25.  
  26. for marker in markers:
  27.     marker_color = markers[marker]['color']
  28.  
  29.     if marker_color == marker_filter:
  30.         marker_name = markers[marker]['name']
  31.         marker_startframe = marker + marker_offset
  32.         marker_endframe = ( marker_startframe + markers[marker]['duration'] - 1 )
  33.  
  34.         print(f"Adding {marker_name} to Render Queue. Frames: {marker_startframe} - {marker_endframe}")
  35.         renderjob_create(marker_name, marker_startframe, marker_endframe)

User avatar
malbred
Posts: 48
Joined: Wed Aug 16, 2017 9:17 pm
Answers: 1
Location: Saint-Petersburg, Russia
Contact:

Re: Resolve Scripting Essentials

#86

Post by malbred »

SirEdric wrote: Mon Apr 15, 2019 1:13 am
SirEdric wrote: Wed Apr 11, 2018 10:58 pmNow if one only could do something like fu:ToggleUtility('FBXImport', 'p:\ath\to\file.obj', autoImport = true)
Quoting myself here....:-)
Does anybody have new information on this topic for F16?
Is there a way now to import fbx via script?
is there any solution?

User avatar
malbred
Posts: 48
Joined: Wed Aug 16, 2017 9:17 pm
Answers: 1
Location: Saint-Petersburg, Russia
Contact:

Re: Resolve Scripting Essentials

#87

Post by malbred »

Hello guys
I have a macro with simple interface control compiled in Davinci resolve. This macro used import FBX node (FBXMesh3D) and after using on fusion page I have no open FBX file because path file is absolute.
PIC001.jpeg
With the help of the guys on this forum, I made a LUA script that replaces non-working paths.
PIC002.jpeg
FBX import nodes inside the macro

As I understand it, I need to run the script once after load the project to redefine the paths.
But Where should I place my LUA script for that?
You do not have the required permissions to view the files attached to this post.

User avatar
UserNoah
Fusioneer
Posts: 195
Joined: Mon Mar 09, 2020 11:43 am
Been thanked: 6 times
Contact:

Re: Resolve Scripting Essentials

#88

Post by UserNoah »

malbred wrote: Thu Jun 17, 2021 1:00 pmBut Where should I place my LUA script for that?
There might be another way, but currently, I can only think of placing the script in a button the user has to press. You can put scripts behind buttons that will get executed when pressed. You can add them through the UI if you want:

Image