Documentation Davinci Resolve Scripting

User avatar
foxdanger
Posts: 1
Joined: Sat Jun 15, 2019 4:30 pm

Documentation Davinci Resolve Scripting

#1

Post by foxdanger » Sat Jun 15, 2019 4:34 pm

Hi guys. Trying to create something here and I didn't understood yet how Davinci Resolve Scripting really works.

Tried to found in all internet the documentation for the API. So with that I could know what I can and what I Can't do.

But there's nothing. I can't find any information or documentation about it. Only for old versions of fusion.

So, How I'm suposed to know the function names, how to get a button, how to send a command and etc?

For example: Can I create a script which increments contrast with one click in a button? Can I create a script to turn the gain wheel to left or to right? Can I control the color wheels with a script?

And if I can, how? Where is the documentation to learn the functions and etc?

Thank you for any help.

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

Re: Documentation Davinci Resolve Scripting

#2

Post by SecondMan » Mon Jun 17, 2019 12:04 pm

There's not much, currently. Documentation is in progress, I hear, but no ETA has been given.

The venerable @Greg Bovine made a pretty spectacular intro to Scripting in Resolve here: viewtopic.php?f=35&t=2012

I don't know if you've already seen it, but if not I suggest you start there and see if answers some of your questions?
foxdanger wrote:
Sat Jun 15, 2019 4:34 pm
Can I create a script which increments contrast with one click in a button? Can I create a script to turn the gain wheel to left or to right? Can I control the color wheels with a script?
I have not seen examples of this. So I have no idea if that is possible already, or if it will be :)

What you could do is send an email to support@blackmagicdesign.com with your questions (and then report back with their answers) :)

Hope this helps.

Out of interest, what specifically are you trying to do that you want scripting access to those controls for?

User avatar
Igor Ridanovic
Posts: 24
Joined: Mon Apr 16, 2018 11:17 pm
Location: Los Angeles
Been thanked: 3 times
Contact:

Re: Documentation Davinci Resolve Scripting

#3

Post by Igor Ridanovic » Mon Jun 17, 2019 4:22 pm

All API methods are documented in the readme.txt. You can locate it by going to Resolve Help/Developers menu.

It is not directly possible to control any parameter values within Resolve color page. Depending on what you need done you may get by using a method called ApplyGradeFromDRX(). It applies a grade specified in a DRX file to a clip on the timeline.

This intro video shows Resolve scripting using Python. I have a couple of other videos that touch the subject there as well.

User avatar
sgsgesgg
Posts: 5
Joined: Mon Jun 17, 2019 6:18 pm

Re: Documentation Davinci Resolve Scripting

#4

Post by sgsgesgg » Mon Jun 17, 2019 6:20 pm

@Igor Ridanovic

i cant import DaVinciResolveScript

i get an error: ModuleNotFoundError: No module named 'DaVinciResolveScript'

What do i do? what do i import?

edit: on win 10 and using DR 16

User avatar
AndrewHazelden
Fusionator
Posts: 1380
Joined: Fri Apr 03, 2015 3:20 pm
Answers: 3
Location: West Dover, Nova Scotia, Canada
Been thanked: 56 times
Contact:

Re: Documentation Davinci Resolve Scripting

#5

Post by AndrewHazelden » Mon Jun 17, 2019 6:27 pm

As a quick double-check, are you running Resolve Studio? Did you enable scripting access in Resolve's preference window?

The free version of Resolve has limitations where it doesn't allow you to control areas outside of the Fusion page via scripting, and you can't externally access Resolve's scripting API via Fuscript/Python from a command prompt/terminal session.

User avatar
Igor Ridanovic
Posts: 24
Joined: Mon Apr 16, 2018 11:17 pm
Location: Los Angeles
Been thanked: 3 times
Contact:

Re: Documentation Davinci Resolve Scripting

#6

Post by Igor Ridanovic » Mon Jun 17, 2019 6:43 pm

You can see in the script examples folder how BMD do it. But it can be simpler if you just care about Windows. Since you know where the library is located you can use imp to import it.
  1. import imp
  2. lib = 'C:\\Program Files\\Blackmagic Design\\DaVinci Resolve\\fusionscript.dll'
  3. dvr_script = imp.load_dynamic('fusionscript', lib)
  4.  
  5. # Create the instances you need...
  6. resolve = dvr_script.scriptapp('Resolve')
  7. fusion   = dvr_script.scriptapp('Fusion')

User avatar
sgsgesgg
Posts: 5
Joined: Mon Jun 17, 2019 6:18 pm

Re: Documentation Davinci Resolve Scripting

#7

Post by sgsgesgg » Mon Jun 17, 2019 6:56 pm

from the above code i get: ImportError: DLL load failed: %1 is not a valid Win32 application.

User avatar
Igor Ridanovic
Posts: 24
Joined: Mon Apr 16, 2018 11:17 pm
Location: Los Angeles
Been thanked: 3 times
Contact:

Re: Documentation Davinci Resolve Scripting

#8

Post by Igor Ridanovic » Mon Jun 17, 2019 7:06 pm

Are you maybe using 32-bit Python? I wasn't aware 64-bit Python is a requirement, but maybe it is.

User avatar
sgsgesgg
Posts: 5
Joined: Mon Jun 17, 2019 6:18 pm

Re: Documentation Davinci Resolve Scripting

#9

Post by sgsgesgg » Mon Jun 17, 2019 7:39 pm

i didnt think i was

but ive updated to the current version, had to change imp to importlib
and dvr_script = importlib.import_module('fusionscript', lib)

and now i get: ModuleNotFoundError: No module named 'fusionscript'

User avatar
Iddos
Posts: 18
Joined: Sat Oct 06, 2018 4:21 pm
Been thanked: 2 times

Re: Documentation Davinci Resolve Scripting

#10

Post by Iddos » Mon Jun 17, 2019 9:43 pm

Hi

What python version are you using?

Python 3 doesn’t support imp in some versions, I think above 3.4.
And I think resolve supports up till 3.6
Try 2.7 with imp.

This can also be a environmental thing.
Did you set the environment variable in windows path?

User avatar
sgsgesgg
Posts: 5
Joined: Mon Jun 17, 2019 6:18 pm

Re: Documentation Davinci Resolve Scripting

#11

Post by sgsgesgg » Mon Jun 17, 2019 9:46 pm

i think i put the variables in the right spot
i changed my python version to 3.6 but i cant open the console in resolve, it says i need python 3.6 ...
imp works but i cant get DaVinciResolveScript, i get: ModuleNotFoundError: No module named 'DaVinciResolveScript'

User avatar
Igor Ridanovic
Posts: 24
Joined: Mon Apr 16, 2018 11:17 pm
Location: Los Angeles
Been thanked: 3 times
Contact:

Re: Documentation Davinci Resolve Scripting

#12

Post by Igor Ridanovic » Mon Jun 17, 2019 9:57 pm

sgsgesgg wrote:
Mon Jun 17, 2019 7:39 pm


and now i get: ModuleNotFoundError: No module named 'fusionscript'
I can't exactly repro. I'm on Linux machine without Resolve right now. But if I try to import a module that's not there I get:

ImportError: /opt/resolve/libs/Fusion/fusionscript.so: cannot open shared object file: No such file or directory

This is Python 2.7.6. Although the error is not the same as yours I think both mean the same thing. The module is missing. Check if the .dll is in that path.

User avatar
sgsgesgg
Posts: 5
Joined: Mon Jun 17, 2019 6:18 pm

Re: Documentation Davinci Resolve Scripting

#13

Post by sgsgesgg » Mon Jun 17, 2019 10:43 pm

fusionscript.dll? its in there


edit:
so the script now doesnt give any errors, but it also doesnt do anything. it runs and gives a 'press any key to continue'. no project is created when resolve is open.

Code: Select all

import imp
lib = r'C:\Program Files\Blackmagic Design\DaVinci Resolve\fusionscript.dll'
dvr_script = imp.load_dynamic('fusionscript', lib)
resolve = dvr_script.scriptapp("Resolve")
fusion = resolve.Fusion()
projectManager = resolve.GetProjectManager()
projectManager.CreateProject("Hello World")

User avatar
Iddos
Posts: 18
Joined: Sat Oct 06, 2018 4:21 pm
Been thanked: 2 times

Re: Documentation Davinci Resolve Scripting

#14

Post by Iddos » Mon Jun 17, 2019 11:42 pm

Try assignment.
myProject = projectManager.CreateProject("Hello World")

User avatar
Igor Ridanovic
Posts: 24
Joined: Mon Apr 16, 2018 11:17 pm
Location: Los Angeles
Been thanked: 3 times
Contact:

Re: Documentation Davinci Resolve Scripting

#15

Post by Igor Ridanovic » Tue Jun 18, 2019 9:21 am

The only time I came across that is when the project settings or preferences windows are open in Resolve Studio. You're using the Resolve Studio, not Resolve, right?

The assignment won't make a difference, but if you do:
  1. myProject = projectManager.CreateProject("Hello World")
  2. print myProject
You'll at least be able to tell if myProject is a valid object. The exception reporting from the API can be very silent.