Scripting: Setting ClipProperty

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

julian_b

  • Posts: 236
  • Joined: Sun Jan 22, 2017 1:45 pm
  • Real Name: Julian Böhme

Scripting: Setting ClipProperty

PostThu May 14, 2020 9:08 pm

I'm trying to set clip properties of MediaPoolItems, but it seems like I can set barely any of the clip attributes.
So far, only "Clip Color" has worked.
Here's what I tried:
Code: Select all
        clip.SetClipProperty('File Path', file_path)
        clip.SetClipProperty('Comments', 'MY COMMENT')
        clip.SetClipProperty('Shot', 'Shot 1')
        clip.SetClipProperty('Flags', 'Blue')
        clip.SetClipProperty('Clip Color', 'Orange')
        clip.SetClipProperty('Keywords', 'Hello')


I know that some properties are read-only, but COME ON!
Comment? Shot? Keyword? That can't be!
Can anybody tell me what I'm doing wrong?

And there's also the questions of how do attributes with multiple values work?
For example Flags and Keywords.
Single string values don't make much sense there.
I tried passing lists, that didn't work either:
Code: Select all
clip.SetClipProperty('Flags', ['Blue'])



Example code to run:
Code: Select all
import os
import sys
import traceback
import pprint

file_path = 'D:\file.mp4'

def main():
    resolve = app.GetResolve()
    proj_manager = resolve.GetProjectManager()
    proj = proj_manager.GetCurrentProject()
    media_pool = proj.GetMediaPool()
    folder = media_pool.GetCurrentFolder()
    clips = folder.GetClipList()

    for clip in clips:
        print(clip.SetClipProperty('File Path', file_path))
        print(clip.SetClipProperty('Comments', 'MY COMMENT'))
        print(clip.SetClipProperty('Shot', 'Shot 1'))
        print(clip.SetClipProperty('Flags', ['Blue']))
        print(clip.SetClipProperty('Clip Color', 'Orange'))
        print(clip.SetClipProperty('Keywords', 'Hello'))


if __name__ == '__main__':
    try:
        main()
    except:
        print(traceback.format_exc())


Here are the possible attributes:


Code: Select all
{'Alpha mode': 'None'

 'Angle': ''

  'Audio Bit Depth': '16'

   'Audio Ch': '2'
 
   'Audio Codec': 'AAC'

    'Audio Offset': ''

     'Bit Depth': '8'

      'Camera #': ''
 'Clip Color': ''
 'Clip Name': 'AES Encryption 1_ Intro and Outline (1080p_15fps_H264-128kbit_AAC) 2.mp4'
 'Comments': ''
 'Data Level': 'Auto'
 'Date Added': 'Thu May 14 2020 20:51:54'
 'Date Created': 'Mon Dec 16 22:30:30 2019'
 'Date Modified': 'Mon Dec 16 22:30:30 2019'
 'Description': ''
 'Drop frame': '0'
 'Duration': '00:16:22:14'
 'Enable Deinterlacing': '0'
 'End': '14743'
 'End TC': '00:16:22:14'
 'FPS': '15.000'
 'Field Dominance': 'Auto'
 'File Name': 'AES Encryption 1_ Intro and Outline (1080p_15fps_H264-128kbit_AAC) 2.mp4'
 'File Path': 'D:\\Downloads\\AES Encryption\\Neuer Ordner\\AES Encryption 1_ Intro and Outline (1080p_15fps_H264-128kbit_AAC) 2.mp4'
 'Flags': ''
 'Format': 'QuickTime'
 'Frame/Field': ''
 'Frames': '14744'
 'Good Take': ''
 'H-FLIP': 'Off'
 'IDT': 'Project'
 'In': '00:03:01:05'
 'Input Color Space': 'Rec.709 (Scene)'
 'Input LUT': ''
 'Input Sizing Preset': 'None'
 'Keyword': ''
 'Noise Reduction': ''
 'Offline Reference': ''
 'Optimized Media': 'None'
 'Out': '00:03:57:05'
 'PAR': 'Square'
 'Reel Name': ''
 'Resolution': '1920x1080'
 'Roll/Card': ''
 'S3D Sync': ''
 'Sample Rate': '44100'
 'Scene': ''
 'Sharpness': ''
 'Shot': ''
 'Slate TC': '00:00:00:00'
 'Start': '0'
 'Start KeyKode': ''
 'Start TC': '00:00:00:00'
 'Synced Audio': ''
 'Take': ''
 'Type': 'Video + Audio'
 'Usage': '0'
 'V-FLIP': 'Off'
 'Video Codec': 'H.264'
 'Super Scale': 1.0}
Offline
User avatar

roger.magnusson

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

Re: Scripting: Setting ClipProperty

PostThu May 14, 2020 11:03 pm

You're right, it's strange that many fields that you would expect to be writable are read-only. In general, the API still has a long way to go but you don't need SetClipProperty for all these properties.

Some examples that work:
Code: Select all
clip.SetClipProperty("Clip Name", "Test")
clip.SetClipProperty("Start TC", "00:00:00:00")
clip.SetClipProperty("Super Scale", 1) # Values are in the API readme.txt
clip.SetClipProperty("Clip Color", "Yellow")
For flags you can use clip.AddFlag(color) instead.

Comments etc. are accessible through clip.GetMetadata(metadataType) and clip.SetMetadata(metadataType, metadataValue).
Offline
User avatar

Paul Carlin

  • Posts: 51
  • Joined: Wed Aug 22, 2012 8:14 pm
  • Location: Burbank, California

Re: Scripting: Setting ClipProperty

PostWed Oct 05, 2022 2:10 am

The only way I was able to set multiple colored flags was to have multiple AddFlag() statements.

Code: Select all
clip.AddFlag("Red")
clip.AddFlag("Lemon")
Professional Problem Solver
Offline

piersdeseilligny

  • Posts: 33
  • Joined: Tue Apr 07, 2020 8:45 pm
  • Real Name: Piers Deseilligny

Re: Scripting: Setting ClipProperty

PostWed Feb 21, 2024 7:34 pm

I'd just like to voice support for adding more writeable properties. Things like setting "Good take" would be immensely useful when working with external ingest software, and you can change all these properties in Resolve so it makes absolutely no sense you couldn't change them programatically.

Could someone from Blackmagic Design provide some guidance as to why we can't set these properties, and if there's any workarounds?

Return to DaVinci Resolve

Who is online

Users browsing this forum: panos_mts and 158 guests