Python API AppendClipsToTimeline with an offSet

Ask software engineering and SDK questions for developers working on Mac OS X, Windows or Linux.
  • Author
  • Message
Offline

drober

  • Posts: 2
  • Joined: Thu Jan 05, 2023 12:31 pm
  • Location: Spain
  • Real Name: Roberto Salgado

Python API AppendClipsToTimeline with an offSet

PostThu Jan 05, 2023 1:26 pm

Hello, everyone.

I'm struggling with adding clips to a new, if relevant, timeline, adding an specific offSet / exact location/frame for each clip.

Code: Select all
censoring_data_elements = construct_censoring_frames_data(censoring_markers)
project.GetMediaPool().SetCurrentFolder(censoring_sub_folder)
media_pool.CreateTimelineFromClips("censoring", censoring_data_elements)

censoring data elements is a list of dictionaries with these keys:
  • mediaPoolItem: <clipItem full data obtained through API pointing to an mp3 file>
  • startFrame: 0
  • endFrame: 20

Also tried adding keys like: offSet, offset,OffSet, startOffset, start, and some more in order to set the clip in an specific timeline frame.

None of this worked. Also tried using AppendClipsToTimeline using similar approach but each item at a time.

Farther I got is creating a timeline with some concatenated clips at the beginning of it.

What would be the way to set the startTime in timeline for a clip? what would be a better approach that would avoid a user from adding them manually?


Thanks!!

Extra info:
  • Purpose: I'm using the source timeline's markers to get the frame where I want to add an audio censoring clip.
  • Code will be released in GitHub if I manage this to work!
  • Future improvement: using subtitle tracks looking for banned words to automatically add censorship
Offline
User avatar

iddos-l

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

Re: Python API AppendClipsToTimeline with an offSet

PostThu Jan 05, 2023 3:53 pm

There is an undocumented method shown in this thread:

viewtopic.php?t=113040

You can check an implementation of this in a script I recently wrote:

https://github.com/Iddos-l/Resolve_Mixdown_In_To_Out
Offline

drober

  • Posts: 2
  • Joined: Thu Jan 05, 2023 12:31 pm
  • Location: Spain
  • Real Name: Roberto Salgado

Re: Python API AppendClipsToTimeline with an offSet

PostFri Jan 06, 2023 12:23 am

Thank you.
I managed to fix it using that info.

I am not allowed to link to GitHub. I guess I’m too new here.

Find the project at GitHub: droberin/davinci-censor-audio

Cheers!

Return to Software Developers

Who is online

Users browsing this forum: No registered users and 22 guests