Scripting Input Sizing

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

Damien Letexier

  • Posts: 11
  • Joined: Fri Feb 13, 2015 9:56 am
  • Location: Paris, FR

Scripting Input Sizing

PostFri Oct 04, 2024 4:04 am

Hello,

I am currently looking for applying Input sizing preset through scripting, but it is always returning 'None' value. If I set manually the input sizing on a clip to 'My_preset_Name', then when I GetClipProperty, it is returning this preset name. But as soon as I try to Set this property, it turns back to None.

Therefore I am wondering if this function is or is not scriptable...
Anyone had chance to make it work ? Or is there a workaround (like possibility to script directly into the input sizing tab ? )

Code: Select all
liste = timeline.GetItemListInTrack('video',1)
for item in liste:
    print(f"item property {item.GetProperty()}")
    totem = item.GetMediaPoolItem()
    item.SetProperty('CompositeMode',0)
    print(f"item property {item.GetProperty()}")
    print(f"{totem.GetClipProperty('Input Sizing Preset')}")
    totem.SetClipProperty('Input Sizing Preset','My_preset_Name')
    print(f"{totem.GetClipProperty('Input Sizing Preset')}")


Thanks a lot ,

PS: I cannot use the zoomX/Y of the clip into the timeline since in conforming I need to retrieve the editorial zooms on the top of the input sizing.
Mac Pro 5.1 2x3,06GhZ 6-Core Intel Xeon 64Gb RAM
AMD Radeon HD 7950
Offline

DorinDXN

  • Posts: 174
  • Joined: Thu Aug 04, 2022 5:07 pm
  • Real Name: Dorin Godja

Re: Scripting Input Sizing

PostFri Oct 04, 2024 9:05 am

Perhaps if you implement a try block, to see if there are any exceptions

Code: Select all
liste = timeline.GetItemListInTrack('video',1)
for item in liste:
   try:
      print(f"item property {item.GetProperty()}")
      totem = item.GetMediaPoolItem()
      item.SetProperty('CompositeMode',0)
      print(f"item property {item.GetProperty()}")
      print(f"{totem.GetClipProperty('Input Sizing Preset')}")
      totem.SetClipProperty('Input Sizing Preset','My_preset_Name')
      print(f"{totem.GetClipProperty('Input Sizing Preset')}")
   except Exception as e:
        print(f"Error processing item: {e}")


cheers,
Dorin
DaVinci Resolve Anthem
https://www.youtube.com/watch?v=CcKC8R9ku50
DaVinci Resolve Clips
https://www.youtube.com/playlist?list=PLYgg-7sUX2Jh3dqNJ0AVBTIlDFtufrYyn
Playhead Lock Script
https://forum.blackmagicdesign.com/viewtopic.php?f=21&t=210163
Offline

Stef Girres

  • Posts: 18
  • Joined: Sat Feb 02, 2013 6:14 pm

Re: Scripting Input Sizing

PostFri Oct 04, 2024 2:45 pm

Hello Damien,
I'm not sur what you're trying to do. Do you want to specify the input sizing on a per-clip basis or for a timeline ?

What kind of sizing would you like to apply ?

It is possible to set the input scaling via scripting. I've never used the Input sizing preset and I don't know its usefulness.

Stéfan
Offline

Damien Letexier

  • Posts: 11
  • Joined: Fri Feb 13, 2015 9:56 am
  • Location: Paris, FR

Re: Scripting Input Sizing

PostFri Oct 04, 2024 5:27 pm

Hi,
Thanks for your input, I will try to see if there is an exception, but it is definitely getting the value.

What I want to achieve is an input sizing zoom (I'm ok to deal with input sizing on hard without a preset, I did not found out where to script the input sizing in the documentation, do you have the function ?) on a per-clip basis and not on a timeline basis.

Actually the idea is to burn the framing guide to the clips (because on some specific projets DOP are taking some margin, between 5 and 10%).

I saved an input sizing preset in the input sizing tab, thinking to reuse it for all the clips I want.

Afterwards, I will dig into matching the input sizing with the lens used on the set.
Mac Pro 5.1 2x3,06GhZ 6-Core Intel Xeon 64Gb RAM
AMD Radeon HD 7950
Offline

Damien Letexier

  • Posts: 11
  • Joined: Fri Feb 13, 2015 9:56 am
  • Location: Paris, FR

Re: Scripting Input Sizing

PostFri Oct 04, 2024 5:34 pm

DorinDXN wrote:Perhaps if you implement a try block, to see if there are any exceptions
cheers,
Dorin


Hi Dorin,

There is no Exception,
Here is the result I have with all the print functions.
To dig a little, I tried to apply manually my preset on the clip prior to launch the script.
As you can see the GetClipProperty is working but the SetClipProperty is not and it even comes back to 'None' value... erasing what has been done.

I tried to display item property, but as it is timeline related there is no input sizing.

Code: Select all
item property {'Pan': 0.0, 'Tilt': 0.0, 'ZoomX': 1.0, 'ZoomY': 1.0, 'ZoomGang': True, 'RotationAngle': 0.0, 'AnchorPointX': 0.0, 'AnchorPointY': 0.0, 'Pitch': 0.0, 'Yaw': 0.0, 'FlipX': False, 'FlipY': False, 'CropLeft': 0.0, 'CropRight': 0.0, 'CropTop': 0.0, 'CropBottom': 0.0, 'CropSoftness': 0.0, 'CropRetain': False, 'DynamicZoomEase': 0, 'CompositeMode': 0, 'Opacity': 100.0, 'Distortion': 0.0, 'RetimeProcess': 0, 'MotionEstimation': 0, 'Scaling': 0, 'ResizeFilter': 0}

item property {'Pan': 0.0, 'Tilt': 0.0, 'ZoomX': 1.0, 'ZoomY': 1.0, 'ZoomGang': True, 'RotationAngle': 0.0, 'AnchorPointX': 0.0, 'AnchorPointY': 0.0, 'Pitch': 0.0, 'Yaw': 0.0, 'FlipX': False, 'FlipY': False, 'CropLeft': 0.0, 'CropRight': 0.0, 'CropTop': 0.0, 'CropBottom': 0.0, 'CropSoftness': 0.0, 'CropRetain': False, 'DynamicZoomEase': 0, 'CompositeMode': 0, 'Opacity': 100.0, 'Distortion': 0.0, 'RetimeProcess': 0, 'MotionEstimation': 0, 'Scaling': 0, 'ResizeFilter': 0}

My_preset_Name
None
Mac Pro 5.1 2x3,06GhZ 6-Core Intel Xeon 64Gb RAM
AMD Radeon HD 7950
Offline

DorinDXN

  • Posts: 174
  • Joined: Thu Aug 04, 2022 5:07 pm
  • Real Name: Dorin Godja

Re: Scripting Input Sizing

PostSat Oct 05, 2024 8:26 am

Try setting the preset as a number (0, 1, or 2).

Maybe it expects an index, as it seems that it changes it to "None,"
which is the first option in the input sizing presets at the Clip attribute window.

I cannot test this myself right now.

cheers,
Dorin
DaVinci Resolve Anthem
https://www.youtube.com/watch?v=CcKC8R9ku50
DaVinci Resolve Clips
https://www.youtube.com/playlist?list=PLYgg-7sUX2Jh3dqNJ0AVBTIlDFtufrYyn
Playhead Lock Script
https://forum.blackmagicdesign.com/viewtopic.php?f=21&t=210163
Offline

Damien Letexier

  • Posts: 11
  • Joined: Fri Feb 13, 2015 9:56 am
  • Location: Paris, FR

Re: Scripting Input Sizing

PostSat Oct 05, 2024 8:17 pm

Thank you,
I already gave it a try without any success.
Mac Pro 5.1 2x3,06GhZ 6-Core Intel Xeon 64Gb RAM
AMD Radeon HD 7950
Offline

DorinDXN

  • Posts: 174
  • Joined: Thu Aug 04, 2022 5:07 pm
  • Real Name: Dorin Godja

Re: Scripting Input Sizing

PostSun Oct 06, 2024 3:05 pm

Indeed, it looks like it doesn't work.

To do your job, perhaps you can set your own preset functions with a discrete set of pan, tilt, zoom, etc., then use them to achieve the same result as using a preset.


Here is an example in Lua;
the changing of the properties (some random values) seem to work in DR 19.0.2

Code: Select all
local timeline = resolve:GetProjectManager():GetCurrentProject():GetCurrentTimeline()
local clip = timeline:GetItemListInTrack('video', 1)[1]

clip:SetProperty('ZoomX', 1.3)
clip:SetProperty('ZoomY', 1.3)
clip:SetProperty('PositionX', 50.0)
clip:SetProperty('PositionY', 100.0)
clip:SetProperty('RotationAngle', 15.0)
clip:SetProperty('AnchorPointX', 0.5)
clip:SetProperty('AnchorPointY', 0.5)
clip:SetProperty('Pitch', 50.0)
clip:SetProperty('Yaw', 75.0)
clip:SetProperty('FlipX', true)
clip:SetProperty('FlipY', true)
clip:SetProperty('CropLeft', 100.0)
clip:SetProperty('CropRight', 100.0)
clip:SetProperty('CropTop', 100.0)
clip:SetProperty('CropBottom', 100.0)
clip:SetProperty('CropSoftness', 0.0)
clip:SetProperty('CropRetain', true)
clip:SetProperty('CropRetainCenter', true)
clip:SetProperty('DistortX', 10.0)
clip:SetProperty('DistortY', 50.0)
clip:SetProperty('DistortCorner1X', 0.0)
clip:SetProperty('DistortCorner1Y', 0.0)
clip:SetProperty('DistortCorner2X', 0.0)
clip:SetProperty('DistortCorner2Y', 0.0)
clip:SetProperty('DistortCorner3X', 0.0)
clip:SetProperty('DistortCorner3Y', 0.0)
clip:SetProperty('DistortCorner4X', 0.0)
clip:SetProperty('DistortCorner4Y', 0.0)


cheers,
Dorin
DaVinci Resolve Anthem
https://www.youtube.com/watch?v=CcKC8R9ku50
DaVinci Resolve Clips
https://www.youtube.com/playlist?list=PLYgg-7sUX2Jh3dqNJ0AVBTIlDFtufrYyn
Playhead Lock Script
https://forum.blackmagicdesign.com/viewtopic.php?f=21&t=210163
Offline

Damien Letexier

  • Posts: 11
  • Joined: Fri Feb 13, 2015 9:56 am
  • Location: Paris, FR

Re: Scripting Input Sizing

PostSun Oct 06, 2024 3:11 pm

Hi,
Yes it is an option, but I don't want to go that way, since I want to preserve all the clip properties in the timeline for future conforming work.

I really need all that stuff at input sizing level, to generate proxies.

Then editing, and coming back to resolve I want to get back by input sizing and apply all zooms/ pans,etc from the editing.

Kr,
Mac Pro 5.1 2x3,06GhZ 6-Core Intel Xeon 64Gb RAM
AMD Radeon HD 7950
Offline

DorinDXN

  • Posts: 174
  • Joined: Thu Aug 04, 2022 5:07 pm
  • Real Name: Dorin Godja

Re: Scripting Input Sizing

PostSun Oct 06, 2024 3:41 pm

I cannot test it right now, as I don't have access to the DR PC,

See if it helps you, basically the code should read the "My preset" you saved before and apply to the clip, in the same way you'd apply "My preset" directly:

Code: Select all
local resolve = Resolve()
local projectManager = resolve:GetProjectManager()
local project = projectManager:GetCurrentProject()
local timeline = project:GetCurrentTimeline()
local clip = timeline:GetItemListInTrack('video', 1)[1]

local function readPresetProperties(presetName)
    local properties = {}
    local preset = resolve:GetPresetManager():GetPreset(presetName)
    if preset then
        properties.ZoomX = preset:GetProperty('ZoomX')
        properties.ZoomY = preset:GetProperty('ZoomY')
        properties.PositionX = preset:GetProperty('PositionX')
        properties.PositionY = preset:GetProperty('PositionY')
        properties.RotationAngle = preset:GetProperty('RotationAngle')
        properties.AnchorPointX = preset:GetProperty('AnchorPointX')
        properties.AnchorPointY = preset:GetProperty('AnchorPointY')
        properties.Pitch = preset:GetProperty('Pitch')
        properties.Yaw = preset:GetProperty('Yaw')
        properties.FlipX = preset:GetProperty('FlipX')
        properties.FlipY = preset:GetProperty('FlipY')
        properties.CropLeft = preset:GetProperty('CropLeft')
        properties.CropRight = preset:GetProperty('CropRight')
        properties.CropTop = preset:GetProperty('CropTop')
        properties.CropBottom = preset:GetProperty('CropBottom')
        properties.CropSoftness = preset:GetProperty('CropSoftness')
        properties.CropRetain = preset:GetProperty('CropRetain')
        properties.CropRetainCenter = preset:GetProperty('CropRetainCenter')
        properties.DistortX = preset:GetProperty('DistortX')
        properties.DistortY = preset:GetProperty('DistortY')
        properties.DistortCorner1X = preset:GetProperty('DistortCorner1X')
        properties.DistortCorner1Y = preset:GetProperty('DistortCorner1Y')
        properties.DistortCorner2X = preset:GetProperty('DistortCorner2X')
        properties.DistortCorner2Y = preset:GetProperty('DistortCorner2Y')
        properties.DistortCorner3X = preset:GetProperty('DistortCorner3X')
        properties.DistortCorner3Y = preset:GetProperty('DistortCorner3Y')
        properties.DistortCorner4X = preset:GetProperty('DistortCorner4X')
        properties.DistortCorner4Y = preset:GetProperty('DistortCorner4Y')
    end
    return properties
end

local presetProperties = readPresetProperties("My preset")

clip:SetProperty('ZoomX', presetProperties.ZoomX)
clip:SetProperty('ZoomY', presetProperties.ZoomY)
clip:SetProperty('PositionX', presetProperties.PositionX)
clip:SetProperty('PositionY', presetProperties.PositionY)
clip:SetProperty('RotationAngle', presetProperties.RotationAngle)
clip:SetProperty('AnchorPointX', presetProperties.AnchorPointX)
clip:SetProperty('AnchorPointY', presetProperties.AnchorPointY)
clip:SetProperty('Pitch', presetProperties.Pitch)
clip:SetProperty('Yaw', presetProperties.Yaw)
clip:SetProperty('FlipX', presetProperties.FlipX)
clip:SetProperty('FlipY', presetProperties.FlipY)
clip:SetProperty('CropLeft', presetProperties.CropLeft)
clip:SetProperty('CropRight', presetProperties.CropRight)
clip:SetProperty('CropTop', presetProperties.CropTop)
clip:SetProperty('CropBottom', presetProperties.CropBottom)
clip:SetProperty('CropSoftness', presetProperties.CropSoftness)
clip:SetProperty('CropRetain', presetProperties.CropRetain)
clip:SetProperty('CropRetainCenter', presetProperties.CropRetainCenter)
clip:SetProperty('DistortX', presetProperties.DistortX)
clip:SetProperty('DistortY', presetProperties.DistortY)
clip:SetProperty('DistortCorner1X', presetProperties.DistortCorner1X)
clip:SetProperty('DistortCorner1Y', presetProperties.DistortCorner1Y)
clip:SetProperty('DistortCorner2X', presetProperties.DistortCorner2X)
clip:SetProperty('DistortCorner2Y', presetProperties.DistortCorner2Y)
clip:SetProperty('DistortCorner3X', presetProperties.DistortCorner3X)
clip:SetProperty('DistortCorner3Y', presetProperties.DistortCorner3Y)
clip:SetProperty('DistortCorner4X', presetProperties.DistortCorner4X)
clip:SetProperty('DistortCorner4Y', presetProperties.DistortCorner4Y)


cheers,
Dorin
DaVinci Resolve Anthem
https://www.youtube.com/watch?v=CcKC8R9ku50
DaVinci Resolve Clips
https://www.youtube.com/playlist?list=PLYgg-7sUX2Jh3dqNJ0AVBTIlDFtufrYyn
Playhead Lock Script
https://forum.blackmagicdesign.com/viewtopic.php?f=21&t=210163
Offline

Damien Letexier

  • Posts: 11
  • Joined: Fri Feb 13, 2015 9:56 am
  • Location: Paris, FR

Re: Scripting Input Sizing

PostThu Oct 17, 2024 7:38 pm

Thank you Dorin,
But as said earlier I need to have an input sizing preset at the clip level and not in the timeline itself as zoom / position.

I need at the end to conform, meaning that I need to keep the zoom values in edit sizing free to report all sizing from the editing.
The input sizing is used to make the proxies first, so I want to keep the input sizing prior to apply the edit sizing.

KR,

Damien
Offline

ambustion

  • Posts: 30
  • Joined: Mon Jun 24, 2019 4:36 pm
  • Real Name: Brendon Rathbone

Re: Scripting Input Sizing

PostSun Nov 10, 2024 7:11 pm

Unfortunately this is not possible with scripting. Best alternative I have found is scripting an alternative export of metadata, which you kind of need from resolve as it is, because you also cannot script circle takes(and they do not match the formatting of the column for avid anyway).

With the new custom metadata section, this opens up a ton of options there. Unfortunate it is needed in resolve as there are a few scripting elements that seem to be bugged. For the last few versions querying fps would only give an int so it would give 23 for 23.976, which has since been fixed so I have hope they will allow us to set these properties soon.
Offline

camkerr

  • Posts: 1
  • Joined: Mon Jan 13, 2025 10:21 pm
  • Real Name: Cameron Kerr

Re: Scripting Input Sizing

PostTue Jan 14, 2025 2:25 pm

I am also running into this issue. It appears that Input Sizing Preset is a read-only property. If you try to set it using SetClipProperty() or SetProperty() it won't work, but if you set it using the GUI and then read it with GetClipProperty() or GetProperty() it does return whatever your change in the GUI was.

The README.txt scripting documentation does have this line:
Some properties may be read only - these include intrinsic clip properties like date created or sample rate, and properties that can be disabled in specific application contexts (e.g. custom colorspaces
in an ACES workflow, or output sizing parameters when behavior is set to match timeline)

This is frustrating because, like you, I'd like to set it programatically. More frustrating though is that SetClipProperty() and SetProperty() return booleans of True when trying to set Input Sizing Preset. If an item is read-only, shouldn't these return False?

What's even weirder is that, if you set the value in the GUI, then try to set it programatically, it does change. It just always changes to "None" to matter what you pass in.
Offline
User avatar

Paul Carlin

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

Re: Scripting Input Sizing

PostWed Jun 04, 2025 8:15 pm

I am having the same issue. Everything appears to work when you use the SetClipPropery for "Input Sizing Preset" except for the fact that it sets the clips to "None".

If the clip already has an existing setting, it get's set to "None", which tells you that it is functioning incorrectly.

Have not been able to find a workaround.
Professional Problem Solver

Return to DaVinci Resolve

Who is online

Users browsing this forum: Baidu [Spider], Beimo77, Peter Cave, Rick van den Berg and 289 guests