Resolve API Render Call Crash

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

TimElschner

  • Posts: 38
  • Joined: Mon Nov 12, 2018 2:46 pm
  • Real Name: Tim Elschner

Resolve API Render Call Crash

PostThu Mar 14, 2019 8:28 am

We are trying to write a script for Resolve that renders a timeline using the following code:


import DaVinciResolveScript as dvr_script
resolve = dvr_script.scriptapp("Resolve")
print(resolve)
projectManager = resolve.GetProjectManager()
print(projectManager)
project = projectManager.GetCurrentProject()
print(project)

#'seq_050'
timeline = project.GetTimelineByIndex(3)
print(timeline)
resolve.OpenPage("Deliver")
project.DeleteAllRenderJobs()
project.SetPreset("ProRes Master")
project.SetCurrentTimeline(timeline)
project.SetRenderSettings({"SelectAllFrames": 1, "TargetDir" : "H:/test"})
project.AddRenderJob()
project.StartRendering()



Looking at the Reolve GUI, eveything seem fine, the timeline is added the Render Queue. But, as soon as project.StartRendering() is executed via script, the „Start Render“ button changes to „Stop“, but I get a message box with



„Render jobs for {projectname} are not complete. Would you like to cancel…“ Any button press causes the program to crash.


Bizarrely, if I exclude „project.StartRendering()“ from the code and leave everything else in, Resolve renders the timeline just fine if I manually press the „Start Render“ button.

Any help really appreciated!
Offline

Dermot Shane

  • Posts: 2740
  • Joined: Tue Nov 11, 2014 6:48 pm
  • Location: Vancouver, Canada

Re: Resolve API Render Call Crash

PostThu Mar 14, 2019 2:43 pm

clever script!
Offline

TimElschner

  • Posts: 38
  • Joined: Mon Nov 12, 2018 2:46 pm
  • Real Name: Tim Elschner

Re: Resolve API Render Call Crash

PostThu Mar 14, 2019 2:44 pm

Dermot Shane wrote:clever script!


was this irony ? because it crashes...
Offline

Dermot Shane

  • Posts: 2740
  • Joined: Tue Nov 11, 2014 6:48 pm
  • Location: Vancouver, Canada

Re: Resolve API Render Call Crash

PostThu Mar 14, 2019 5:41 pm

no...
once it's sorted, it's a very simple / fool proof way of getting renders done, bypassing the chance of an overly tired assist pressing the wrong button late at night

i still think it's clever.... even as a work in progress
Offline

TimElschner

  • Posts: 38
  • Joined: Mon Nov 12, 2018 2:46 pm
  • Real Name: Tim Elschner

Re: Resolve API Render Call Crash

PostThu Mar 14, 2019 6:06 pm

well then lets hope some of the BMD developers reads this thread an fixes the bug or pointing out what we are doing wrong...
Offline
User avatar

Igor Riđanović

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

Re: Resolve API Render Call Crash

PostThu Mar 14, 2019 6:46 pm

I assume your host OS is MacOS or Linux based on the "Prores" in the name of the preset.

Could it be that the Windows-like path "H:/test" is throwing a kink in the system? The slash is a Posix style slash used with a Windows style mount point.

Resolve's paths are somewhat slash-type agnostic across platforms. But I don't know if this extends to the scripting API. Still, this would not explain why you can manually start the render and StartRendering() fails.
www.metafide.com - DaVinci Resolve™ Apps
Offline

TimElschner

  • Posts: 38
  • Joined: Mon Nov 12, 2018 2:46 pm
  • Real Name: Tim Elschner

Re: Resolve API Render Call Crash

PostFri Mar 15, 2019 7:13 am

Its a PC the presetname was just the name. Unfortunately I really think its a bug, since I have no clue what should be the difference when it works with the button press
Offline

Peter Chamberlain

Blackmagic Design

  • Posts: 13944
  • Joined: Wed Aug 22, 2012 7:08 am

Re: Resolve API Render Call Crash

PostFri Mar 15, 2019 7:24 am

Resolve on Windows does not render ProRes.
Are you trying to do that?
DaVinci Resolve Product Manager
Offline

TimElschner

  • Posts: 38
  • Joined: Mon Nov 12, 2018 2:46 pm
  • Real Name: Tim Elschner

Re: Resolve API Render Call Crash

PostFri Mar 15, 2019 7:32 am

Peter Chamberlain wrote:Resolve on Windows does not render ProRes.
Are you trying to do that?


Hi Peter,
thanks for the reply! It does not change anything when we remove the line. You can check for yourself:

import DaVinciResolveScript as dvr_script
resolve = dvr_script.scriptapp("Resolve")
print(resolve)
projectManager = resolve.GetProjectManager()
print(projectManager)
project = projectManager.GetCurrentProject()
print(project)

#'seq_050'
timeline = project.GetTimelineByIndex(3)
print(timeline)
resolve.OpenPage("Deliver")
project.DeleteAllRenderJobs()
project.SetCurrentTimeline(timeline)
project.SetRenderSettings({"SelectAllFrames": 1, "TargetDir" : "H:/test"})
project.AddRenderJob()
project.StartRendering()


As mentioned when we remove "project.StartRendering()" and just press the physical button everything works fine.

Any help really appreciated!
Thanks a bunch!
Tim
Offline
User avatar

roger.magnusson

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

Re: Resolve API Render Call Crash

PostFri Mar 15, 2019 7:45 am

I don't have Python installed, but the same script in Lua works fine. Forward slash like you use in TargetDir should work on Windows, but have you tried double backslashes instead just to make sure?

Here's a Lua version
Code: Select all
resolve = Resolve()
projectManager = resolve:GetProjectManager()
project = projectManager:GetCurrentProject()

timeline = project:GetTimelineByIndex(3)
resolve:OpenPage("Deliver")
project:DeleteAllRenderJobs()
project:SetCurrentTimeline(timeline)
project:SetRenderSettings({ SelectAllFrames = 1, TargetDir = [[C:\temp]] })
project:AddRenderJob()
project:StartRendering()

By the way, when you execute methods for the Deliver page Resolve will automatically switch to that page, so no need for the OpenPage method.
Offline

TimElschner

  • Posts: 38
  • Joined: Mon Nov 12, 2018 2:46 pm
  • Real Name: Tim Elschner

Re: Resolve API Render Call Crash

PostFri Mar 15, 2019 8:10 am

Hi Roger,
thanks for your reply! Unfortunately we have to connect from outside to the running resolve instance. To my knowledge I just can run LUA code inside of resolve, is this correct?

Best
Tim
Offline

Rohit Gupta

Blackmagic Design

  • Posts: 1631
  • Joined: Wed Aug 22, 2012 5:00 am

Re: Resolve API Render Call Crash

PostFri Mar 15, 2019 8:10 am

Can you post your project or send me a link to it please (PM)?
Rohit Gupta

DaVinci Resolve Software Development
Blackmagic Design
Offline
User avatar

roger.magnusson

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

Re: Resolve API Render Call Crash

PostFri Mar 15, 2019 8:57 am

TimElschner wrote:Hi Roger,
thanks for your reply! Unfortunately we have to connect from outside to the running resolve instance. To my knowledge I just can run LUA code inside of resolve, is this correct?

Best
Tim

No, you can run external Lua (and Python) scripts in the Studio version of Resolve using %ProgramFiles%\Blackmagic Design\DaVinci Resolve\fuscript.exe
Offline

martinrushworth

  • Posts: 4
  • Joined: Fri Mar 15, 2019 9:52 pm
  • Real Name: Martin Rushworth

Re: Resolve API Render Call Crash

PostFri Mar 15, 2019 10:04 pm

When I looked at this late last year, I found it didn't work headless, i.e. with Resolve.exe -rr

But it worked with the GUI open.

Resolve Studio 15.2.0.033

I'd be more interested in rendering with Resolve if you could render headless. This kind of thing worked for me that's a little different to what you have...

renderFormat = "mov"
renderCodec = "DNxHD1080p36"
outputFilename = "Test-Resolve"
targetDirectory = "C:\"
project.SetCurrentRenderFormatAndCodec(renderFormat, renderCodec):
project.SetRenderSettings({"SelectAllFrames" : 1, "TargetDir" : targetDirectory, "CustomName" : outputFilename}):
project.StartRendering():
while project.IsRenderingInProgress():
print("rendering in progress")
time.sleep(1)
Offline

TimElschner

  • Posts: 38
  • Joined: Mon Nov 12, 2018 2:46 pm
  • Real Name: Tim Elschner

Re: Resolve API Render Call Crash

PostSat Mar 16, 2019 8:24 am

Headless would be indeed the best solution! Did you remember what was the issue in the past?
I will try your code and report back!
Many Thanks
Tim
Offline

TimElschner

  • Posts: 38
  • Joined: Mon Nov 12, 2018 2:46 pm
  • Real Name: Tim Elschner

Re: Resolve API Render Call Crash

PostMon Mar 18, 2019 8:59 am

Here is a Demo Project that demonstrates the API call crash.

Any help really appreciated
Attachments
API_rendertest.zip
(143.28 KiB) Downloaded 73 times
Offline
User avatar

roger.magnusson

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

Re: Resolve API Render Call Crash

PostMon Mar 18, 2019 9:52 am

I installed Python v3.6.8 and your script runs fine on my machine with your project. It renders 154 exr frames.

Sorry, no idea why it's not working for you. The only thing I can think of is if you're running through remote desktop. Then the GPU might not be correctly initialized and rendering can't start.
Offline

TimElschner

  • Posts: 38
  • Joined: Mon Nov 12, 2018 2:46 pm
  • Real Name: Tim Elschner

Re: Resolve API Render Call Crash

PostMon Mar 18, 2019 10:37 am

Hi Roger,
thats strange, I tried it on several machines with no remote Desktop and Also with Python 3.6.8.
Same crash on every machine with Dialog Screen (see attachment)

I am on a Windows 10 machine by the way. Are you on MAC ?
Attachments
API_crash.JPG
API_crash.JPG (197.53 KiB) Viewed 3518 times
Offline
User avatar

roger.magnusson

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

Re: Resolve API Render Call Crash

PostMon Mar 18, 2019 11:11 am

No, this was on Windows 10 as well. Resolve Studio v15.3.

PythonRendering.png
PythonRendering.png (252.18 KiB) Viewed 3510 times
Offline

TimElschner

  • Posts: 38
  • Joined: Mon Nov 12, 2018 2:46 pm
  • Real Name: Tim Elschner

Re: Resolve API Render Call Crash

PostMon Mar 18, 2019 11:15 am

:shock:

Thats so weird.... now I dive into the dxDiag again....

Are you on nVidia GPU or AMD?
Offline
User avatar

roger.magnusson

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

Re: Resolve API Render Call Crash

PostMon Mar 18, 2019 11:34 am

This is just a small dev machine without a dedicated GPU, so it's an integrated Intel GPU. Can't test on my workstation right now, but I've not seen that issue on any of my machines earlier (Windows 10 with nVidia GPUs, Mac Mini 2018, MacBook Pro 2015).
Offline

TimElschner

  • Posts: 38
  • Joined: Mon Nov 12, 2018 2:46 pm
  • Real Name: Tim Elschner

Re: Resolve API Render Call Crash

PostMon Mar 18, 2019 11:37 am

Okaaayyyy.. Closing in on this Issue, it happens when you are on a PostgresSQL Database, it renders when the project is imported in the local databases...
@BMD Any ideas what might cause this crash on the Collaborated PostGresSQL Database Connection?
Offline

TimElschner

  • Posts: 38
  • Joined: Mon Nov 12, 2018 2:46 pm
  • Real Name: Tim Elschner

Re: Resolve API Render Call Crash

PostWed Mar 20, 2019 7:44 am

Since I could verify that the API Rendercall crash happens when one uses a PostgreSQL Database connection instead of a local one, are there any ideas how to solve this issue or does this qualify as a bug?
Offline
User avatar

roger.magnusson

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

Re: Resolve API Render Call Crash

PostWed Mar 20, 2019 9:37 am

I tried both a disk database and a remote PostgreSQL database without issues. Haven't tried a local PostgreSQL though.
Offline

TimElschner

  • Posts: 38
  • Joined: Mon Nov 12, 2018 2:46 pm
  • Real Name: Tim Elschner

Re: Resolve API Render Call Crash

PostWed Mar 20, 2019 10:08 am

Hi Roger,
how did you setup your remote postgresSQL ? What version did you use and on what system did you run it?
Thanks
Tim
Offline
User avatar

roger.magnusson

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

Re: Resolve API Render Call Crash

PostWed Mar 20, 2019 11:05 am

The remote database was installed/configured by the DaVinci Resolve 15 installer on a Mac Mini. Not sure which version Resolve uses nowadays. According to the download page it's v9.5.4: "Starting from DaVinci Resolve 12.5.3, new installations will include PostgreSQL version 9.5.4."

Could it be a software firewall issue?
Offline

TimElschner

  • Posts: 38
  • Joined: Mon Nov 12, 2018 2:46 pm
  • Real Name: Tim Elschner

Re: Resolve API Render Call Crash

PostWed Mar 20, 2019 1:01 pm

Thanks Roger!

we have installed postgres 10.5 on windows server 2016

https://www.enterprisedb.com/downloads/ ... -downloads

I will look into the firewall matter, but the connection to the database works normal and I still can press the start render button manually. So I am wondering in what way the API call project.StartRendering(): differs from manual pressing the button..

@BlackmagicDesign
are there any compatibility issues with the windows Version of postgres or a version conflicts, that might cause the crash?

Addendum: Just tested it the a linux connected postrgres database on a qnap with the same error
Offline

TimElschner

  • Posts: 38
  • Joined: Mon Nov 12, 2018 2:46 pm
  • Real Name: Tim Elschner

Re: Resolve API Render Call Crash

PostWed Mar 20, 2019 1:31 pm

Dear BlackMagickDesign Developers,

Cleaning all logs and starting fresh,
attached you will find log files

It crahes
[0x000049b4] | BtCommon | FATAL | 2019-03-20 14:21:47,612 | Error: Incorrect mutex locking order detected
[0x000049b4] | Main | INFO | 2019-03-20 14:21:47,614 | Caught termination signal SIGABRT, triggering termination routine

To state the matter again. When we remove the project.StartRendering() and press the button the rendering works as expected.

Any help really appreciated!
Best
Tim
Attachments
CrashReport.zip
(137.15 KiB) Downloaded 51 times
Offline

TimElschner

  • Posts: 38
  • Joined: Mon Nov 12, 2018 2:46 pm
  • Real Name: Tim Elschner

Re: Resolve API Render Call Crash

PostMon Mar 25, 2019 3:34 pm

Hm, no reply from the BlackMagicDesign Support?
Offline

TimElschner

  • Posts: 38
  • Joined: Mon Nov 12, 2018 2:46 pm
  • Real Name: Tim Elschner

Re: Resolve API Render Call Crash

PostThu Mar 28, 2019 4:04 pm

still no reply ..... :(
Offline
User avatar

roger.magnusson

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

Re: Resolve API Render Call Crash

PostThu Mar 28, 2019 6:20 pm

Well, it's a user forum so you might say you were spoiled by getting replies from two different BMD managers in the same thread. ;)

Official support is available here: https://www.blackmagicdesign.com/support/contact/email.
Offline

TimElschner

  • Posts: 38
  • Joined: Mon Nov 12, 2018 2:46 pm
  • Real Name: Tim Elschner

Re: Resolve API Render Call Crash

PostWed Apr 10, 2019 5:07 pm

The support already got plenty of mails from me on this topic ;)

So, I now know a bit more:
If the project is set to "enable collaboration" and you want call rendering via python it gets a mutex lock error exception an crashes.
If I disable collaboration, resolve starts to render.

Is there a way to get both, collaboration AND api render call support?
Offline
User avatar

Igor Riđanović

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

Re: Resolve API Render Call Crash

PostThu Apr 11, 2019 1:24 am

That's good to know. What's a "mutex lock"?
www.metafide.com - DaVinci Resolve™ Apps
Offline

TimElschner

  • Posts: 38
  • Joined: Mon Nov 12, 2018 2:46 pm
  • Real Name: Tim Elschner

Re: Resolve API Render Call Crash

PostThu Apr 11, 2019 6:30 am

Hey Igor,

no idea, maybe something with postgresql


[0x000049b4] | BtCommon | FATAL | 2019-03-20 14:21:47,612 | Error: Incorrect mutex locking order detected
[0x000049b4] | Main | INFO | 2019-03-20 14:21:47,614 | Caught termination signal SIGABRT, triggering termination routine


Only blackmagic could really debug this
Offline

Hendrik Proosa

  • Posts: 3056
  • Joined: Wed Aug 22, 2012 6:53 am
  • Location: Estonia

Re: Resolve API Render Call Crash

PostThu Apr 11, 2019 7:49 am

Mutex is a mechanism that prevents different concurrent threads/users/parties operating on the same piece of data, basically it allows only one party to touch something at the same time. Mutex is locked to do something and other lock calls wait until mutex is released. Mutex lock exception sounds like mutex is already locked by the same party that tries to lock it again (resolve python instance?), which causes undefined behavior or basically it would wait indefinitely for lock to release and thus throws an exception to prevent that.

Why python api call would act differently than simply pressing render in ui though...? I assume you can manually render just fine in collaboration mode?
I do stuff
Offline

TimElschner

  • Posts: 38
  • Joined: Mon Nov 12, 2018 2:46 pm
  • Real Name: Tim Elschner

Re: Resolve API Render Call Crash

PostThu Apr 11, 2019 8:04 am

Hi Hendrik,
correct, when I remove the StartRendering call I can normal press on the StartRender Button.
So I assume that the api access does not get full ownership during the call and it conflicts with the "logged" on GUI session... just a wild guess

Return to DaVinci Resolve

Who is online

Users browsing this forum: ahartley, CodeTech, falcondrum, Jim Simon, Paul Fisher, pav2000, ppbkwrtr, schluki123 and 250 guests