Python scripting in Resolve 15

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

Nick Shaw

  • Posts: 237
  • Joined: Thu Sep 13, 2012 11:43 am
  • Location: London, UK

Python scripting in Resolve 15

PostMon Apr 16, 2018 12:28 pm

Is this the right place to look for help on Resolve scripting?

I am a bit of a noob to this, so I may well be doing something stupid.

Code: Select all
DaVinciResolveScript.scriptapp("Resolve")
returns a None object, so I can't then do anything with it.
Code: Select all
AttributeError: 'NoneType' object has no attribute 'GetProjectManager'

The example scripts fail for this same reason.

However,
Code: Select all
DaVinciResolveScript.scriptapp("Fusion")
returns a FusionUI object, so the module would appear to have loaded.

I do get a bunch of warnings when importing the module:
Code: Select all
dyld: warning, LC_RPATH @executable_path/../Libraries/Fusion in /Applications/DaVinci Resolve/DaVinci Resolve.app/Contents/Libraries/Fusion/fusionscript.so being ignored in restricted program because of @executable_path
dyld: warning, LC_RPATH @executable_path/. in /Applications/DaVinci Resolve/DaVinci Resolve.app/Contents/Libraries/Fusion/fusionscript.so being ignored in restricted program because of @executable_path
dyld: warning, LC_RPATH @executable_path/../Frameworks in /Applications/DaVinci Resolve/DaVinci Resolve.app/Contents/Libraries/Fusion/libluajit-5.1.2.dylib being ignored in restricted program because of @executable_path
dyld: warning, LC_RPATH @executable_path/../Libraries/Fusion in /Applications/DaVinci Resolve/DaVinci Resolve.app/Contents/Libraries/Fusion/libluajit-5.1.2.dylib being ignored in restricted program because of @executable_path
dyld: warning, LC_RPATH @executable_path/. in /Applications/DaVinci Resolve/DaVinci Resolve.app/Contents/Libraries/Fusion/libluajit-5.1.2.dylib being ignored in restricted program because of @executable_path
dyld: warning, LC_RPATH @executable_path/../Libraries/Fusion in /Applications/DaVinci Resolve/DaVinci Resolve.app/Contents/Libraries/Fusion/fusionscript.so being ignored in restricted program because of @executable_path
dyld: warning, LC_RPATH @executable_path/. in /Applications/DaVinci Resolve/DaVinci Resolve.app/Contents/Libraries/Fusion/fusionscript.so being ignored in restricted program because of @executable_path
dyld: warning, LC_RPATH @executable_path/../Libraries/Fusion in /Applications/DaVinci Resolve/DaVinci Resolve.app/Contents/Libraries/Fusion/fusionscript.so being ignored in restricted program because of @executable_path
dyld: warning, LC_RPATH @executable_path/. in /Applications/DaVinci Resolve/DaVinci Resolve.app/Contents/Libraries/Fusion/fusionscript.so being ignored in restricted program because of @executable_path
Workflow Consultant, London UK
LUTs and LUT plugins
www.antlerpost.com
Offline
User avatar

Nick Shaw

  • Posts: 237
  • Joined: Thu Sep 13, 2012 11:43 am
  • Location: London, UK

Re: Python scripting in Resolve 15

PostTue Apr 17, 2018 11:06 am

Update, I got the errors mentioned above when trying to use scripting through a standard Terminal Python shell (under OS X) but when I run fuscript in interactive mode I have more success (/Applications/DaVinci\ Resolve/DaVinci\ Resolve.app/Contents/Libraries/Fusion/fuscript -l py2 -i). I discovered this via a post on steakunderwater.com although I can't see any mention of fuscript in the Resolve scripting README.

I'm sure yesterday I had the same problems using the console within Resolve, but today it seems to work! So maybe I missed something yesterday.

I am able to work through the steps from the 1_sorted_timeline_from_folder.py example script, and it seems mainly to work. I can create a project and add the clips to a timeline. There are a few things I am still unsure of, but I am feeling my way, and it may well be user error.

project.SetResolution(2048, 1152) sets the Timeline Resolution (as shown in the Project Settings panel) to 2048x1152, but then running timeline = mediapool.CreateEmptyTimeline("Test Timeline 1") creates a new timeline which is still 1920x1080, per defaults. But if the resolution is set via scripting, creating a new timeline by pressing CMD-N also produces a 1080p timeline, so maybe there is somewhere else that I need to set it to 2k as well.

project.SetFrameRate(25) sets the timeline framerate to 25, but the Playback Framerate stays at the default 24, and I can't find a way of setting that via scripting.

If this is a bug, I was just luck that a chose a folder of 2kp25 clips to test with. If they had been 1080p24, I would not have noticed.
Workflow Consultant, London UK
LUTs and LUT plugins
www.antlerpost.com
Offline
User avatar

Nick Shaw

  • Posts: 237
  • Joined: Thu Sep 13, 2012 11:43 am
  • Location: London, UK

Re: Python scripting in Resolve 15

PostTue Apr 17, 2018 11:50 am

…and now it works in a standard Python shell in Terminal as well!

Maybe it's because I restarted the machine. Maybe it's because I ran fuscript first. Who knows, but it works!

I can still only create a 1080p timeline that plays back at 24fps, but it's a good start.

Onwards and upwards!
Workflow Consultant, London UK
LUTs and LUT plugins
www.antlerpost.com
Offline
User avatar

Nick Shaw

  • Posts: 237
  • Joined: Thu Sep 13, 2012 11:43 am
  • Location: London, UK

Re: Python scripting in Resolve 15

PostMon Apr 23, 2018 3:25 pm

Has anybody found out if there are any methods enabled in Resolve scripting which are not listed in the ReadMe? Particularly ones for rendering.
Workflow Consultant, London UK
LUTs and LUT plugins
www.antlerpost.com
Online
User avatar

roger.magnusson

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

Re: Python scripting in Resolve 15

PostWed May 02, 2018 2:41 pm

I can't answer the question but I hope it's ok to use this thread for general Python scripting feedback as well.

The DaVinci Resolve Beta 2 Python scripting documentation in %ProgramData%\Blackmagic Design\DaVinci Resolve\Support\Developer\Scripting\README.txt has some mistakes in the environment variables for Windows.

It says:
Code: Select all
Windows:
RESOLVE_SCRIPT_API="%PROGRAMDATA%\\Blackmagic Design\\DaVinci Resolve\\Support\\Developer\\Scripting\\"
RESOLVE_SCRIPT_LIB="C:\\Program Files\\Blackmagic Design\\DaVinci Resolve\\fusionscript.so"
PYTHONPATH="%PYTHONPATH%:%RESOLVE_SCRIPT_API%\\Modules\\"
But it should probably be:
Code: Select all
Windows:
RESOLVE_SCRIPT_API="%PROGRAMDATA%\\Blackmagic Design\\DaVinci Resolve\\Support\\Developer\\Scripting\\"
RESOLVE_SCRIPT_LIB="C:\\Program Files\\Blackmagic Design\\DaVinci Resolve\\fusionscript.dll"
PYTHONPATH="%PYTHONPATH%;%RESOLVE_SCRIPT_API%\\Modules\\"

That's ".dll" at the end of the second variable, and a semicolon instead of a colon as a separator in the third variable (the Windows "Environment Variables" built-in GUI editor needs semicolon or it won't function properly).
Offline
User avatar

Igor Riđanović

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

Re: Python scripting in Resolve 15

PostSat May 05, 2018 6:40 am

I spent a couple of hours testing it yesterday. It's pretty cool.

Yes, there is an error in readme.txt in the description of the Windows environment variables. Depending on how you create the variables the double slashes may also need to go. For example, of you use the whatever-it's-called Windows 10 GUI tool to define the variables, you need to use the single slashes.

Also, you can't define:

Code: Select all
PYTHONPATH="%PYTHONPATH%:%RESOLVE_SCRIPT_API%\\Modules\\"


Because the variables are sorted alphabetically and %RESOLVE_SCRIPT_API% does not exist until after %PYTHONPATH%.

Instead I defined mine as somewhat less flexible, but acceptable:

Code: Select all
PYTHONPATH = %PYTHONPATH%;C:\ProgramData\Blackmagic Design\DaVinci Resolve\Support\Developer\Scripting\Modules\
www.metafide.com - DaVinci Resolve™ Apps
Offline
User avatar

Igor Riđanović

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

Re: Python scripting in Resolve 15

PostSat May 05, 2018 7:12 am

Nick Shaw wrote:Has anybody found out if there are any methods enabled in Resolve scripting which are not listed in the ReadMe? Particularly ones for rendering.


I may have seen something in the two sample .py scripts that was not listed in the API documentation. Also, the doc itself said that the methods listed were "often used" which would imply there are other ones. I haven't seen anything render oriented so far.

I've never needed to dig into a class looking for undocumented methods, but i think the Python inspect module does that.

The DaVinciResolveScript.py module is sort of passed right through to the fusionscript.dll or fusionscript.so on OSX/Linux. Reverse engineering library binaries looking for Python code is not the best way to do it.

I was initially unable to import the module and instantiate the class objects from the built in console in Fusion. I tried it only once before I set my system environment variables. After that it worked. But I understood the API documentation saying that it's not necessary to set the variables if you're using the built in console, but that's not how it worked for me.

After seeing that it worked I just used the Windows command line instead. I like the way Python interpreter echoes in the OS console better than the behavior in the Fusion console.

I have had some slowdowns. Particularly after creating a new timeline from existing media pool clips and appending it with clips Resolve would become sluggish to the point it needed a restart. On one occasion I had to kill the process to shut it down.

Reading existing clip metadata reading worked, but writing to clip metadata didn't seem to work well. I would write metadata, and could read it back from the command line, but the metadata panel in Resolve would still show the pre-existing metadata.

I love the ability to create a project, bins, populate with clips, and even conform timelines programmatically. We heavily rely on such automation for Media Composer project creation. It saves a ton of time on complex projects.

I made a couple of proof-of-concept apps wrapped in Qt that demo the API capabilities. I'll be putting out a scripting video tutorial in the coming weeks.
www.metafide.com - DaVinci Resolve™ Apps
Offline
User avatar

Igor Riđanović

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

Re: Python scripting in Resolve 15

PostMon May 07, 2018 8:29 pm

Here are several Resolve scripting Python tests i put together. The two examples installed by the V15 are very good for understanding the API usage.

https://github.com/IgorRidanovic/DaVinc ... ClipLister
https://github.com/IgorRidanovic/DaVinc ... ageFlipper
https://github.com/IgorRidanovic/DaVinc ... geSwitcher
www.metafide.com - DaVinci Resolve™ Apps
Online
User avatar

roger.magnusson

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

Re: Python scripting in Resolve 15

PostTue May 08, 2018 8:35 am

Nice, I've been meaning to check out the QT framework and this will be a good starting point.

@BMD, is there any chance you will publish the header file for fusionscript.dll so that we can use it in other languages/technologies as well? Or even better, a .NET Core managed dll.
Offline
User avatar

Igor Riđanović

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

Re: Python scripting in Resolve 15

PostTue May 08, 2018 3:40 pm

You could spend many, many months learning the intricacies of Qt and the learning curve is steep. But the payback is significant. But before you dive into it, check this discussion of the stripped down Qt that's provided as a part of Fuscript. I haven't tried it myself yet. The advantages are the simplicity and the UI style inherited from Resolve.

I don't know if such apps could be portable and usable on a non-Resolve machine. You'd have to make sure all the dependencies are included in the package which is easy with Qt.

https://www.steakunderwater.com/wesuckl ... 1&start=15
www.metafide.com - DaVinci Resolve™ Apps
Offline

Chip.Murphy

  • Posts: 167
  • Joined: Wed Mar 08, 2017 5:59 pm

Re: Python scripting in Resolve 15

PostSat May 19, 2018 5:58 am

Igor Riđanović wrote:Here are several Resolve scripting Python tests i put together. The two examples installed by the V15 are very good for understanding the API usage.

https://github.com/IgorRidanovic/DaVinc ... ClipLister
https://github.com/IgorRidanovic/DaVinc ... ageFlipper
https://github.com/IgorRidanovic/DaVinc ... geSwitcher


Igor, these are awesome.

Super curious to see your python script that has SetMetadata at some point. Were you able to set specific metadata?

This could be super useful for CatDV users. A script to just pull in a CSV without having to go through the import metadata function would be great.
Offline

Tom Early

  • Posts: 2664
  • Joined: Wed Jul 17, 2013 11:01 am

Re: Python scripting in Resolve 15

PostSat May 19, 2018 10:18 am

Nick Shaw wrote:project.SetResolution(2048, 1152) sets the Timeline Resolution (as shown in the Project Settings panel) to 2048x1152, but then running timeline = mediapool.CreateEmptyTimeline("Test Timeline 1") creates a new timeline which is still 1920x1080, per defaults. But if the resolution is set via scripting, creating a new timeline by pressing CMD-N also produces a 1080p timeline, so maybe there is somewhere else that I need to set it to 2k as well.


Thr Mediapool timeline resolution column will display whatever resolution is set in Output Scaling
MBP2021 M1 Max 64GB, macOS 14.4, Resolve Studio 18.6.6 build 7
Output: UltraStudio 4K Mini, Desktop Video 12.7
Offline

GeeOBCR

  • Posts: 1
  • Joined: Fri Jun 15, 2018 10:54 am
  • Real Name: George Antonopoulos

Re: Python scripting in Resolve 15

PostFri Jun 15, 2018 11:04 am

Hi, just wondering if you had any luck with initialising the Resolve side of scripting,

I can't get past DaVinciResolveScript.scriptapp("Resolve"), even though Fusion works,
I've tried Nick's suggestion of launching fuscript on interactive mode but that hasn't helped.

I'm on Windows so don't know if that plays a part as well,

Thanks for reading!

George
Offline

Framestamp

  • Posts: 3
  • Joined: Mon Jun 25, 2018 7:33 pm
  • Real Name: Gilles de Saint-Aubert

Re: Python scripting in Resolve 15

PostMon Jun 25, 2018 7:45 pm

GeeOBCR wrote:Hi, just wondering if you had any luck with initialising the Resolve side of scripting,

I can't get past DaVinciResolveScript.scriptapp("Resolve"), even though Fusion works,
I've tried Nick's suggestion of launching fuscript on interactive mode but that hasn't helped.

I'm on Windows so don't know if that plays a part as well,

Thanks for reading!

George

Hi,

I'm having the same issue (Win 10).
However, I'm running the free version of Resolve 15 (beta 5). As there there is no option for scripting in the Preference menu, I'm suspecting Scripting is only available using the Studio version. Can anybody confirm ?

As mentioned at steakunderwater.com :
If you open Resolve's System > Configuration section there is an External Scripting Using control that can be configured to allow remote systems to control and automate the Resolve GUI session using fuscript. You have the choice of selecting "None", "Local", or "Network" in this menu.

I do not see this option in my settings.

Thanks.
Offline
User avatar

Igor Riđanović

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

Re: Python scripting in Resolve 15

PostWed Jun 27, 2018 3:38 pm

Chip.Murphy wrote:Super curious to see your python script that has SetMetadata at some point. Were you able to set specific metadata?

This could be super useful for CatDV users. A script to just pull in a CSV without having to go through the import metadata function would be great.


It wasn't a script. I only tested that in an interactive Python interpreter session. And it was back in April on beta 1.

I was able to read metadata written in Resolve. I was also able to write and read metadata from Python, but i could not read that metadata in Resolve.
www.metafide.com - DaVinci Resolve™ Apps
Offline
User avatar

Igor Riđanović

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

Re: Python scripting in Resolve 15

PostWed Jun 27, 2018 3:53 pm

GeeOBCR wrote:
I'm on Windows so don't know if that plays a part as well,


Do you get any specific response in the console when you try this?

Windows is not a factor, except that it doesn't come with Python preinstalled. I haven't tried it, but I don't see how the Fusion console would work in Python if the interpreter is missing. Lua is installed with Fusion.

Did you add the path to the module to the $PATH environment variable?
www.metafide.com - DaVinci Resolve™ Apps
Offline

Rodion Zhabrev

  • Posts: 4
  • Joined: Fri Sep 28, 2012 9:11 am

Re: Python scripting in Resolve 15

PostMon Jul 02, 2018 8:32 pm

Hello,

Can't understand what am I doing wrong. After setting Variables in Windows as mentioned above still getting "Could not locate module dependencies" error on importing DaVinciResolveScript.

It's my first time setting variables so maybe I did something terribly wrong.
Offline

im.thatoneguy

  • Posts: 20
  • Joined: Fri Jul 06, 2018 11:52 pm
  • Real Name: Gavin Greenwalt

Re: Python scripting in Resolve 15

PostFri Jul 06, 2018 11:55 pm

I can't get it to work on windows either.

If I run scriptapp("Fusion") it works.
FusionUI (0x000002884A77A020) [App: 'Fusion' on 127.0.0.1, UUID: 750f52fb-0a45-40d9-ade8-c68e975277a0]

if I run scriptapp("Resolve")
None

I tried setting the Environment Variables and I tried doing it pragramatically through Python in the python shell.

I tried in the Console. I tried in IDLE ad I tried through fuscript with the same result.
Offline

Val Gameiro

  • Posts: 83
  • Joined: Thu May 02, 2013 11:42 pm
  • Location: Austin, Texas

Re: Python scripting in Resolve 15

PostThu Jul 12, 2018 7:02 pm

Ok, after a lot of back and forth and research, I got Resolve 15 scripting to stop giving me errors, but it's still not working.

First, I tried running lines from the DaVinciResolveScript.py directly in python to help find the problem.

Code: Select all
script_module = None
-- ran fine

Code: Select all
import fusionscript as script_module
-- gave "no module named 'fusionscript'

Code: Select all
>>> lib_path=os.getenv("RESOLVE_SCRIPT_LIB")
>>> print(lib_path)
"C:\Program Files\Blackmagic Design\DaVinci Resolve Beta\fusionscript.dll"


So, that worked fine.

And here it tanked:
Code: Select all
script_module = imp.load_dynamic("fusionscript", lib_path)


"ImportError: DLL load failed: The specified module could not be found."

But I knew the file was there. I could see it.

Finally, the problem turned out to be that the sys env variable had to have double backslashes in order for it to work:

script_module = imp.load_dynamic("fusionscript", "C:\\Program Files\\Blackmagic Design\\DaVinci Resolve Beta\\fusionscript.dll")

So, I went to System Properties / Advanced / Environment Variables, and made the change.

Here are my env vars -- you'll notice I'm running the Beta concurrently with v14, so I will have to update these vars once I upgrade to the final release:

Code: Select all
RESOLVE_SCRIPT_API=C:\ProgramData\Blackmagic Design\DaVinci Resolve\Support\Developer\Scripting\
RESOLVE_SCRIPT_LIB="C:\\Program Files\\Blackmagic Design\\DaVinci Resolve Beta\\fusionscript.dll"


But, even with all that, and manually running each statement from the DaVinciResolveScript.py, I'm still stuck.

Basically, after I run
Code: Select all
sys.modules[__name__] = script_module
it seems to lose all the imports and variables, and I can't load them back.

For instance, if I try
Code: Select all
import sys
I get an ImportError:

Code: Select all
ImportError: __import__ not found


Anybody had any luck? Not sure where to go from here. It seemed, at first, that it was working (once the errors disappeared) but I can't run statements.

Code: Select all
resolve = script_module.scriptapp('Resolve')
pm = resolve.GetProjectManager()
Val Gameiro
Writer/Director/Filmmaker
Austin, Texas
http://www.AmnesiaTheMovie.com
http://www.ValGameiro.com
http://www.IdealSceneProductions.com
http://www.TXSTARentertainment.com

Resolve 16.1.1 64bit Windows 10 Pro MS Surface Book 2 16GB RAM GTX 1050
Offline
User avatar

Igor Riđanović

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

Re: Python scripting in Resolve 15

PostFri Jul 13, 2018 2:30 am

Are you saying that
Code: Select all
import sys

on your machine returns an error? If that's correct, you should reinstall Python. Something is botched and it has nothing to do with Resolve.

Other than that, the scripting definitely works on all public beta releases so far. Look up getresolve.py that's installed in the developer directory. Actually, I'm not sure if this is the original name or if I renamed my customized version. Either way, this script will show you the best way to load the API.

It evaluates the host OS, attempts to import DaVinciResolveScript using your system envirnoment variables, and if the variables are not set it uses the imp module to import DaVinciResolveScript from semi-hard coded paths where this file is most likely to be found.

Or you can forget the all of this and just use imp for brute force loading, but your script will not be cross platform compatible. Here is the Windows compatible hard coded version:
Code: Select all
# loading without sys env variables
import imp
dr = imp.load_source('DaVinciResolveScript', 'C:\ProgramData\Blackmagic Design\DaVinci Resolve\Support\Developer\Scripting\Modules\DaVinciResolveScript.py')
resolve = dr.scriptapp('Resolve')
www.metafide.com - DaVinci Resolve™ Apps
Offline

Val Gameiro

  • Posts: 83
  • Joined: Thu May 02, 2013 11:42 pm
  • Location: Austin, Texas

Re: Python scripting in Resolve 15

PostFri Jul 13, 2018 1:44 pm

Well, let me explain.

The "import sys" doesn't fail at first, only when I manually try to execute the python commands in the DavinciResolveScript.py.

Specifically after sys.modules call:

Code: Select all
script_module = imp.load_dynamic("fusionscript", "C:\\Program Files\\Blackmagic Design\\DaVinci Resolve Beta\\fusionscript.dll")
sys.modules[__name__] = script_module


But, if I restart the interpreter, then it goes back to working fine.

By the way, I really enjoyed your video on Resolve 15 scripting! :)
Val Gameiro
Writer/Director/Filmmaker
Austin, Texas
http://www.AmnesiaTheMovie.com
http://www.ValGameiro.com
http://www.IdealSceneProductions.com
http://www.TXSTARentertainment.com

Resolve 16.1.1 64bit Windows 10 Pro MS Surface Book 2 16GB RAM GTX 1050
Offline

Rodion Zhabrev

  • Posts: 4
  • Joined: Fri Sep 28, 2012 9:11 am

Re: Python scripting in Resolve 15

PostMon Aug 06, 2018 9:56 am

Rodion Zhabrev wrote:Hello,

Can't understand what am I doing wrong. After setting Variables in Windows as mentioned above still getting "Could not locate module dependencies" error on importing DaVinciResolveScript.

It's my first time setting variables so maybe I did something terribly wrong.


Answering my own question. The problem was I used 32bit Python. With 64bit one no more "Could not locate module dependencies" however Python crashes with Segmentation Error every time on module import. Tried on fresh installed windows just now.

Any ideas?
Offline

MarcusWolschon

  • Posts: 801
  • Joined: Sun Apr 14, 2013 6:59 pm

Re: Python scripting in Resolve 15

PostThu Sep 06, 2018 5:29 pm

Any new insight into that
Code: Select all
AttributeError: 'NoneType' object has no attribute 'GetProjectManager'

issue?

I'm stuck at the same point for days now.
I understand that for you it just randomly started working after a reboot?

Are your environment variables set system-wide or only in the console where you execute the script?
Offline
User avatar

Igor Riđanović

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

Re: Python scripting in Resolve 15

PostThu Sep 06, 2018 6:14 pm

You probably have something like this:

Code: Select all
projectmanager =  resolve.GetProjectManager()


You're getting the Attribute Error because your 'resolve' instance (or whatever you named it) is not defined as in 'NoneType.'

Can you post the lines that precede the above statement?
www.metafide.com - DaVinci Resolve™ Apps
Offline

MarcusWolschon

  • Posts: 801
  • Joined: Sun Apr 14, 2013 6:59 pm

Re: Python scripting in Resolve 15

PostThu Sep 06, 2018 6:26 pm

Igor Riđanović wrote:Can you post the lines that precede the above statement?


I'm still just trying to just get the examples to work.
In this case
5_get_project_information.py
using
python_get_resolve.py
Offline

firegreen

  • Posts: 7
  • Joined: Thu Oct 04, 2018 2:38 pm
  • Real Name: Steeve VINCENT

Re: Python scripting in Resolve 15

PostThu Oct 04, 2018 3:30 pm

Hi,

I'm trying to use Python Scripting but with no success. Well, more or less...
I correctly set the environment variables, Resolve recognizes them and when I use the Resolve API in the console, it works fine.
But when I try to execute a script from the file system (by drag/drop or from Resolve script list), it doesn't work anymore.
In the same way, when I use fuscript for scripting locally, it fails to get Resolve or Fusion via scriptapp (but I do manage to ping Fusion).
So in my opinion, I might need to use the "External Scripting Using" parameter in order to run my scripts, but I cannot find this setting :(.

Thanks for your replies.

captureResolve.png
captureResolve.png (588.22 KiB) Viewed 20675 times

I'm using the last free version for windows (15.1.1)
Offline
User avatar

Igor Riđanović

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

Re: Python scripting in Resolve 15

PostThu Oct 04, 2018 8:03 pm

I'm using the last free version for windows (15.1.1)


That may be a part of your problem. Scripting support is limited in the free version.

The "External Scripting Using" set to "local", which I think is default, allows me to drag and drop .py files onto the built-in console. When I set mine to "none" I get the same result as you.

This parameter control is located in sytem-wide preferences (CTRL+,).
www.metafide.com - DaVinci Resolve™ Apps
Offline

Martin Schitter

  • Posts: 899
  • Joined: Tue Apr 28, 2015 10:41 pm

Re: Python scripting in Resolve 15

PostThu Oct 04, 2018 11:18 pm

Igor Riđanović wrote:That may be a part of your problem. Scripting support is limited in the free version.


it's in fact so much crippled, that it's hardly usable at all...
Offline

firegreen

  • Posts: 7
  • Joined: Thu Oct 04, 2018 2:38 pm
  • Real Name: Steeve VINCENT

Re: Python scripting in Resolve 15

PostFri Oct 05, 2018 5:02 pm

I see.
Thanks for your help :).

I will use the console for now, but I'm facing another issue.
Most of the posts from the forum deal with scripting in Lua, but I need to use Python instead.
Are there other topics where I can find support in Python or should I continue to ask questions here?
Offline
User avatar

Igor Riđanović

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

Re: Python scripting in Resolve 15

PostMon Oct 08, 2018 7:54 pm

firegreen wrote:I see.
Thanks for your help :).

I will use the console for now, but I'm facing another issue.
Most of the posts from the forum deal with scripting in Lua, but I need to use Python instead.
Are there other topics where I can find support in Python or should I continue to ask questions here?


This BMD forum has the most salient discussion of the scripting as far as I can tell.

There is a very knowledgeable community at https://www.steakunderwater.com/wesuckless/, although they seem to favorite Lua over Python somewhat, and their primary concern is making sure they can continue using Fusion as a VFX tool after the merge with Python.

There is also a Slack channel dedicated to Resolve scripting but it doesn't see much action.
www.metafide.com - DaVinci Resolve™ Apps
Offline

firegreen

  • Posts: 7
  • Joined: Thu Oct 04, 2018 2:38 pm
  • Real Name: Steeve VINCENT

Re: Python scripting in Resolve 15

PostWed Oct 10, 2018 11:22 am

Indeed the "wesuckless" forum has been very useful (too bad it lacks of a searching feature). I did manage to get a working Python script from their Lua examples.

In case it may help others, here is my test for scripting in Resolve (only for Windows, sorry). Just call run_resolve.py to launch Resolve with a configured environment.
resolve_python_test.zip
(2.8 KiB) Downloaded 728 times
Offline

firegreen

  • Posts: 7
  • Joined: Thu Oct 04, 2018 2:38 pm
  • Real Name: Steeve VINCENT

Re: Python scripting in Resolve 15

PostWed Oct 10, 2018 11:23 am

resolve_capt2.PNG
resolve_capt2.PNG (121.23 KiB) Viewed 20502 times

tonyflorida

Re: Python scripting in Resolve 15

PostTue Nov 20, 2018 1:37 am

Rodion Zhabrev wrote:
Rodion Zhabrev wrote:Hello,

Can't understand what am I doing wrong. After setting Variables in Windows as mentioned above still getting "Could not locate module dependencies" error on importing DaVinciResolveScript.

It's my first time setting variables so maybe I did something terribly wrong.


Answering my own question. The problem was I used 32bit Python. With 64bit one no more "Could not locate module dependencies" however Python crashes with Segmentation Error every time on module import. Tried on fresh installed windows just now.

Any ideas?


I'm running into the "Segmentation fault: 11" error as well on my Mac running Mojave when trying to
Code: Select all
import DaVinciResolveScript
.

It seems this error is caused by line 14 of the DaVinciResolveScript.py file:

Code: Select all
script_module = imp.load_dynamic("fusionscript", lib_path)


I tried modifying the DaVinciResolveScript.py script according to a suggestion on Lift Gamma Gain, but no luck :cry:

Code: Select all
 import importlib.machinery
lib_path = os.environ.get('RESOLVE_SCRIPT_LIB')
loader = importlib.machinery.ExtensionFileLoader('fusionscript', lib_path)
module = loader.load_module()


Were you able to find a solution for this?
Offline

Steve Swisz

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

Re: Python scripting in Resolve 15

PostTue Apr 09, 2019 8:05 pm

Anyone got this working on a MAC - Free Version Resolve - Python 2.7.14
We want to run our commands from Terminal not in this CONSOLE Resolve built.

Thanks Guys, We did try this on the paid version and updated to Python 3 but still having issues?

It seems simple enough what we want to create a Python Script that will allow us to pull Directory into Resolve maintain folder path structure, add some Metadata to those clips, then create a timeline, and auto Deliver some out of Resolve.

We receive an insane amount of Camera Raw and Temp VFX, using Python to Automating these steps would be fantastic.
Offline
User avatar

Roel Videler

  • Posts: 96
  • Joined: Mon Dec 21, 2015 10:50 am
  • Location: Amsterdam, Netherlands

Re: Python scripting in Resolve 15

PostThu Aug 15, 2019 1:53 pm

Getting this to work was a pain in the butt. And I'm not even sure if it's really working now, but I'll take what I can get. My #1 requested feature for this would be to retrieve the thumbnails of the memories. This is not a feature that's likely to come to any of the panels anytime, so us diy-ers with a mini + streamdeck setup would love to get one up on filmlight by getting those memories on the Streamdeck. Same would go for timeline thumbs. This opens up more possibilities for in-house scripting and feedback systems.

Also, just a way to directly command the keyboard interface. I.e. you can use OpenPage as a function, but it'd be just as useful to call the function as listed in the keyboard customization. For instance: Command.Workspace.ShowPage.Color() Or something. That would allow -every- function that can be keyboard bound to be scriptable and accessible even if Resolve is not in the foreground.

Of course I/we'd love to see this more easily integrated, but I'm just really happy this is happening now. Thanks BMD!
DaVinci Resolve Studio 17
HP Z640, Mini Panel, Windows 10 Pro x64, 2x Intel E5-26something, 64GB, Mini Monitor 4K, GTX1080Ti

Return to DaVinci Resolve

Who is online

Users browsing this forum: 4EvrYng, Baidu [Spider], Bing [Bot], Kilin3110, peeceful, Simnut and 146 guests