Last active
December 1, 2024 15:50
-
-
Save sjimenez44/1963864eceb38e9a2510e67c0053b0a3 to your computer and use it in GitHub Desktop.
Format raw video in Davinci Resolve Timeline
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
projectManager = resolve.GetProjectManager() | |
currentProject = projectManager.GetCurrentProject() | |
media_pool = currentProject.GetMediaPool() | |
timeline = currentProject.GetCurrentTimeline() | |
media_pool_clips = media_pool.GetRootFolder().GetClipList() | |
selected_clip = media_pool_clips[1] | |
timeline_clip = media_pool.AppendToTimeline([selected_clip])[0] | |
clip_width, clip_height = 2560, 1440 | |
screen_width, screen_height = 1280, 720 | |
positions = [ | |
( screen_width * 0.75, -screen_height * 0.75), # Parte superior izquierda | |
(-screen_width * 0.75, -screen_height * 0.75), # Parte superior derecha | |
(-screen_width * 0.75, screen_height * 0.75), # Parte inferior izquierda | |
( screen_width * 0.75, screen_height * 0.75), # Parte inferior derecha | |
] | |
linked_items = timeline_clip.GetLinkedItems() | |
timeline.SetClipsLinked(linked_items, True) | |
for item in linked_items: | |
timeline.SetClipsLinked([item], True) | |
timeline.AddTrack("video") | |
timeline.AddTrack("video") | |
videoclip = timeline.GetItemListInTrack("video", 1)[0] | |
videoclip_start = videoclip.GetSourceStartFrame() | |
videoclip_end = videoclip.GetSourceEndFrame() | |
clip_info = { | |
"mediaPoolItem": selected_clip, # El clip seleccionado | |
"startFrame": videoclip_start, # Comienza desde el primer fotograma del clip | |
"endFrame": videoclip_end, # Duración completa del clip | |
"mediaType": 1, # Solo video | |
"trackIndex": 2, # Pista 1 | |
"recordFrame": 0 # Comenzar en el fotograma 120 de la línea de tiempo | |
} | |
timeline_items = media_pool.AppendToTimeline([clip_info]) | |
############## | |
videoclip = timeline.GetItemListInTrack("video", 1)[0] | |
videoclip.SetProperty("Pan", positions[0][0]) | |
videoclip.SetProperty("Tilt", positions[0][1]) | |
videoclip.SetProperty("ZoomX", 2) | |
videoclip.SetProperty("ZoomY", 2) | |
videoclip = timeline.GetItemListInTrack("video", 2)[0] | |
videoclip.SetProperty("Pan", positions[1][0]) | |
videoclip.SetProperty("Tilt", positions[1][1]) | |
videoclip.SetProperty("ZoomX", 2) | |
videoclip.SetProperty("ZoomY", 2) | |
videoclip = timeline.GetItemListInTrack("video", 3)[0] | |
videoclip.SetProperty("Pan", positions[2][0]) | |
videoclip.SetProperty("Tilt", positions[2][1]) | |
videoclip.SetProperty("ZoomX", 2) | |
videoclip.SetProperty("ZoomY", 2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment