Resolve Script : Is it possible to get SourceTC In/Out

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

omakazu

  • Posts: 5
  • Joined: Sun Jan 21, 2024 8:47 am
  • Real Name: Kazuki Omata

Resolve Script : Is it possible to get SourceTC In/Out

PostSun Jan 21, 2024 9:01 am

I have qeuestion about resolve script.

Is there any way to get the in/out source timecode of the clips in the current timeline?
mediaPoolItem:GetClipProperty("In") and ("Out") were the in/out values in the media pool.
I konw the in/out timecode in timeline.

another question,
Is therer any way to get the source timecode of the clips in the current timeline?

thanks
Offline

Shrinivas Ramani

Blackmagic Design

  • Posts: 2731
  • Joined: Wed Sep 20, 2017 10:19 am

Re: Resolve Script : Is it possible to get SourceTC In/Out

PostTue Jan 23, 2024 1:46 am

Some pseudocode:

Code: Select all
    tiItem = resolve.GetProjectManager().GetCurrentProject().GetCurrentTimeline().GetItemListInTrack('video',1)[0]
    mpItem = tiItem.GetMediaPoolItem()
    media_fps = mpItem.GetClipProperty("FPS")
    frames_trimmed = tiItem.GetLeftOffset()
    # A quick and hacky timecode arithmetic illustration. Do consider using `pip install timecode` or other timecode utilities
    source_start = [int(i) for i in mpItem.GetClipProperty("Start TC").split(':')]
    trim_tc = [ int(frames_trimmed/media_fps/60/60), int(frames_trimmed/media_fps/60), int(frames_trimmed/media_fps), int(frames_trimmed%media_fps) ]
    source_start_at_timeline_trim = [ source_start[i]+trim_tc[i] for i in range(4) ]
    print(f'{":".join([str(i) for i in source_start_at_timeline_trim])}')
Offline

omakazu

  • Posts: 5
  • Joined: Sun Jan 21, 2024 8:47 am
  • Real Name: Kazuki Omata

Re: Resolve Script : Is it possible to get SourceTC In/Out

PostTue Jan 23, 2024 2:12 am

Shrinivas Ramani wrote:Some pseudocode:

Code: Select all
    tiItem = resolve.GetProjectManager().GetCurrentProject().GetCurrentTimeline().GetItemListInTrack('video',1)[0]
    mpItem = tiItem.GetMediaPoolItem()
    media_fps = mpItem.GetClipProperty("FPS")
    frames_trimmed = tiItem.GetLeftOffset()
    # A quick and hacky timecode arithmetic illustration. Do consider using `pip install timecode` or other timecode utilities
    source_start = [int(i) for i in mpItem.GetClipProperty("Start TC").split(':')]
    trim_tc = [ int(frames_trimmed/media_fps/60/60), int(frames_trimmed/media_fps/60), int(frames_trimmed/media_fps), int(frames_trimmed%media_fps) ]
    source_start_at_timeline_trim = [ source_start[i]+trim_tc[i] for i in range(4) ]
    print(f'{":".join([str(i) for i in source_start_at_timeline_trim])}')


Thank you, Shrinivas.

If I wanna add handle of the all clip, I should create new timeline and call "AppendToTimeline()" ?
Is there any other function in this API?
I wanna use "Cut" and "Trim" in this API.


Code: Select all
  AppendToTimeline([{clipInfo}, ...])             --> [TimelineItem]     # Appends list of clipInfos specified as dict of "mediaPoolItem", "startFrame" (int), "endFrame" (int), (optional) "mediaType" (int; 1 - Video only, 2 - Audio only), "trackIndex" (int) and "recordFrame" (int). Returns the list of appended timelineItems.



this function's "startFrame" and "endFrame" is source clip's start/end Frame?
or timeline start/end Frame?
Is there any function to imoprt a clip with a specific "Duration" and "Start/end"?
Offline

sushi ninja

  • Posts: 6
  • Joined: Tue Feb 14, 2023 8:01 am
  • Real Name: Satoru Taguchi

Re: Resolve Script : Is it possible to get SourceTC In/Out

PostThu Mar 07, 2024 11:55 am

omakazu wrote:
Shrinivas Ramani wrote:Some pseudocode:

Code: Select all
    tiItem = resolve.GetProjectManager().GetCurrentProject().GetCurrentTimeline().GetItemListInTrack('video',1)[0]
    mpItem = tiItem.GetMediaPoolItem()
    media_fps = mpItem.GetClipProperty("FPS")
    frames_trimmed = tiItem.GetLeftOffset()
    # A quick and hacky timecode arithmetic illustration. Do consider using `pip install timecode` or other timecode utilities
    source_start = [int(i) for i in mpItem.GetClipProperty("Start TC").split(':')]
    trim_tc = [ int(frames_trimmed/media_fps/60/60), int(frames_trimmed/media_fps/60), int(frames_trimmed/media_fps), int(frames_trimmed%media_fps) ]
    source_start_at_timeline_trim = [ source_start[i]+trim_tc[i] for i in range(4) ]
    print(f'{":".join([str(i) for i in source_start_at_timeline_trim])}')


Thank you, Shrinivas.

If I wanna add handle of the all clip, I should create new timeline and call "AppendToTimeline()" ?
Is there any other function in this API?
I wanna use "Cut" and "Trim" in this API.


Code: Select all
  AppendToTimeline([{clipInfo}, ...])             --> [TimelineItem]     # Appends list of clipInfos specified as dict of "mediaPoolItem", "startFrame" (int), "endFrame" (int), (optional) "mediaType" (int; 1 - Video only, 2 - Audio only), "trackIndex" (int) and "recordFrame" (int). Returns the list of appended timelineItems.



this function's "startFrame" and "endFrame" is source clip's start/end Frame?
or timeline start/end Frame?
Is there any function to imoprt a clip with a specific "Duration" and "Start/end"?




Hi, omakazu.
I work in a Japanese post-production company and have the same problem!

startFrame and endFrame in AppendToTimeline() are the start and end (int value of timecode converted to number of frames) of the source clip, respectively.
The optional values trackIndex and recordFrame are the timeline track and record timecode ( that converted to number of frames), respectively, to which the clip is added, but trackIndex does not seem to be working properly.

I am also getting the Source In Out of the Timeline Item in a different way. By exporting the Edit Index of the timeline as a csv, parsing it and tying it to the Timeline Item, I can get information that is hard to get from the API.
Offline

omakazu

  • Posts: 5
  • Joined: Sun Jan 21, 2024 8:47 am
  • Real Name: Kazuki Omata

Re: Resolve Script : Is it possible to get SourceTC In/Out

PostMon Mar 25, 2024 11:15 am

Hi, sushi ninja
thanks nice tips about getting I/O.
Exporting a CSV is a good current practice.

Return to Software Developers

Who is online

Users browsing this forum: No registered users and 14 guests