Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Script DaVinci Resolve - Placement de médias sur marqueurs
- -- Lua 5.1
- function sleep(seconds)
- local debut = os.clock()
- while os.clock() - debut <= seconds do end
- end
- local resolve = Resolve()
- local projectManager = resolve:GetProjectManager()
- local project = projectManager:GetCurrentProject()
- if not project then
- error("No project open")
- return
- end
- local mediaPool = project:GetMediaPool()
- local timeline = project:GetCurrentTimeline()
- if not timeline then
- error("No active timeline")
- return
- end
- -- Récupérer tous les marqueurs de la timeline
- local markers = timeline:GetMarkers()
- if not markers or next(markers) == nil then
- error("No markers found")
- return
- end
- -- Convertir les marqueurs en tableau trié
- local markerFrames = {}
- for frameId, markerData in pairs(markers) do
- table.insert(markerFrames, tonumber(frameId))
- end
- table.sort(markerFrames)
- local rootFolder = mediaPool:GetCurrentFolder()
- local clips=mediaPool:GetSelectedClips()
- if clips == nil then
- clips = rootFolder:GetClipList()
- end
- if not clips or #clips == 0 then
- error("No media in Mediapool")
- return
- end
- local numClipsPlaced = 0
- local minCount = math.min(#clips, #markerFrames - 1)
- local e=0 -- compteur d'erreur d'insertion, si erreur reste sur le même marqueur mais clip suivant
- for i = 1, minCount do
- local startFrame = markerFrames[i-e]
- local endFrame = markerFrames[i + 1-e]
- local desiredDuration = endFrame - startFrame
- clips[i]:SetMarkInOut(0, desiredDuration-1, "all")
- local success = mediaPool:AppendToTimeline(clips[i])
- sleep(0)
- if success == nil then
- --dump(clips[i])
- e=e+1
- print("Error when inserting Clip [ "..clips[i]:GetName().. " ], it was skipped")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment