clip.SetClipProperty() sometimes does not work

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

roli09

  • Posts: 3
  • Joined: Tue Oct 26, 2021 7:58 pm
  • Real Name: Roland Kieslinger

clip.SetClipProperty() sometimes does not work

PostMon Jan 30, 2023 7:10 pm

Hi!

I'm using the following script to automatically set the timecode of my clips in DaVinci Resolve. Because the "date modified" of the clips of my Sony (A7S III, A7 IV) cameras is actually the end of the clip, I calculate the Start TC by subtracting the duration.
Code: Select all
from datetime import datetime

pm = resolve.GetProjectManager()
proj = pm.GetCurrentProject()
mp = proj.GetMediaPool()
bin = mp.GetCurrentFolder()
clips = bin.GetClipList()

for clip in clips:
    clipEnd = datetime.strptime(clip.GetClipProperty('Date Modified').split()[3], '%H:%M:%S')
    duration = datetime.strptime(clip.GetClipProperty('Duration')[0:8], '%H:%M:%S')
    clipStart = "{:0>8}".format(str(clipEnd - duration)) + ":00"

    if clip.SetClipProperty('Start TC', clipStart):
        result = '*success*'
    else:
        result = '!failed!'

    actualClipStart = clip.GetClipProperty('Start TC')
    print(result,
          clip.GetClipProperty('File Name'),
          actualClipStart,
          clipStart,
          duration.time(),
          clipEnd.time(),
          'match' if clipStart == (actualClipStart).replace(";", ":") else '!!!mismatch!!!')


This script works on almost all clips, but on a few, it doesn't and I it's replicable. Here's a sample output:

Code: Select all
*success* C0522.MP4 10:34:30:00 10:34:30:00 00:00:00 10:34:30 match
*success* C0526.MP4 18:12:46;00 18:12:46:00 00:00:05 18:12:51 match
*success* C0527.MP4 18:13:02;00 18:13:02:00 00:00:34 18:13:36 match
*success* C0525.MP4 18:11:25;00 18:11:25:00 00:00:56 18:12:21 match
*success* C0528.MP4 18:13:41;00 18:13:41:00 00:01:20 18:15:01 match
*success* C0530.MP4 18:21:19;00 18:21:19:00 00:00:06 18:21:25 match
*success* C0521.MP4 08:30:30;11 08:32:18:00 00:02:14 08:34:32 !!!mismatch!!!
*success* C0529.MP4 18:17:01;00 18:17:01:00 00:00:12 18:17:13 match
*success* C0524.MP4 17:49:31;00 17:49:31:00 00:03:07 17:52:38 match
*success* C0532.MP4 18:25:44;00 18:25:44:00 00:00:47 18:26:31 match
*success* C0531.MP4 18:24:43;00 18:24:43:00 00:00:55 18:25:38 match
*success* C0533.MP4 18:26:40;00 18:26:40:00 00:00:58 18:27:38 match
*success* C0535.MP4 18:32:51;00 18:32:51:00 00:00:11 18:33:02 match
*success* C0536.MP4 18:38:19;00 18:38:19:00 00:00:10 18:38:29 match
*success* C0537.MP4 18:40:08;00 18:40:08:00 00:00:15 18:40:23 match
*success* C0539.MP4 18:42:15;00 18:42:15:00 00:00:04 18:42:19 match
*success* C0538.MP4 18:40:37;00 18:40:37:00 00:00:33 18:41:10 match
*success* C0534.MP4 18:31:04;00 18:31:04:00 00:01:07 18:32:11 match
*success* C0543.MP4 19:54:52;00 19:54:52:00 00:00:05 19:54:57 match
*success* C0544.MP4 19:55:27;00 19:55:27:00 00:00:08 19:55:35 match
*success* C0541.MP4 19:42:03;00 19:42:03:00 00:00:53 19:42:56 match
*success* C0546.MP4 20:18:08;00 20:18:08:00 00:00:43 20:18:51 match
*success* C0548.MP4 20:20:05;00 20:20:05:00 00:00:08 20:20:13 match
*success* C0547.MP4 20:19:07;00 20:19:07:00 00:00:34 20:19:41 match
*success* C0549.MP4 20:20:22;00 20:20:22:00 00:00:13 20:20:35 match
*success* C0550.MP4 20:20:50;00 20:20:50:00 00:00:21 20:21:11 match
*success* C0552.MP4 20:22:23;00 20:22:23:00 00:00:15 20:22:38 match
*success* C0551.MP4 20:21:40;00 20:21:40:00 00:00:28 20:22:08 match
*success* C0553.MP4 20:23:30;00 20:23:30:00 00:00:19 20:23:49 match
*success* C0540.MP4 19:10:38;00 19:10:38:00 00:04:02 19:14:40 match
*success* C0555.MP4 20:34:36;00 20:34:36:00 00:00:12 20:34:48 match
*success* C0556.MP4 20:34:54;00 20:34:54:00 00:00:11 20:35:05 match
*success* C0557.MP4 20:35:12;00 20:35:12:00 00:00:30 20:35:42 match
*success* C0554.MP4 20:33:01;00 20:33:01:00 00:01:23 20:34:24 match
*success* C0558.MP4 20:36:13;00 20:36:13:00 00:00:24 20:36:37 match
*success* C0559.MP4 20:38:27;00 20:38:27:00 00:00:30 20:38:57 match
*success* C0562.MP4 21:18:23;00 21:18:23:00 00:00:09 21:18:32 match
*success* C0561.MP4 21:16:56;00 21:16:56:00 00:00:03 21:16:59 match
*success* C0545.MP4 20:10:50;00 20:10:50:00 00:06:35 20:17:25 match
*success* C0560.MP4 21:14:41;00 21:14:41:00 00:01:22 21:16:03 match
*success* C0564.MP4 21:27:36;00 21:27:36:00 00:00:05 21:27:41 match
*success* C0563.MP4 21:25:56;00 21:25:56:00 00:01:25 21:27:21 match
*success* C0565.MP4 21:28:15;00 21:28:15:00 00:00:10 21:28:25 match
*success* C0566.MP4 21:28:45;00 21:28:45:00 00:00:15 21:29:00 match
*success* C0567.MP4 21:29:29;00 21:29:29:00 00:00:29 21:29:58 match
*success* C0568.MP4 21:31:08;00 21:31:08:00 00:00:12 21:31:20 match
*success* C0569.MP4 21:33:21;00 21:33:21:00 00:00:17 21:33:38 match
*success* C0571.MP4 21:36:13;00 21:36:13:00 00:00:19 21:36:32 match
*success* C0542.MP4 19:43:06;00 19:43:06:00 00:11:37 19:54:43 match
*success* C0572.MP4 21:38:01;00 21:38:01:00 00:00:12 21:38:13 match
*success* C0574.MP4 21:44:34;00 21:44:34:00 00:00:04 21:44:38 match
*success* C0573.MP4 21:42:40;00 21:42:40:00 00:00:36 21:43:16 match
*success* C0570.MP4 21:34:08;00 21:34:08:00 00:00:44 21:34:52 match
*success* C0575.MP4 21:46:06;00 21:46:06:00 00:00:21 21:46:27 match
*success* C0576.MP4 21:47:54;00 21:47:54:00 00:00:20 21:48:14 match
*success* C0580.MP4 22:06:10;00 22:06:10:00 00:00:06 22:06:16 match
*success* C0578.MP4 21:54:39;00 21:54:39:00 00:00:10 21:54:49 match
*success* C0577.MP4 21:53:44;00 21:53:44:00 00:00:21 21:54:05 match
*success* C0581.MP4 22:06:38;00 22:06:38:00 00:00:07 22:06:45 match
*success* C0582.MP4 22:12:55;00 22:12:55:00 00:00:11 22:13:06 match
*success* C0579.MP4 22:05:00;04 22:05:00:00 00:00:32 22:05:32 !!!mismatch!!!
*success* C0583.MP4 22:15:16;00 22:15:16:00 00:00:03 22:15:19 match
*success* C0585.MP4 22:18:00;04 22:18:00:00 00:00:08 22:18:08 !!!mismatch!!!
*success* C0584.MP4 22:16:07;00 22:16:07:00 00:00:04 22:16:11 match
*success* C0586.MP4 22:18:23;00 22:18:23:00 00:00:21 22:18:44 match
*success* C0588.MP4 22:22:12;00 22:22:12:00 00:00:25 22:22:37 match
*success* C0590.MP4 22:32:24;00 22:32:24:00 00:00:06 22:32:30 match
*success* C0587.MP4 22:19:13;00 22:19:13:00 00:00:52 22:20:05 match
*success* C0589.MP4 22:30:29;00 22:30:29:00 00:01:05 22:31:34 match
*success* C0592.MP4 22:42:51;00 22:42:51:00 00:00:07 22:42:58 match
*success* C0591.MP4 22:38:41;00 22:38:41:00 00:00:26 22:39:07 match
*success* C0593.MP4 22:43:28;00 22:43:28:00 00:00:15 22:43:43 match
*success* C0594.MP4 22:45:08;00 22:45:08:00 00:00:23 22:45:31 match
*success* C0523.MP4 13:05:05:00 13:05:05:00 01:17:06 14:22:11 match


As you can see, on clip C0521.MP4 as an example the actual value for Start TC is 08:30:30;11, although I set it to 08:32:18:00 using clip.SetClipProperty().

I can't even set it correctly by using the UI. I added a screenshot as an attachment, where you can see, that the value in the list differs from the value in the Clip Attributes.

Screenshot 2023-01-30 200748.png
Screenshot 2023-01-30 200748.png (116.67 KiB) Viewed 264 times


What's the matter and how can I fix it?

Thank you so much in advance!
Offline
User avatar

Igor Riđanović

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

Re: clip.SetClipProperty() sometimes does not work

PostWed Feb 01, 2023 4:05 am

Can you try the same test on non-MP4 files and see if it fails?
www.metafide.com - DaVinci Resolve™ Apps

Return to DaVinci Resolve

Who is online

Users browsing this forum: Bing [Bot], Darmouthz, Luke Holzmann and 212 guests