Page 1 of 1

How to export stills from timeline

PostPosted: Thu Nov 21, 2024 9:45 pm
by mcclen
I would like to export the stills "grabbed" from a timeline, but don't seem to be able to do so.

I'm using the following APIs for Python 3 and Resolve 19.1.0:

Timeline:
GrabAllStills(stillFrameSource)

Return Type: [galleryStill]

Grabs stills from all the clips of the timeline at 'stillFrameSource' (1 - First frame, 2 - Middle frame). Returns the list of GalleryStill objects.


GalleryStillAlbum:
ExportStills([galleryStill], folderPath, filePrefix, format)

Return Type: Bool

Exports list of GalleryStill objects '[galleryStill]' to directory 'folderPath', with filename prefix 'filePrefix', using file format 'format' (supported formats: dpx, cin, tif, jpg, png, ppm, bmp, xpm).



I track my own timeline object from its creation and acquire a reference to the "current" gallery still album. I use the same "stills" list object returned from the "grab" as the export argument. I'm checking all arguments and results of calls.

The Timeline:GrabAllStills always succeeds and the stills appear in the default Gallery Still Album called "Stills 1"

The Gallery Still Album:ExportStills mostly fails (not quite 100% of the time), but mostly the export function returns false and no stills appear in the folder path. Not sure why it succeeds when it does.

I'm using an external python application on a Mac running macOS 13.4.1 with Python 3 version 13.12.4 with Resolve 19.1.0.

Has anyone had any success trying to so something similar? Am I dealing with a race condition between grab and export or is there a Resolve setting that is not set properly for this to work?

Re: How to export stills from timeline

PostPosted: Fri Nov 22, 2024 7:14 pm
by Christoph Schmid
Works for me like this:
Code: Select all
#!/usr/bin/env python3

import DaVinciResolveScript

resolve = DaVinciResolveScript.scriptapp('Resolve')
project_manager = resolve.GetProjectManager()
project = project_manager.GetCurrentProject()
gallery = project.GetGallery()
album = gallery.GetCurrentStillAlbum()
stills = album.GetStills()
album.ExportStills(stills, "/path/to/still/", "name_prefix", "jpg")

The path has to exist.

EDIT:
Apparently I responded too quickly...
When I grab the stills and then try to export them immediately, it doesn't always work.

Code: Select all
#!/usr/bin/env python


import DaVinciResolveScript

resolve = DaVinciResolveScript.scriptapp('Resolve')
project_manager = resolve.GetProjectManager()
project = project_manager.GetCurrentProject()
current_timeline = project.GetCurrentTimeline()
gallery = project.GetGallery()
album = gallery.GetCurrentStillAlbum()
stills = album.GetStills()
print(stills)
current_timeline.GrabAllStills(1)
album.ExportStills(stills, "/home/green/Schreibtisch/", "name_prefix", "jpg")


Am I dealing with a race condition between grab and export...

Looks like it.
But a sleep command doesn't work either.
Apparently the script itself blocks the query of the stills in the album.
Even if they appear visually in the gallery before the export, they are not exported.

Re: How to export stills from timeline

PostPosted: Fri Nov 22, 2024 8:17 pm
by mcclen
Thanks for the cross check and the response.

I'm noticing that MediaStorage gives different results than Pathlib at times. This may be what the documentation for MediaStorge:GetFileList means by "Note that media listings may be logically consolidated entries." For example, export as JPG provides both JPG and DRX files, but MediaStorage responds only with the JPG. Also, I suppose MediaStorage may be providing a "view" of the physical filesystem where intent is recorded before actualization.

I'll see if I can poll with Pathlib and avoid guessing at sleep values.

EDIT: Probably over thinking this a bit. The timing issue is between the grab and export, my comments above confuse the issue with follow on activity of getting the stills for the next step in the workflow.

Re: How to export stills from timeline

PostPosted: Fri Nov 22, 2024 8:58 pm
by mcclen
One more thought and question.

The Project object has method: ExportCurrentFrameAsStill(filePath).

Perhaps a combination of Timeline and TimelineItem methods "set" the current frame in each clip in the timeline would provide a means to bypass the race condition as it would avoid the Gallery and GalleryStillAlbum methods.

Has anyone any thoughts on this approach?