Scripting API: Project.AddRenderJob() returns empty string

Ask software engineering and SDK questions for developers working on Mac OS X, Windows or Linux.
  • Author
  • Message
Offline
User avatar

pedrolabonia

  • Posts: 15
  • Joined: Fri Jan 28, 2022 7:56 pm
  • Real Name: Pedro Labonia

Scripting API: Project.AddRenderJob() returns empty string

PostSat Apr 23, 2022 6:41 pm

Hello,

During some tests, I've come to realize that sometimes calling Project.AddRenderJob() can return an empty string.

To reproduce the behavior, you need to have some completed or canceled rendered jobs on the queue, manipulate small timelines with non blocking calls and then try to add them to render queue.

The bug doesn't seem to happen if the render queue is currently empty.

The expected behavior is that Resolve API either blocks until it can generate an UUID string, or either returns None or False since raising Python exceptions isn't currently supported.

I'd advocate for None, since it's the same as is returned when you call the function on an empty project with no timelines.

Had to do some bug hunting because the type was right(str), but it returned an empty string.

The code is the following:

Code: Select all
    for key in clips_res.keys():

        res_x, res_y = key.split("x")

        res_folder = media_pool.add_subfolder(key, ocf_folder)
        clips = clips_res[key]

        media_pool.move_clips(clips, res_folder)
        media_pool.create_timeline_from_clips(res_folder.name, res_folder.clips)

        timeline = project.timeline
        timeline.set_setting(
            "useCustomSettings", "1"
        )  # enable custom timeline size != project settings
        timeline.set_setting("timelineResolutionWidth", res_x)
        timeline.set_setting("timelineResolutionHeight", res_y)

        render_settings = {
            "FormatWidth": int(int(res_x) / proxyfactor),
            "FormatHeight": int(int(res_y) / proxyfactor),
            "TargetDir": output_dir,
        }

        # Set Render Resolution
        project.set_render_settings(render_settings)

        # print(render_id)
        render_id = project.add_renderjob()
        render_ids.append(render_id)
    return render_ids


This is a python wrapper I've made, but you get the idea. The timelines are single clip timelines.

I suspect what's happening is there's a bug when generating/checking for UUIDs for the job ids.

Adding a blocking call like this works all the time:
Code: Select all
    def add_renderjob(self, block: bool = True) -> str:

        job_id = self._obj.AddRenderJob()

        if block and job_id == "":
            while job_id == "":

                job_id = self._obj.AddRenderJob()

            return job_id

        return job_id



When the bug is observed, while debugging, it needs about 2 or 3 of those while loops before it returns an actual UUID.

Currently on Resovle 17.4.6 Build 4, Windows 10, Python 3.6.8, not using headless
https://vimeo.com/pedrolabonia

----

pydavinci: the python package to help you to script Davinci Resolve!

Check now on github: https://github.com/pedrolabonia/pydavinci
Offline
User avatar

pedrolabonia

  • Posts: 15
  • Joined: Fri Jan 28, 2022 7:56 pm
  • Real Name: Pedro Labonia

Re: Scripting API: Project.AddRenderJob() returns empty stri

PostTue May 03, 2022 12:28 pm

Some other weird things/bugs that I've found in the API:

For the
Code: Select all
Project.Get/SetSettings()

Code: Select all
"videoDeckUseAudoEdit" -> typo, should be "auto"

"videoDataLevels" -> apparently doesn't change the setting

"videoDataLevels" -> only works with "single_link", Dual and Quad link return "None", and can't set Dual or Quad Link

"timelineFrameRate" -> can't seem to set this even after setting Timeline.SetSetting("useCustomSettings": "1"). Seems very finicky, can't get it to work all the time. Seems like there needs to be different media framerates, but still is very inconsistent. After doing some tests, can't even manually change the framerate in the UI. I think something is locking up the setting.
https://vimeo.com/pedrolabonia

----

pydavinci: the python package to help you to script Davinci Resolve!

Check now on github: https://github.com/pedrolabonia/pydavinci

Return to Software Developers

Who is online

Users browsing this forum: repsej and 9 guests