Export markers and stills

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

Jean Paul Sneider

  • Posts: 271
  • Joined: Sat Jul 01, 2017 5:46 pm

Export markers and stills

PostTue Aug 04, 2020 9:32 am

Hi,

I need to compile a VFX list to send to the laboratory. One way is to painfully export a still for each needed VFX combing through my markers and compile a document with description and TC.
Is there a function to automate part of the process? Be it be the exporting still, the text from markers and tc to a txt or something akin to what you can do in Avid?

Thanks
Offline
User avatar

iddos-l

  • Posts: 803
  • Joined: Sat Mar 30, 2019 7:55 pm
  • Real Name: iddo lahman

Re: Export markers and stills

PostTue Aug 04, 2020 12:13 pm

With scripting you can export all the data of the markers to a csv file and upload it to a spreadsheet.
There is a new method to export thumbnails but I haven’t tried it yet.
The csv part I should have a written code somewhere. I will try to find it if you think it will help.


Sent from my iPhone using Tapatalk
Offline

Jean Paul Sneider

  • Posts: 271
  • Joined: Sat Jul 01, 2017 5:46 pm

Re: Export markers and stills

PostTue Aug 04, 2020 2:42 pm

I haven't really dived into scripting for resolve yet, but having a look into your might be a nice jumpstart to it.

New way to export thumbnails? Idea where I could look into it? (other than the script I am thinking of exporting the edit index... I will check it too.)
Offline

franciscovaldez

  • Posts: 465
  • Joined: Wed Aug 22, 2012 4:52 pm

Re: Export markers and stills

PostTue Aug 04, 2020 2:56 pm

Jean Paul Sneider wrote:Hi,

I need to compile a VFX list to send to the laboratory. One way is to painfully export a still for each needed VFX combing through my markers and compile a document with description and TC.
Is there a function to automate part of the process? Be it be the exporting still, the text from markers and tc to a txt or something akin to what you can do in Avid?

Thanks


I think this could be a feature request.

I would love to be able to automatically export stills with markers appearing as notes over the image... With these parameters being user defined and customizable.
MacBook Pro 13"
M2
UltraStudio 4K

Mac Pro
2.7 GHz 12-Core Intel Xeon E5
64 GB 1866 MHz DDR3
AMD FirePro D700 6 GB
Offline
User avatar

iddos-l

  • Posts: 803
  • Joined: Sat Mar 30, 2019 7:55 pm
  • Real Name: iddo lahman

Re: Export markers and stills

PostTue Aug 04, 2020 7:19 pm

Jean Paul Sneider wrote:I haven't really dived into scripting for resolve yet, but having a look into your might be a nice jumpstart to it.

New way to export thumbnails? Idea where I could look into it? (other than the script I am thinking of exporting the edit index... I will check it too.)


Hi,
Here is a python3 script that will export markers to a csv file.
The script will log data and shot name of all timeline markers in any timeline that begins with "$" in its name and will save the files to home/temp folder.

As for the thumbnails options, as mentioned in the documentation:
Returns a dict (keys "width", "height", "format" and "data") with data containing raw thumbnail image data (RGB 8-bit image data encoded in base64 format)

You can use openCV to decode it as shown in one of the examples. This is possible only from the color page.
Very interesting indeed, will need to play around with it more.

You can read about it and of Resolve scripting in the Help menu => Documentation => Developer

code:
Code: Select all
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys, os, time, csv, gspread
from pathlib import Path as path
from tkinter import Tk, filedialog, messagebox

# ///////////////////////////
# ===============
# Utils
# ===============
# ///////////////////////////

def GetResolve():
   try:
   # The PYTHONPATH needs to be set correctly for this import statement to work.
   # An alternative is to import the DaVinciResolveScript by specifying absolute path (see ExceptionHandler logic)
      import DaVinciResolveScript as bmd
   except ImportError:
      if sys.platform.startswith("darwin"):
         expectedPath="/Library/Application Support/Blackmagic Design/DaVinci Resolve/Developer/Scripting/Modules/"
      elif sys.platform.startswith("win") or sys.platform.startswith("cygwin"):
         import os
         expectedPath=os.getenv('PROGRAMDATA') + "\\Blackmagic Design\\DaVinci Resolve\\Support\\Developer\\Scripting\\Modules\\"
      elif sys.platform.startswith("linux"):
         expectedPath="/opt/resolve/libs/Fusion/Modules/"

      # check if the default path has it...
      print("Unable to find module DaVinciResolveScript from $PYTHONPATH - trying default locations")
      try:
         import imp
         bmd = imp.load_source('DaVinciResolveScript', expectedPath+"DaVinciResolveScript.py")
      except ImportError:
         # No fallbacks ... report error:
         print("Unable to find module DaVinciResolveScript - please ensure that the module DaVinciResolveScript is discoverable by python")
         print("For a default DaVinci Resolve installation, the module is expected to be located in: "+expectedPath)
         sys.exit()

   return bmd.scriptapp("Resolve")

def frames2tc (frames, fps):
    print(frames)
    print(fps)
    h = str(int(frames / (fps * 3600)))
    m = str(int(frames / (fps * 60)) % 60)
    s = str(int((frames % (fps * 60)) /fps))
    f = str(int(frames % (fps * 60)) % fps)
    return f'{h.zfill(2)}:{m.zfill(2)}:{s.zfill(2)}:{f.zfill(2)}'


def makeCSV(csvfile, dict, fps):
    """checks if csv file exists, deletes it and dump to CSV file"""
    csvColumns = ['TC', 'name', 'color', 'note', 'duration', 'Shot']
    if os.path.isfile(csvfile):
        path(csvfile).unlink()

    # log to CSV file
    try:
        with open(csvfile, 'w', encoding='utf-8') as c:
            writer = csv.DictWriter(c, fieldnames=csvColumns)
            writer.writeheader()
            for key in dict:
                writer.writerow(markers[key])
    except Exception as ex:
        print(ex)
    print(f'Loged {csvfile}')


# ///////////////////////////
# ===============
# system config
# ===============
# ///////////////////////////

desDir = path.home() / 'temp'
if not path.exists(desDir):
    desDir.mkdir()
os.chdir(desDir)


# //////////////////////////////////////////
# =============
# Resolve
# =============
# //////////////////////////////////////////
print('[*]Working...')

# instancing Resolve object
resolve = GetResolve()

if resolve == None:
    print('[!] --ERROR-- Can not get Resolve. Make sure Resolve is running')
    sys.exit()

projectManager = resolve.GetProjectManager()
project = projectManager.GetCurrentProject()
fps = round(float(project.GetSetting('timelineFrameRate')))
timelineCount = int(project.GetTimelineCount())
timelinelList = [project.GetTimelineByIndex(float(i)).GetName() for i in range(1,
                timelineCount+1) if project.GetTimelineByIndex(float(i)).GetName()[0] == '$']

# For every timeline extract markers and shot name
# save to temp CSV file
for count in range(1, timelineCount+1):
    if project.GetTimelineByIndex(count).GetName()[0] == '$':
        currentTimeline = project.GetTimelineByIndex(count)
        offset = currentTimeline.GetStartFrame()
        markers = currentTimeline.GetMarkers()
        markerTC = [k for k in markers]
        trackCount = int(currentTimeline.GetTrackCount('video'))
        shots = {tr : currentTimeline.GetItemsInTrack('video', tr) for tr in\
            range(1, trackCount+1) if len(currentTimeline.GetItemsInTrack('video', tr))}
        trackNum = sorted([k for k in shots])
        csvFileName = currentTimeline.GetName()+'.csv'

        # creates an updated markers dictonary with ofsset TC and shots name
        for marker in markerTC:
            markers[marker]['TC'] = frames2tc(marker+offset, fps)
            flag = True
            for track in reversed(trackNum):
                if flag:
                    for shot in shots[track]:
                        shotName = shots[track][shot].GetName()
                        start = shots[track][shot].GetStart()
                        end = shots[track][shot].GetEnd()
                        if (marker + offset) >= start and (marker + offset) < end:
                            markers[marker]['Shot'] = shotName
                            flag = False
                            break
                else:
                    break

        # log markers and shots name to CSV file
        print(f'Loging markers to {csvFileName} @ {desDir}')
        makeCSV(csvFileName, markers, fps)

print('***************************\n          DONE!\n***************************')

Offline

Jean Paul Sneider

  • Posts: 271
  • Joined: Sat Jul 01, 2017 5:46 pm

Re: Export markers and stills

PostWed Aug 05, 2020 1:22 pm

Thanks a lot, I will dig into it
Offline
User avatar

Igor Riđanović

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

Re: Export markers and stills

PostWed Aug 05, 2020 4:51 pm

I haven't been able to export thumbnails but I've only tried it once in a hurry. Does that work for anyone? I think the method kept returning None.
www.metafide.com - DaVinci Resolve™ Apps
Offline
User avatar

iddos-l

  • Posts: 803
  • Joined: Sat Mar 30, 2019 7:55 pm
  • Real Name: iddo lahman

Re: Export markers and stills

PostWed Aug 05, 2020 5:18 pm

Igor Riđanović wrote:I haven't been able to export thumbnails but I've only tried it once in a hurry. Does that work for anyone? I think the method kept returning None.

Yes, I did.
I was able to run the example script provided in the developer folder and was able to see a preview with cv2.
Again this worked only with the color page opened.
I used python 3.6 on macOS.



Sent from my iPhone using Tapatalk
Offline
User avatar

Igor Riđanović

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

Re: Export markers and stills

PostThu Aug 06, 2020 1:46 am

Ah, maybe I didn't have the color page opened. I'll have to test it again at some point.
www.metafide.com - DaVinci Resolve™ Apps

Return to DaVinci Resolve

Who is online

Users browsing this forum: Enrico Budianto, FlyingBanana78, Steve Alexander and 213 guests