-- Takehound for DaVinci Resolve. -- Put this file in Resolve's Scripts folder once (see takehound.com/help/open-in-resolve-or-final-cut), then in Resolve -- choose Workspace > Scripts > Takehound and pick the cut file you saved from Takehound. -- It adds one bin and one timeline to the open project: your recording on V1, your shots on V2, and a marker for -- every line with Takehound's reason (blue: a shot was placed, yellow: the line stays on you). It changes nothing else. local r = resolve or Resolve() local f = fusion or fu local project = r:GetProjectManager():GetCurrentProject() if not project then error("Takehound: open a project in Resolve first", 0) end local pool = project:GetMediaPool() -- Scripts in the free build can't show a window of their own, so a problem is said where it will be seen: -- as the name of a bin in the media pool. local function tell(msg) print("Takehound: " .. msg) pool:AddSubFolder(pool:GetRootFolder(), "Takehound: " .. msg) end -- 1. the cut file local start = "/Users/" .. (os.getenv("USER") or "") .. "/Movies/" local okd, last = pcall(function() return f:GetData("Takehound.LastFolder") end) if okd and type(last) == "string" and last ~= "" then start = last end local okr, path = pcall(function() return f:RequestFile(start, "", { FReqS_Title = "Choose your Takehound cut", FReqS_Filter = "Takehound cut (*.lua)|*.lua" }) end) if not okr then okr, path = pcall(function() return f:RequestFile(start) end) end if not okr or type(path) ~= "string" or path == "" then return end local okc, cut = pcall(dofile, path) if not okc or type(cut) ~= "table" or type(cut.picks) ~= "table" then tell("could not read that cut file. Keep it in your Movies folder and try again") return end pcall(function() f:SetData("Takehound.LastFolder", (string.gsub(path, "[^/]*$", ""))) end) -- 2. a bin for this cut, and its media local name = tostring(cut.name or "Takehound cut") local root, bin = pool:GetRootFolder(), nil for _, sub in pairs(root:GetSubFolders() or {}) do if sub:GetName() == "Takehound " .. name then bin = sub end end bin = bin or pool:AddSubFolder(root, "Takehound " .. name) if bin then pool:SetCurrentFolder(bin) end local have = {} for _, it in pairs((bin and bin:GetClips()) or {}) do local fp = it:GetClipProperty("File Path") if fp and fp ~= "" then have[fp] = it end end local want, seen = {}, {} local function need(p) if p and not seen[p] then seen[p] = true; if not have[p] then want[#want + 1] = p end end end need(cut.talk) for _, p in ipairs(cut.picks) do need(p.path) end if #want > 0 then pool:ImportMedia(want) -- read the bin again rather than trust what ImportMedia hands back (its table is not only clips) for _, it in pairs((bin and bin:GetClips()) or {}) do local fp = it:GetClipProperty("File Path") if fp and fp ~= "" then have[fp] = it end end end -- 3. the timeline local tl = pool:CreateEmptyTimeline(name) or pool:CreateEmptyTimeline(name .. " " .. os.date("%H%M%S")) if not tl then tell("could not make a timeline for " .. name); return end project:SetCurrentTimeline(tl) local fps = tonumber(tl:GetSetting("timelineFrameRate")) or tonumber(cut.fps) or 30 local first = tl:GetStartFrame() local function frames(seconds, rate) return math.floor(seconds * rate + 0.5) end local missing = {} local talk = cut.talk and have[cut.talk] if cut.talk and not talk then missing[#missing + 1] = cut.talk end if talk then local n = tonumber(talk:GetClipProperty("Frames")) or 1 pool:AppendToTimeline({ { mediaPoolItem = talk, startFrame = 0, endFrame = n - 1, trackIndex = 1, recordFrame = first } }) end if tl:GetTrackCount("video") < 2 then tl:AddTrack("video") end for _, p in ipairs(cut.picks) do local it = have[p.path] local at = frames(p.offset, fps) if it then local rate = tonumber(it:GetClipProperty("FPS")) or fps local a = frames(p.src, rate) pool:AppendToTimeline({ { mediaPoolItem = it, startFrame = a, endFrame = a + frames(p.dur, rate), trackIndex = 2, recordFrame = first + at, mediaType = 1 } }) tl:AddMarker(at, "Blue", "Takehound pick", tostring(p.line or "") .. ": " .. tostring(p.why or ""), 1, "") else missing[#missing + 1] = p.path tl:AddMarker(at, "Red", "Missing clip", tostring(p.path), 1, "") end end for _, g in ipairs(cut.stay or {}) do tl:AddMarker(frames(g.offset, fps), "Yellow", "Stay on camera", tostring(g.why or ""), 1, "") end if #missing > 0 then tell(#missing .. " file(s) were not found for " .. name .. ". Check the folder paths you typed in Takehound") end print("Takehound: " .. name .. ": " .. (#cut.picks - #missing + (cut.talk and not talk and 1 or 0)) .. " shots placed, " .. #(cut.stay or {}) .. " lines left on you, " .. #missing .. " files missing")