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.