├── .gitignore ├── Examples ├── 1_sorted_timeline_from_folder.lua ├── 1_sorted_timeline_from_folder.py ├── 2_compositions_from_timeline_clips.lua ├── 2_compositions_from_timeline_clips.py ├── 3_grade_and_render_all_timelines.lua ├── 3_grade_and_render_all_timelines.py ├── 4_display_project_and_folder_tree.lua ├── 4_display_project_and_folder_tree.py ├── 5_get_project_information.lua ├── 5_get_project_information.py └── python_get_resolve.py ├── Modules └── DaVinciResolveScript.py ├── README.md ├── docs ├── .nojekyll ├── README.md └── index.html ├── package-lock.json └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | .DS_Store 3 | -------------------------------------------------------------------------------- /Examples/1_sorted_timeline_from_folder.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | Example DaVinci Resolve script: 3 | Based on a given media folder path, this script creates a new project, a default timeline and appends clips into the timeline sorted by name 4 | 5 | Inputs: 6 | - project name 7 | - project framerate 8 | - project width, in pixels 9 | - project height, in pixels 10 | - path to media 11 | --]] 12 | 13 | if table.getn(arg) < 5 then 14 | print("input parameters for scripts are [project name] [framerate] [width] [height] [path to media]") 15 | os.exit() 16 | end 17 | 18 | projectName = arg[1] 19 | framerate = arg[2] 20 | width = arg[3] 21 | height = arg[4] 22 | mediaPath = arg[5] 23 | 24 | --[[ 25 | Create project and set parameters: 26 | --]] 27 | resolve = Resolve() 28 | projectManager = resolve:GetProjectManager() 29 | project = projectManager:CreateProject(projectName) 30 | 31 | if not project then 32 | print("Unable to create a project '"..projectName.."'") 33 | os.exit() 34 | end 35 | 36 | project:SetSetting("timelineFrameRate", tostring(framerate)) 37 | project:SetSetting("timelineResolutionWidth", tostring(width)) 38 | project:SetSetting("timelineResolutionHeight", tostring(height)) 39 | 40 | --[[ 41 | Add folder contents to Media Pool: 42 | --]] 43 | mediapool = project:GetMediaPool() 44 | rootFolder = mediapool:GetRootFolder() 45 | clips = resolve:GetMediaStorage():AddItemsToMediaPool(mediaPath) 46 | 47 | --[[ 48 | Create timeline: 49 | --]] 50 | timelineName = "Timeline 1" 51 | timeline = mediapool:CreateEmptyTimeline(timelineName) 52 | if not timeline then 53 | print("Unable to create timeline '"..timelineName.."'") 54 | os.exit() 55 | end 56 | 57 | --[[ 58 | Sort by name 59 | --]] 60 | table.sort(clips, function(a,b) return a:GetClipProperty("File Name")["File Name"] < b:GetClipProperty("File Name")["File Name"] end) 61 | 62 | for clipIndex in pairs(clips) do 63 | mediapool:AppendToTimeline(clips[clipIndex]) 64 | end 65 | 66 | projectManager:SaveProject() 67 | 68 | print("'"..projectName.."' has been added") 69 | -------------------------------------------------------------------------------- /Examples/1_sorted_timeline_from_folder.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | 4 | """ 5 | Example DaVinci Resolve script: 6 | Based on a given media folder path, this script creates a new project, a default timeline and appends clips into the timeline sorted by name 7 | """ 8 | 9 | from python_get_resolve import GetResolve 10 | import sys 11 | 12 | # Inputs: 13 | # - project name 14 | # - project framerate 15 | # - project width, in pixels 16 | # - project height, in pixels 17 | # - path to media 18 | if len(sys.argv) < 6: 19 | print("input parameters for scripts are [project name] [framerate] [width] [height] [path to media]") 20 | sys.exit() 21 | 22 | projectName = sys.argv[1] 23 | framerate = sys.argv[2] 24 | width = sys.argv[3] 25 | height = sys.argv[4] 26 | mediaPath = sys.argv[5] 27 | 28 | # Create project and set parameters: 29 | resolve = GetResolve() 30 | projectManager = resolve.GetProjectManager() 31 | project = projectManager.CreateProject(projectName) 32 | 33 | if not project: 34 | print("Unable to create a project '" + projectName + "'") 35 | sys.exit() 36 | 37 | project.SetSetting("timelineFrameRate", str(framerate)) 38 | project.SetSetting("timelineResolutionWidth", str(width)) 39 | project.SetSetting("timelineResolutionHeight", str(height)) 40 | 41 | # Add folder contents to Media Pool: 42 | mediapool = project.GetMediaPool() 43 | rootFolder = mediapool.GetRootFolder() 44 | clips = resolve.GetMediaStorage().AddItemsToMediaPool(mediaPath) 45 | 46 | # Create timeline: 47 | timelineName = "Timeline 1" 48 | timeline = mediapool.CreateEmptyTimeline(timelineName) 49 | if not timeline: 50 | print("Unable to create timeline '" + timelineName + "'") 51 | sys.exit() 52 | 53 | # sort by name 54 | clipNames = [] 55 | for clipIdx in clips: 56 | clipNames.append(clips[clipIdx].GetClipProperty("File Name")["File Name"]) 57 | 58 | indexes = sorted(range(len(clipNames)),key=lambda x:clipNames[x]) 59 | 60 | for clipIdx in range(len(indexes)): 61 | mediapool.AppendToTimeline(clips[indexes[clipIdx] + 1]) 62 | 63 | projectManager.SaveProject() 64 | 65 | print("'" + projectName + "' has been added") 66 | -------------------------------------------------------------------------------- /Examples/2_compositions_from_timeline_clips.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | Example DaVinci Resolve script: 3 | Add composition to currently open timeline to timeline clips what do not have any compositions yet 4 | 5 | Get currently open project 6 | --]] 7 | resolve = Resolve() 8 | projectManager = resolve:GetProjectManager() 9 | project = projectManager:GetCurrentProject() 10 | 11 | if not project then 12 | print("No project is loaded") 13 | os.exit() 14 | end 15 | 16 | --[[ 17 | Get current timeline. If no current timeline try to load it from timeline list 18 | --]] 19 | 20 | timeline = project:GetCurrentTimeline() 21 | if not timeline then 22 | if project:GetTimelineCount() > 0 then 23 | timeline = project:GetTimelineByIndex(1) 24 | project:SetCurrentTimeline(timeline) 25 | end 26 | end 27 | 28 | if not timeline then 29 | print("Current project has no timelines") 30 | os.exit() 31 | end 32 | 33 | --[[ 34 | Add compositions for all clips in timeline 35 | --]] 36 | timelineVideoTrackCount = timeline:GetTrackCount("video") 37 | 38 | for index = 1, timelineVideoTrackCount, 1 do 39 | local clips = timeline:GetItemsInTrack("video", index) 40 | for clipIdx in pairs(clips) do 41 | if clips[clipIdx]:GetFusionCompCount() < 1 then 42 | clips[clipIdx]:AddFusionComp() 43 | end 44 | end 45 | end 46 | -------------------------------------------------------------------------------- /Examples/2_compositions_from_timeline_clips.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | 4 | """ 5 | Example DaVinci Resolve script: 6 | Add composition to currently open timeline to timeline clips what do not have any compositions yet 7 | """ 8 | 9 | from python_get_resolve import GetResolve 10 | import sys 11 | 12 | # Get currently open project 13 | resolve = GetResolve() 14 | projectManager = resolve.GetProjectManager() 15 | project = projectManager.GetCurrentProject() 16 | 17 | if not project: 18 | print("No project is loaded") 19 | sys.exit() 20 | 21 | # Get current timeline. If no current timeline try to load it from timeline list 22 | timeline = project.GetCurrentTimeline() 23 | if not timeline: 24 | if project.GetTimelineCount() > 0: 25 | timeline = project.GetTimelineByIndex(1) 26 | project.SetCurrentTimeline(timeline) 27 | 28 | if not timeline: 29 | print("Current project has no timelines") 30 | sys.exit() 31 | 32 | # add compositions for all clips in timeline 33 | timelineVideoTrackCount = timeline.GetTrackCount("video") 34 | 35 | for i in range(int(timelineVideoTrackCount)): 36 | clips = timeline.GetItemsInTrack("video", i + 1) 37 | for clipIdx in clips: 38 | if clips[clipIdx].GetFusionCompCount() < 1: 39 | clips[clipIdx].AddFusionComp() 40 | -------------------------------------------------------------------------------- /Examples/3_grade_and_render_all_timelines.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | Example DaVinci Resolve script: 3 | Load a still from DRX file, apply the still to all clips in all timelines. Set render format and codec, add render jobs for all timelines, render to specified path and wait for rendering completion. 4 | Once render is complete, delete all jobs 5 | --]] 6 | 7 | local function sleep(n) 8 | os.execute("sleep " .. tonumber(n)) 9 | end 10 | 11 | local function TableConcat(t1,t2) 12 | for i=1, #t2 do 13 | t1[#t1+1] = t2[i] 14 | end 15 | return t1 16 | end 17 | 18 | local function AddTimelineToRender( project, timeline, presetName, targetDirectory, renderFormat, renderCodec ) 19 | project:SetCurrentTimeline(timeline) 20 | project:LoadRenderPreset(presetName) 21 | 22 | if not project:SetCurrentRenderFormatAndCodec(renderFormat, renderCodec) then 23 | return false 24 | end 25 | 26 | local renderSettings = {} 27 | renderSettings["SelectAllFrames"] = 1 28 | renderSettings["TargetDir"] = targetDirectory 29 | 30 | project:SetRenderSettings(renderSettings) 31 | return project:AddRenderJob() 32 | end 33 | 34 | local function RenderAllTimelines( resolve, presetName, targetDirectory, renderFormat, renderCodec ) 35 | projectManager = resolve:GetProjectManager() 36 | project = projectManager:GetCurrentProject() 37 | if not project then 38 | return false 39 | end 40 | 41 | resolve.OpenPage("Deliver") 42 | local timelineCount = project:GetTimelineCount() 43 | 44 | for index = 1, timelineCount, 1 do 45 | if not AddTimelineToRender(project, project:GetTimelineByIndex(index), presetName, targetDirectory, renderFormat, renderCodec) then 46 | return false 47 | end 48 | end 49 | 50 | return project:StartRendering() 51 | end 52 | 53 | local function IsRenderingInProgress( resolve ) 54 | projectManager = resolve:GetProjectManager() 55 | project = projectManager:GetCurrentProject() 56 | if not project then 57 | return false 58 | end 59 | 60 | return project.IsRenderingInProgress() 61 | end 62 | 63 | local function WaitForRenderingCompletion( resolve ) 64 | while IsRenderingInProgress(resolve) do 65 | sleep(1) 66 | end 67 | end 68 | 69 | local function ApplyDRXToAllTimelineClips( timeline, path, gradeMode ) 70 | gradeMode = gradeMode or 0 71 | 72 | local clips = {} 73 | 74 | local trackCount = timeline:GetTrackCount("video") 75 | for index = 1, trackCount, 1 do 76 | TableConcat(clips, timeline:GetItemsInTrack("video", index)) 77 | end 78 | 79 | return timeline:ApplyGradeFromDRX(path, tonumber(gradeMode), clips) 80 | end 81 | 82 | local function ApplyDRXToAllTimelines( resolve, path, gradeMode ) 83 | gradeMode = gradeMode or 0 84 | 85 | projectManager = resolve:GetProjectManager() 86 | project = projectManager:GetCurrentProject() 87 | if not project then 88 | return false 89 | end 90 | 91 | local timelineCount = project:GetTimelineCount() 92 | 93 | for index = 1, timelineCount, 1 do 94 | local timeline = project:GetTimelineByIndex(index) 95 | project:SetCurrentTimeline(timeline) 96 | if not ApplyDRXToAllTimelineClips(timeline, path, gradeMode) then 97 | return false 98 | end 99 | end 100 | return true 101 | end 102 | 103 | local function DeleteAllRenderJobs( resolve ) 104 | projectManager = resolve:GetProjectManager() 105 | project = projectManager:GetCurrentProject() 106 | project:DeleteAllRenderJobs() 107 | return 108 | end 109 | 110 | --[[ 111 | Inputs: 112 | - DRX file to import grade still and apply it for clips 113 | - grade mode (0, 1 or 2) 114 | - preset name for rendering 115 | - render path 116 | - render format 117 | - render codec 118 | --]] 119 | 120 | if table.getn(arg) < 6 then 121 | print("input parameters for scripts are [drx file path] [grade mode] [render preset name] [render path] [render format] [render codec]") 122 | os.exit() 123 | end 124 | 125 | drxPath = arg[1] 126 | gradeMode = arg[2] 127 | renderPresetName = arg[3] 128 | renderPath = arg[4] 129 | renderFormat = arg[5] 130 | renderCodec = arg[6] 131 | 132 | --[[ 133 | Get currently open project 134 | --]] 135 | resolve = Resolve() 136 | 137 | if not ApplyDRXToAllTimelines(resolve, drxPath, gradeMode) then 138 | print("Unable to apply a still from drx file to all timelines") 139 | os.exit() 140 | end 141 | 142 | if not RenderAllTimelines(resolve, renderPresetName, renderPath, renderFormat, renderCodec) then 143 | print("Unable to set all timelines for rendering") 144 | os.exit() 145 | end 146 | 147 | WaitForRenderingCompletion(resolve) 148 | 149 | DeleteAllRenderJobs(resolve) 150 | 151 | print("Rendering is completed.") 152 | -------------------------------------------------------------------------------- /Examples/3_grade_and_render_all_timelines.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | """ 4 | Example DaVinci Resolve script: 5 | Load a still from DRX file, apply the still to all clips in all timelines. Set render format and codec, add render jobs for all timelines, render to specified path and wait for rendering completion. 6 | Once render is complete, delete all jobs 7 | """ 8 | 9 | from python_get_resolve import GetResolve 10 | import sys 11 | import time 12 | 13 | def AddTimelineToRender( project, timeline, presetName, targetDirectory, renderFormat, renderCodec ): 14 | project.SetCurrentTimeline(timeline) 15 | project.LoadRenderPreset(presetName) 16 | 17 | if not project.SetCurrentRenderFormatAndCodec(renderFormat, renderCodec): 18 | return False 19 | 20 | project.SetRenderSettings({"SelectAllFrames" : 1, "TargetDir" : targetDirectory}) 21 | return project.AddRenderJob() 22 | 23 | def RenderAllTimelines( resolve, presetName, targetDirectory, renderFormat, renderCodec ): 24 | projectManager = resolve.GetProjectManager() 25 | project = projectManager.GetCurrentProject() 26 | if not project: 27 | return False 28 | 29 | resolve.OpenPage("Deliver") 30 | timelineCount = project.GetTimelineCount() 31 | 32 | for index in range (0, int(timelineCount)): 33 | if not AddTimelineToRender(project, project.GetTimelineByIndex(index + 1), presetName, targetDirectory, renderFormat, renderCodec): 34 | return False 35 | return project.StartRendering() 36 | 37 | def IsRenderingInProgress( resolve ): 38 | projectManager = resolve.GetProjectManager() 39 | project = projectManager.GetCurrentProject() 40 | if not project: 41 | return False 42 | 43 | return project.IsRenderingInProgress() 44 | 45 | def WaitForRenderingCompletion( resolve ): 46 | while IsRenderingInProgress(resolve): 47 | time.sleep(1) 48 | return 49 | 50 | def ApplyDRXToAllTimelineClips( timeline, path, gradeMode = 0 ): 51 | trackCount = timeline.GetTrackCount("video") 52 | 53 | clips = {} 54 | for index in range (1, int(trackCount) + 1): 55 | clips.update( timeline.GetItemsInTrack("video", index) ) 56 | return timeline.ApplyGradeFromDRX(path, int(gradeMode), clips) 57 | 58 | def ApplyDRXToAllTimelines( resolve, path, gradeMode = 0 ): 59 | projectManager = resolve.GetProjectManager() 60 | project = projectManager.GetCurrentProject() 61 | if not project: 62 | return False 63 | timelineCount = project.GetTimelineCount() 64 | 65 | for index in range (0, int(timelineCount)): 66 | timeline = project.GetTimelineByIndex(index + 1) 67 | project.SetCurrentTimeline( timeline ) 68 | if not ApplyDRXToAllTimelineClips(timeline, path, gradeMode): 69 | return False 70 | return True 71 | 72 | def DeleteAllRenderJobs( resolve ): 73 | projectManager = resolve.GetProjectManager() 74 | project = projectManager.GetCurrentProject() 75 | project.DeleteAllRenderJobs() 76 | return 77 | 78 | # Inputs: 79 | # - DRX file to import grade still and apply it for clips 80 | # - grade mode (0, 1 or 2) 81 | # - preset name for rendering 82 | # - render path 83 | # - render format 84 | # - render codec 85 | if len(sys.argv) < 7: 86 | print("input parameters for scripts are [drx file path] [grade mode] [render preset name] [render path] [render format] [render codec]") 87 | sys.exit() 88 | 89 | drxPath = sys.argv[1] 90 | gradeMode = sys.argv[2] 91 | renderPresetName = sys.argv[3] 92 | renderPath = sys.argv[4] 93 | renderFormat = sys.argv[5] 94 | renderCodec = sys.argv[6] 95 | 96 | # Get currently open project 97 | resolve = GetResolve() 98 | 99 | if not ApplyDRXToAllTimelines(resolve, drxPath, gradeMode): 100 | print("Unable to apply a still from drx file to all timelines") 101 | sys.exit() 102 | 103 | if not RenderAllTimelines(resolve, renderPresetName, renderPath, renderFormat, renderCodec): 104 | print("Unable to set all timelines for rendering") 105 | sys.exit() 106 | 107 | WaitForRenderingCompletion(resolve) 108 | 109 | DeleteAllRenderJobs(resolve) 110 | 111 | print("Rendering is completed.") 112 | -------------------------------------------------------------------------------- /Examples/4_display_project_and_folder_tree.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | Example DaVinci Resolve script: 3 | Draw folder and project tree from project manager window. 4 | --]] 5 | 6 | local function DisplayProjectsWithinFolder( projectManager, folderString, projectString ) 7 | folderString = folderString or "- " 8 | projectString = projectString or " " 9 | 10 | folderString = " "..folderString 11 | projectString = " "..projectString 12 | 13 | local projects = projectManager:GetProjectsInCurrentFolder() 14 | for projectIndex in pairs(projects) do 15 | print(projectString..projects[projectIndex]) 16 | end 17 | 18 | local folders = projectManager:GetFoldersInCurrentFolder() 19 | for folderIndex in pairs(folders) do 20 | print(folderString..folders[folderIndex]) 21 | if projectManager:OpenFolder(folders[folderIndex]) then 22 | DisplayProjectsWithinFolder(projectManager, folderString, projectString) 23 | projectManager:GotoParentFolder() 24 | end 25 | end 26 | end 27 | 28 | local function DisplayProjectTree( resolve ) 29 | projectManager = resolve:GetProjectManager() 30 | projectManager:GotoRootFolder() 31 | print("- Root folder") 32 | DisplayProjectsWithinFolder(projectManager) 33 | end 34 | 35 | resolve = Resolve() 36 | 37 | DisplayProjectTree(resolve) 38 | -------------------------------------------------------------------------------- /Examples/4_display_project_and_folder_tree.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | """ 4 | Example DaVinci Resolve script: 5 | Draw folder and project tree from project manager window. 6 | """ 7 | 8 | from python_get_resolve import GetResolve 9 | 10 | def DisplayProjectsWithinFolder( projectManager, folderString = "- ", projectString = " " ): 11 | folderString = " " + folderString 12 | projectString = " " + projectString 13 | 14 | projects = sorted(projectManager.GetProjectsInCurrentFolder().values()) 15 | for projectName in projects: 16 | print(projectString + projectName) 17 | 18 | folders = sorted(projectManager.GetFoldersInCurrentFolder().values()) 19 | for folderName in folders: 20 | print(folderString + folderName) 21 | if projectManager.OpenFolder(folderName): 22 | DisplayProjectsWithinFolder(projectManager, folderString, projectString) 23 | projectManager.GotoParentFolder() 24 | return 25 | 26 | def DisplayProjectTree( resolve ): 27 | projectManager = resolve.GetProjectManager() 28 | projectManager.GotoRootFolder() 29 | print("- Root folder") 30 | DisplayProjectsWithinFolder(projectManager) 31 | return 32 | 33 | # Get currently open project 34 | resolve = GetResolve() 35 | 36 | DisplayProjectTree(resolve) 37 | -------------------------------------------------------------------------------- /Examples/5_get_project_information.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | Example DaVinci Resolve script: 3 | Display project information: timeline, clips within timelines and media pool structure. 4 | --]] 5 | 6 | local function DisplayTimelineTrack( timeline, trackType, displayShift ) 7 | local trackCount = timeline:GetTrackCount(trackType) 8 | for index = 1, trackCount, 1 do 9 | print(displayShift.."- "..trackType.." "..index) 10 | clips = timeline:GetItemsInTrack(trackType, index) 11 | for clipIndex in pairs(clips) do 12 | print(displayShift.." "..clips[clipIndex]:GetName()) 13 | end 14 | end 15 | end 16 | 17 | local function DisplayTimelineInfo( timeline, displayShift ) 18 | print(displayShift.."- "..timeline:GetName()) 19 | displayShift = " "..displayShift 20 | DisplayTimelineTrack(timeline , "video", displayShift) 21 | DisplayTimelineTrack(timeline , "audio", displayShift) 22 | DisplayTimelineTrack(timeline , "subtitle", displayShift) 23 | return 24 | end 25 | 26 | local function DisplayTimelinesInfo( project ) 27 | print("- Timelines") 28 | local timelineCount = project:GetTimelineCount() 29 | 30 | for index = 1, timelineCount, 1 do 31 | DisplayTimelineInfo(project:GetTimelineByIndex(index), " ") 32 | end 33 | end 34 | 35 | local function DisplayFolderInfo( folder, displayShift ) 36 | print(displayShift.."- "..folder:GetName()) 37 | local clips = folder:GetClips() 38 | for clipIndex in pairs(clips) do 39 | print(displayShift.." "..clips[clipIndex]:GetClipProperty("File Name")["File Name"]) 40 | end 41 | 42 | displayShift = " "..displayShift 43 | 44 | local folders = folder:GetSubFolders() 45 | for folderIndex in pairs(folders) do 46 | DisplayFolderInfo(folders[folderIndex], displayShift) 47 | end 48 | end 49 | 50 | local function DisplayMediaPoolInfo( project ) 51 | mediaPool = project:GetMediaPool() 52 | print("- Media pool") 53 | DisplayFolderInfo(mediaPool:GetRootFolder(), " ") 54 | end 55 | 56 | local function DisplayProjectInfo( project ) 57 | print("-----------") 58 | print("Project '"..project:GetName().."':") 59 | print(" Framerate " .. project:GetSetting("timelineFrameRate")) 60 | print(" Resolution " .. project:GetSetting("timelineResolutionWidth") .. "x" .. project:GetSetting("timelineResolutionHeight")) 61 | 62 | DisplayTimelinesInfo(project) 63 | print("") 64 | DisplayMediaPoolInfo(project) 65 | end 66 | 67 | 68 | resolve = Resolve() 69 | projectManager = resolve:GetProjectManager() 70 | project = projectManager:GetCurrentProject() 71 | 72 | DisplayProjectInfo(project) 73 | -------------------------------------------------------------------------------- /Examples/5_get_project_information.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | """ 4 | Example DaVinci Resolve script: 5 | Display project information: timeline, clips within timelines and media pool structure. 6 | """ 7 | 8 | from python_get_resolve import GetResolve 9 | 10 | def DisplayTimelineTrack( timeline, trackType, displayShift ): 11 | trackCount = timeline.GetTrackCount(trackType) 12 | for index in range (1, int(trackCount) + 1): 13 | print(displayShift + "- " + trackType + " " + str(index)) 14 | clips = timeline.GetItemsInTrack(trackType, index) 15 | for clipIndex in clips: 16 | print(displayShift + " " + clips[clipIndex].GetName()) 17 | return 18 | 19 | def DisplayTimelineInfo( timeline, displayShift ): 20 | print(displayShift + "- " + timeline.GetName()) 21 | displayShift = " " + displayShift 22 | DisplayTimelineTrack(timeline , "video", displayShift) 23 | DisplayTimelineTrack(timeline , "audio", displayShift) 24 | DisplayTimelineTrack(timeline , "subtitle", displayShift) 25 | return 26 | 27 | def DisplayTimelinesInfo( project ): 28 | print("- Timelines") 29 | timelineCount = project.GetTimelineCount() 30 | 31 | for index in range (0, int(timelineCount)): 32 | DisplayTimelineInfo(project.GetTimelineByIndex(index + 1), " ") 33 | return 34 | 35 | def DisplayFolderInfo( folder, displayShift ): 36 | print(displayShift + "- " + folder.GetName()) 37 | clips = folder.GetClips() 38 | for clipIndex in clips: 39 | print(displayShift + " " + clips[clipIndex].GetClipProperty("File Name")["File Name"]) 40 | 41 | displayShift = " " + displayShift 42 | 43 | folders = folder.GetSubFolders() 44 | for folderIndex in folders: 45 | DisplayFolderInfo(folders[folderIndex], displayShift) 46 | return 47 | 48 | def DisplayMediaPoolInfo( project ): 49 | mediaPool = project.GetMediaPool() 50 | print("- Media pool") 51 | DisplayFolderInfo(mediaPool.GetRootFolder(), " ") 52 | return 53 | 54 | def DisplayProjectInfo( project ): 55 | print("-----------") 56 | print("Project '" + project.GetName() +"':") 57 | print(" Framerate " + project.GetSetting("timelineFrameRate")) 58 | print(" Resolution " + project.GetSetting("timelineResolutionWidth") + "x" + project.GetSetting("timelineResolutionHeight")) 59 | 60 | DisplayTimelinesInfo(project) 61 | print("") 62 | DisplayMediaPoolInfo(project) 63 | return 64 | 65 | # Get currently open project 66 | resolve = GetResolve() 67 | projectManager = resolve.GetProjectManager() 68 | project = projectManager.GetCurrentProject() 69 | 70 | DisplayProjectInfo(project) 71 | -------------------------------------------------------------------------------- /Examples/python_get_resolve.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | """ 4 | This file serves to return a DaVinci Resolve object 5 | """ 6 | 7 | import sys 8 | 9 | def GetResolve(): 10 | try: 11 | # The PYTHONPATH needs to be set correctly for this import statement to work. 12 | # An alternative is to import the DaVinciResolveScript by specifying absolute path (see ExceptionHandler logic) 13 | import DaVinciResolveScript as bmd 14 | except ImportError: 15 | if sys.platform.startswith("darwin"): 16 | expectedPath="/Library/Application Support/Blackmagic Design/DaVinci Resolve/Developer/Scripting/Modules/" 17 | elif sys.platform.startswith("win") or sys.platform.startswith("cygwin"): 18 | import os 19 | expectedPath=os.getenv('PROGRAMDATA') + "\\Blackmagic Design\\DaVinci Resolve\\Support\\Developer\\Scripting\\Modules\\" 20 | elif sys.platform.startswith("linux"): 21 | expectedPath="/opt/resolve/libs/Fusion/Modules/" 22 | 23 | # check if the default path has it... 24 | print("Unable to find module DaVinciResolveScript from $PYTHONPATH - trying default locations") 25 | try: 26 | import imp 27 | bmd = imp.load_source('DaVinciResolveScript', expectedPath+"DaVinciResolveScript.py") 28 | except ImportError: 29 | # No fallbacks ... report error: 30 | print("Unable to find module DaVinciResolveScript - please ensure that the module DaVinciResolveScript is discoverable by python") 31 | print("For a default DaVinci Resolve installation, the module is expected to be located in: "+expectedPath) 32 | sys.exit() 33 | 34 | return bmd.scriptapp("Resolve") 35 | -------------------------------------------------------------------------------- /Modules/DaVinciResolveScript.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import imp 3 | import os 4 | 5 | script_module = None 6 | try: 7 | import fusionscript as script_module 8 | except ImportError: 9 | # Look for installer based environment variables: 10 | import os 11 | lib_path=os.getenv("RESOLVE_SCRIPT_LIB") 12 | if lib_path: 13 | try: 14 | script_module = imp.load_dynamic("fusionscript", lib_path) 15 | except ImportError: 16 | pass 17 | if not script_module: 18 | # Look for default install locations: 19 | ext=".so" 20 | if sys.platform.startswith("darwin"): 21 | path = "/Applications/DaVinci Resolve/DaVinci Resolve.app/Contents/Libraries/Fusion/" 22 | elif sys.platform.startswith("win") or sys.platform.startswith("cygwin"): 23 | ext = ".dll" 24 | path = "C:\\Program Files\\Blackmagic Design\\DaVinci Resolve\\" 25 | elif sys.platform.startswith("linux"): 26 | path = "/opt/resolve/libs/Fusion/" 27 | 28 | try: 29 | script_module = imp.load_dynamic("fusionscript", path + "fusionscript" + ext) 30 | except ImportError: 31 | pass 32 | 33 | if script_module: 34 | sys.modules[__name__] = script_module 35 | else: 36 | raise ImportError("Could not locate module dependencies") 37 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Rationale 2 | I could not find adequate web documentation for the Davinci Resolve Api online, so I made one. [https://diop.github.io/davinci-resolve-api/#/](https://diop.github.io/davinci-resolve-api/#/) 3 | 4 | ## Updated as of 13 September 2018 5 | In this package, you will find a brief introduction to the Scripting API for DaVinci Resolve Studio. Apart from this README file, this package contains folders containing the basic import [modules](https://github.com/diop/davinci-resolve-api/tree/master/Modules) for scripting access (DaVinciResolve.py) and some representative [examples](https://github.com/diop/davinci-resolve-api/tree/master/Examples). 6 | 7 | ## Overview 8 | As with Blackmagic Design Fusion scripts, user scripts written in Lua and Python programming languages are supported. By default, scripts can be invoked from the Console window in the Fusion page, or via command line. This permission can be changed in Resolve Preferences, to be only from Console, or to be invoked from the local network. Please be aware of the security implications when allowing scripting access from outside of the Resolve application. 9 | 10 | 11 | ## Using a script 12 | DaVinci Resolve needs to be running for a script to be invoked. 13 | 14 | For a Resolve script to be executed from an external folder, the script needs to know of the API location. 15 | You may need to set the these environment variables to allow for your Python installation to pick up the appropriate dependencies as shown below: 16 | 17 | Mac OS X: 18 | RESOLVE_SCRIPT_API="/Library/Application Support/Blackmagic Design/DaVinci Resolve/Developer/Scripting/" 19 | RESOLVE_SCRIPT_LIB="/Applications/DaVinci Resolve/DaVinci Resolve.app/Contents/Libraries/Fusion/fusionscript.so" 20 | PYTHONPATH="$PYTHONPATH:$RESOLVE_SCRIPT_API/Modules/" 21 | 22 | Windows: 23 | RESOLVE_SCRIPT_API="%PROGRAMDATA%\\Blackmagic Design\\DaVinci Resolve\\Support\\Developer\\Scripting\\" 24 | RESOLVE_SCRIPT_LIB="C:\\Program Files\\Blackmagic Design\\DaVinci Resolve\\fusionscript.dll" 25 | PYTHONPATH="%PYTHONPATH%;%RESOLVE_SCRIPT_API%\\Modules\\" 26 | 27 | Linux: 28 | RESOLVE_SCRIPT_API="/opt/resolve/Developer/Scripting/" 29 | RESOLVE_SCRIPT_LIB="/opt/resolve/libs/Fusion/fusionscript.so" 30 | PYTHONPATH="$PYTHONPATH:$RESOLVE_SCRIPT_API/Modules/" 31 | (Note: For standard ISO Linux installations, the path above may need to be modified to refer to /home/resolve instead of /opt/resolve) 32 | 33 | As with Fusion scripts, Resolve scripts can also be invoked via the menu and the Console. 34 | 35 | On startup, DaVinci Resolve scans the Utility Scripts directory and enumerates the scripts found in the Script application menu. Placing your script in this folder and invoking it from this menu is the easiest way to use scripts. The Utility Scripts folder is located in: 36 | Mac OS X: /Library/Application Support/Blackmagic Design/DaVinci Resolve/Fusion/Scripts/Comp/ 37 | Windows: %APPDATA%\Blackmagic Design\DaVinci Resolve\Fusion\Scripts\Comp\ 38 | Linux: /opt/resolve/Fusion/Scripts/Comp/ (or /home/resolve/Fusion/Scripts/Comp/ depending on installation) 39 | 40 | The interactive Console window allows for an easy way to execute simple scripting commands, to query or modify properties, and to test scripts. The console accepts commands in Python 2.7, Python 3.6 and Lua and evaluates and executes them immediately. For more information on how to use the Console, please refer to the DaVinci Resolve User Manual. 41 | 42 | This example Python script creates a simple project: 43 | #!/usr/bin/env python 44 | import DaVinciResolveScript as dvr_script 45 | resolve = dvr_script.scriptapp("Resolve") 46 | fusion = resolve.Fusion() 47 | projectManager = resolve.GetProjectManager() 48 | projectManager.CreateProject("Hello World") 49 | 50 | The resolve object is the fundamental starting point for scripting via Resolve. As a native object, it can be inspected for further scriptable properties - using table iteration and `getmetatable` in Lua and dir, help etc in Python (among other methods). A notable scriptable object above is fusion - it allows access to all existing Fusion scripting functionality. 51 | 52 | ## Basic Resolve API: 53 | ------------------ 54 | 55 | Some commonly used API functions are described below (*). As with the resolve object, each object is inspectable for properties and functions. 56 | 57 | 58 | ### `Resolve` 59 | * ```Fusion()``` --> Fusion # Returns the Fusion object. Starting point for Fusion scripts. 60 | * ```GetMediaStorage()``` --> MediaStorage # Returns media storage object to query and act on media locations. 61 | * ```GetProjectManager()``` --> ProjectManager # Returns project manager object for currently open database. 62 | * ```OpenPage(pageName)``` --> None # Switches to indicated page in DaVinci Resolve. Input can be one of ("media", "edit", "fusion", "color", "fairlight", "deliver"). 63 | ### `ProjectManager` 64 | * ```CreateProject(projectName)``` --> Project # Creates and returns a project if projectName (text) is unique, and None if it is not. 65 | * ```LoadProject(projectName) ``` --> Project # Loads and returns the project with name = projectName (text) if there is a match found, and None if there is no matching Project. 66 | * ```GetCurrentProject()``` --> Project # Returns the currently loaded Resolve project. 67 | * ```SaveProject()``` --> Bool # Saves the currently loaded project with its own name. Returns True if successful. 68 | * ```CreateFolder(folderName)``` --> Bool # Creates a folder if folderName (text) is unique.` 69 | * ```GetFoldersInCurrentFolder()``` --> [folder names...] # Returns an array of folder names in current folder. 70 | * ```GotoRootFolder()``` --> Bool # Opens root folder in database. 71 | * ```GotoParentFolder()``` --> Bool # Opens parent folder of current folder in database if current folder has parent. 72 | * ```OpenFolder(folderName)``` --> Bool # Opens folder under given name. 73 | ### `Project` 74 | * ```GetMediaPool()``` --> MediaPool # Returns the Media Pool object. 75 | * ```GetTimelineCount()``` --> int # Returns the number of timelines currently present in the project. 76 | * ```GetTimelineByIndex(idx)``` --> Timeline # Returns timeline at the given index, 1 <= idx <= project.GetTimelineCount() 77 | * ```GetCurrentTimeline()``` --> Timeline # Returns the currently loaded timeline. 78 | * ```GetName()``` --> string # Returns project name. 79 | * ```SetCurrentTimeline(timeline)``` --> Bool # Sets given timeline as current timeline for the project. Returns True if successful. 80 | * ```SetName(projectName)``` --> Bool # Sets project name if given projectname (text) is une. 81 | * ```GetPresets()``` --> [presets...] # Returns a table of presets and their information. 82 | * ```SetPreset(presetName)``` --> Bool # Sets preset by given presetName (string) into project. 83 | * ```GetRenderJobs()``` --> [render jobs...] # Returns a table of render jobs and their information. 84 | * ```GetRenderPresets()``` --> [presets...] # Returns a table of render presets and their information. 85 | * ```StartRendering(index1, index2, ...)``` --> Bool # Starts rendering for given render jobs based on their indices. If no parameter is given rendering would start for all render jobs. 86 | * ```StartRendering([idxs...])``` --> Bool # Starts rendering for given render jobs based on their indices. If no parameter is given rendering would start for all render jobs. 87 | * ```StopRendering()``` --> None # Stops rendering for all render jobs. 88 | * ```IsRenderingInProgress()``` --> Bool # Returns true is rendering is in progress. 89 | * ```AddRenderJob()``` --> Bool # Adds render job to render queue. 90 | * ```DeleteRenderJobByIndex(idx)``` --> Bool # Deletes render job based on given job index (int). 91 | * ```DeleteAllRenderJobs()``` --> Bool # Deletes all render jobs. 92 | * ```LoadRenderPreset(presetName)``` --> Bool # Sets a preset as current preset for rendering if presetName (text) exists. 93 | * ```SaveAsNewRenderPreset(presetName)``` --> Bool # Creates a new render preset by given name if presetName(text) is unique. 94 | * ```SetRenderSettings([settings map])``` --> Bool # Sets given settings for rendering. Settings map is a map, keys of map are: "SelectAllFrames", "MarkIn", "MarkOut", "TargetDir", "CustomName". 95 | * ```GetRenderJobStatus(idx)``` --> [status info] # Returns job status and completion rendering percentage of the job by given job index (int). 96 | * ```GetSetting(settingName)``` --> string # Returns setting value by given settingName (string) if the setting exist. With empty settingName the function returns a full list of settings. 97 | * ```SetSetting(settingName, settingValue)``` --> Bool # Sets project setting base on given name (string) and value (string). 98 | * ```GetRenderFormats()``` --> [render formats...]# Returns a list of available render formats. 99 | * ```GetRenderCodecs(renderFormat)``` --> [render codecs...] # Returns a list of available codecs for given render format (string). 100 | * ```SetCurrentRenderFormatAndCodec(format, codec)``` --> Bool # Sets given render format (string) and render codec (string) as options for rendering. 101 | ### `MediaStorage` 102 | * ```GetMountedVolumes()``` --> [paths...] # Returns an array of folder paths corresponding to mounted volumes displayed in Resolve’s Media Storage. 103 | * ```GetSubFolders(folderPath)``` --> [paths...] # Returns an array of folder paths in the given absolute folder path. 104 | * ```GetFiles(folderPath)``` --> [paths...] # Returns an array of media and file listings in the given absolute folder path. Note that media listings may be logically consolidated entries. 105 | * ```RevealInStorage(path)``` --> None # Expands and displays a given file/folder path in Resolve’s Media Storage. 106 | * ```AddItemsToMediaPool(item1, item2, ...)``` --> [clips...] # Adds specified file/folder paths from Media Store into current Media Pool folder. Input is one or more file/folder paths. 107 | * ```AddItemsToMediaPool([items...])``` --> [clips...] # Adds specified file/folder paths from Media Store into current Media Pool folder. Input is an array of file/folder paths. 108 | ### `MediaPool` 109 | * ```GetRootFolder()``` --> Folder # Returns the root Folder of Media Pool 110 | * ```AddSubFolder(folder, name)``` --> Folder # Adds a new subfolder under specified Folder object with the given name. 111 | * ```CreateEmptyTimeline(name)``` --> Timeline # Adds a new timeline with given name.``` 112 | * ```AppendToTimeline(clip1, clip2...)``` --> Bool # Appends specified MediaPoolItem objects in the current timeline. Returns True if successful. 113 | * ```AppendToTimeline([clips])``` --> Bool # Appends specified MediaPoolItem objects in the current timeline. Returns True if successful. 114 | * ```CreateTimelineFromClips(name, clip1, clip2, ...)```--> Timeline # Creates a new timeline with specified name, and appends the specified MediaPoolItem objects. 115 | * ```CreateTimelineFromClips(name, [clips])``` --> Timeline # Creates a new timeline with specified name, and appends the specified MediaPoolItem objects. 116 | * ```ImportTimelineFromFile(filePath)``` --> Timeline # Creates timeline based on parameters within given file. 117 | * ```GetCurrentFolder()``` --> Folder # Returns currently selected Folder. 118 | * ```SetCurrentFolder(Folder)``` --> Bool # Sets current folder by given Folder. 119 | * ```CreateEmptyTimeline(timelineName)``` --> Timeline # Creates a new timeline with specified name is timelineName (text) is unique. 120 | ### `Folder` 121 | * ```GetClips()``` --> [clips...] # Returns a list of clips (items) within the folder. 122 | * ```GetName()``` --> string # Returns user-defined name of the folder. 123 | * ```GetSubFolders()``` --> [folders...] # Returns a list of subfolders in the folder. 124 | ### `MediaPoolItem` 125 | * ```GetMetadata(metadataType)``` --> [[types],[values]] # Returns a value of metadataType. If parameter is not specified returns all set metadata parameters. 126 | * ```SetMetadata(metadataType, metadataValue)``` --> Bool # Sets metadata by given type and value. Returns True if successful. 127 | * ```GetMediaId()``` --> string # Returns a unique ID name related to MediaPoolItem. 128 | * ```AddMarker(frameId, color, name, note, duration)``` --> Bool # Creates a new marker at given frameId position and with given marker information. 129 | * ```GetMarkers()``` --> [markers...] # Returns a list of all markers and their information. 130 | * ```AddFlag(color)``` --> Bool # Adds a flag with given color (text). 131 | * ```GetFlags()``` --> [colors...] # Returns a list of flag colors assigned to the item. 132 | * ```GetClipColor()``` --> string # Returns an item color as a string. 133 | * ```GetClipProperty(propertyName)``` --> [[types],[values]] # Returns property value related to the item based on given propertyName (string). if propertyName is empty then it returns a full list of properties. 134 | * ```SetClipProperty(propertyName, propertyValue)``` --> Bool # Sets into given propertyName (string) propertyValue (string). 135 | ### `Timeline` 136 | * ```GetName()``` --> string # Returns user-defined name of the timeline. 137 | * ```SetName(timelineName)``` --> Bool # Sets timeline name is timelineName (text) is unique. 138 | * ```GetStartFrame()``` --> int # Returns frame number at the start of timeline. 139 | * ```GetEndFrame()``` --> int # Returns frame number at the end of timeline. 140 | * ```GetTrackCount(trackType)``` --> int # Returns a number of track based on specified track type ("audio", "video" or "subtitle"). 141 | * ```GetItemsInTrack(trackType, index)``` --> [items...] # Returns an array of Timeline items on the video or audio track (based on trackType) at specified index. 1 <= index <= GetTrackCount(trackType).``` 142 | * ```AddMarker(frameId, color, name, note, duration)``` --> Bool # Creates a new marker at given frameId position and with given marker information. 143 | * ```ApplyGradeFromDRX(path, gradeMode, item1, item2, ...)```--> Bool # Loads a still from given file path (string) and applies grade to Timeline Items with gradeMode (int): 0 - "No keyframes", 1 - "Source Timecode aligned", 2 - "Start Frames aligned". 144 | * ```ApplyGradeFromDRX(path, gradeMode, [items])``` --> Bool # Loads a still from given file path (string) and applies grade to Timeline Items with gradeMode (int): 0 - "No keyframes", 1 - "Source Timecode aligned", 2 - "Start Frames aligned". 145 | ### `TimelineItem` 146 | * ```GetName()``` --> string # Returns a name of the item. 147 | * ```GetDuration()``` --> int # Returns a duration of item. 148 | * ```GetEnd()``` --> int # Returns a position of end frame. 149 | * ```GetFusionCompByIndex(compIndex)``` --> fusionComp # Returns Fusion composition object based on given index. 1 <= compIndex <= timelineItem.GetFusionCompCount() 150 | * ```GetFusionCompNames()``` --> [names...] # Returns a list of Fusion composition names associated with the timeline item. 151 | * ```GetFusionCompByName(compName)``` --> fusionComp # Returns Fusion composition object based on given name. 152 | * ```GetLeftOffset()``` --> int # Returns a maximum extension by frame for clip from left side. 153 | * ```GetRightOffset()``` --> int # Returns a maximum extension by frame for clip from right side. 154 | * ```GetStart()``` --> int # Returns a position of first frame. 155 | * ```AddMarker(frameId, color, name, note, duration)``` --> Bool # Creates a new marker at given frameId position and with given marker information. 156 | * ```GetMarkers()``` --> [markers...] # Returns a list of all markers and their information. 157 | * ```GetFlags()``` --> [colors...] # Returns a list of flag colors assigned to the item. 158 | * ```GetClipColor()``` --> string # Returns an item color as a string. 159 | * ```AddFusionComp()``` --> fusionComp # Adds a new Fusion composition associated with the timeline item. 160 | 161 | @ Author - Fodé Diop - Computer Science Student at Make School, San Francisco CA. -------------------------------------------------------------------------------- /docs/.nojekyll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/diop/davinci-resolve-api/a75fd3d22a921cd1a749dbb36bb9e1ae6f5ce781/docs/.nojekyll -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | ## Rationale 2 | I could not find adequate web documentation for the Davinci Resolve Api online, so I made one. [https://diop.github.io/davinci-resolve-api/#/](https://diop.github.io/davinci-resolve-api/#/) 3 | 4 | ## Updated as of 13 September 2018 5 | In this package, you will find a brief introduction to the Scripting API for DaVinci Resolve Studio. Apart from this README file, this package contains folders containing the basic import [modules](https://github.com/diop/davinci-resolve-api/tree/master/Modules) for scripting access (DaVinciResolve.py) and some representative [examples](https://github.com/diop/davinci-resolve-api/tree/master/Examples). 6 | 7 | ## Overview 8 | As with Blackmagic Design Fusion scripts, user scripts written in Lua and Python programming languages are supported. By default, scripts can be invoked from the Console window in the Fusion page, or via command line. This permission can be changed in Resolve Preferences, to be only from Console, or to be invoked from the local network. Please be aware of the security implications when allowing scripting access from outside of the Resolve application. 9 | 10 | 11 | ## Using a script 12 | DaVinci Resolve needs to be running for a script to be invoked. 13 | 14 | For a Resolve script to be executed from an external folder, the script needs to know of the API location. 15 | You may need to set the these environment variables to allow for your Python installation to pick up the appropriate dependencies as shown below: 16 | 17 | Mac OS X: 18 | RESOLVE_SCRIPT_API="/Library/Application Support/Blackmagic Design/DaVinci Resolve/Developer/Scripting/" 19 | RESOLVE_SCRIPT_LIB="/Applications/DaVinci Resolve/DaVinci Resolve.app/Contents/Libraries/Fusion/fusionscript.so" 20 | PYTHONPATH="$PYTHONPATH:$RESOLVE_SCRIPT_API/Modules/" 21 | 22 | Windows: 23 | RESOLVE_SCRIPT_API="%PROGRAMDATA%\\Blackmagic Design\\DaVinci Resolve\\Support\\Developer\\Scripting\\" 24 | RESOLVE_SCRIPT_LIB="C:\\Program Files\\Blackmagic Design\\DaVinci Resolve\\fusionscript.dll" 25 | PYTHONPATH="%PYTHONPATH%;%RESOLVE_SCRIPT_API%\\Modules\\" 26 | 27 | Linux: 28 | RESOLVE_SCRIPT_API="/opt/resolve/Developer/Scripting/" 29 | RESOLVE_SCRIPT_LIB="/opt/resolve/libs/Fusion/fusionscript.so" 30 | PYTHONPATH="$PYTHONPATH:$RESOLVE_SCRIPT_API/Modules/" 31 | (Note: For standard ISO Linux installations, the path above may need to be modified to refer to /home/resolve instead of /opt/resolve) 32 | 33 | As with Fusion scripts, Resolve scripts can also be invoked via the menu and the Console. 34 | 35 | On startup, DaVinci Resolve scans the Utility Scripts directory and enumerates the scripts found in the Script application menu. Placing your script in this folder and invoking it from this menu is the easiest way to use scripts. The Utility Scripts folder is located in: 36 | Mac OS X: /Library/Application Support/Blackmagic Design/DaVinci Resolve/Fusion/Scripts/Comp/ 37 | Windows: %APPDATA%\Blackmagic Design\DaVinci Resolve\Fusion\Scripts\Comp\ 38 | Linux: /opt/resolve/Fusion/Scripts/Comp/ (or /home/resolve/Fusion/Scripts/Comp/ depending on installation) 39 | 40 | The interactive Console window allows for an easy way to execute simple scripting commands, to query or modify properties, and to test scripts. The console accepts commands in Python 2.7, Python 3.6 and Lua and evaluates and executes them immediately. For more information on how to use the Console, please refer to the DaVinci Resolve User Manual. 41 | 42 | This example Python script creates a simple project: 43 | #!/usr/bin/env python 44 | import DaVinciResolveScript as dvr_script 45 | resolve = dvr_script.scriptapp("Resolve") 46 | fusion = resolve.Fusion() 47 | projectManager = resolve.GetProjectManager() 48 | projectManager.CreateProject("Hello World") 49 | 50 | The resolve object is the fundamental starting point for scripting via Resolve. As a native object, it can be inspected for further scriptable properties - using table iteration and `getmetatable` in Lua and dir, help etc in Python (among other methods). A notable scriptable object above is fusion - it allows access to all existing Fusion scripting functionality. 51 | 52 | ## Basic Resolve API: 53 | ------------------ 54 | 55 | Some commonly used API functions are described below (*). As with the resolve object, each object is inspectable for properties and functions. 56 | 57 | 58 | ### `Resolve` 59 | * ```Fusion()``` --> Fusion # Returns the Fusion object. Starting point for Fusion scripts. 60 | * ```GetMediaStorage()``` --> MediaStorage # Returns media storage object to query and act on media locations. 61 | * ```GetProjectManager()``` --> ProjectManager # Returns project manager object for currently open database. 62 | * ```OpenPage(pageName)``` --> None # Switches to indicated page in DaVinci Resolve. Input can be one of ("media", "edit", "fusion", "color", "fairlight", "deliver"). 63 | ### `ProjectManager` 64 | * ```CreateProject(projectName)``` --> Project # Creates and returns a project if projectName (text) is unique, and None if it is not. 65 | * ```LoadProject(projectName) ``` --> Project # Loads and returns the project with name = projectName (text) if there is a match found, and None if there is no matching Project. 66 | * ```GetCurrentProject()``` --> Project # Returns the currently loaded Resolve project. 67 | * ```SaveProject()``` --> Bool # Saves the currently loaded project with its own name. Returns True if successful. 68 | * ```CreateFolder(folderName)``` --> Bool # Creates a folder if folderName (text) is unique.` 69 | * ```GetFoldersInCurrentFolder()``` --> [folder names...] # Returns an array of folder names in current folder. 70 | * ```GotoRootFolder()``` --> Bool # Opens root folder in database. 71 | * ```GotoParentFolder()``` --> Bool # Opens parent folder of current folder in database if current folder has parent. 72 | * ```OpenFolder(folderName)``` --> Bool # Opens folder under given name. 73 | ### `Project` 74 | * ```GetMediaPool()``` --> MediaPool # Returns the Media Pool object. 75 | * ```GetTimelineCount()``` --> int # Returns the number of timelines currently present in the project. 76 | * ```GetTimelineByIndex(idx)``` --> Timeline # Returns timeline at the given index, 1 <= idx <= project.GetTimelineCount() 77 | * ```GetCurrentTimeline()``` --> Timeline # Returns the currently loaded timeline. 78 | * ```GetName()``` --> string # Returns project name. 79 | * ```SetCurrentTimeline(timeline)``` --> Bool # Sets given timeline as current timeline for the project. Returns True if successful. 80 | * ```SetName(projectName)``` --> Bool # Sets project name if given projectname (text) is une. 81 | * ```GetPresets()``` --> [presets...] # Returns a table of presets and their information. 82 | * ```SetPreset(presetName)``` --> Bool # Sets preset by given presetName (string) into project. 83 | * ```GetRenderJobs()``` --> [render jobs...] # Returns a table of render jobs and their information. 84 | * ```GetRenderPresets()``` --> [presets...] # Returns a table of render presets and their information. 85 | * ```StartRendering(index1, index2, ...)``` --> Bool # Starts rendering for given render jobs based on their indices. If no parameter is given rendering would start for all render jobs. 86 | * ```StartRendering([idxs...])``` --> Bool # Starts rendering for given render jobs based on their indices. If no parameter is given rendering would start for all render jobs. 87 | * ```StopRendering()``` --> None # Stops rendering for all render jobs. 88 | * ```IsRenderingInProgress()``` --> Bool # Returns true is rendering is in progress. 89 | * ```AddRenderJob()``` --> Bool # Adds render job to render queue. 90 | * ```DeleteRenderJobByIndex(idx)``` --> Bool # Deletes render job based on given job index (int). 91 | * ```DeleteAllRenderJobs()``` --> Bool # Deletes all render jobs. 92 | * ```LoadRenderPreset(presetName)``` --> Bool # Sets a preset as current preset for rendering if presetName (text) exists. 93 | * ```SaveAsNewRenderPreset(presetName)``` --> Bool # Creates a new render preset by given name if presetName(text) is unique. 94 | * ```SetRenderSettings([settings map])``` --> Bool # Sets given settings for rendering. Settings map is a map, keys of map are: "SelectAllFrames", "MarkIn", "MarkOut", "TargetDir", "CustomName". 95 | * ```GetRenderJobStatus(idx)``` --> [status info] # Returns job status and completion rendering percentage of the job by given job index (int). 96 | * ```GetSetting(settingName)``` --> string # Returns setting value by given settingName (string) if the setting exist. With empty settingName the function returns a full list of settings. 97 | * ```SetSetting(settingName, settingValue)``` --> Bool # Sets project setting base on given name (string) and value (string). 98 | * ```GetRenderFormats()``` --> [render formats...]# Returns a list of available render formats. 99 | * ```GetRenderCodecs(renderFormat)``` --> [render codecs...] # Returns a list of available codecs for given render format (string). 100 | * ```SetCurrentRenderFormatAndCodec(format, codec)``` --> Bool # Sets given render format (string) and render codec (string) as options for rendering. 101 | ### `MediaStorage` 102 | * ```GetMountedVolumes()``` --> [paths...] # Returns an array of folder paths corresponding to mounted volumes displayed in Resolve’s Media Storage. 103 | * ```GetSubFolders(folderPath)``` --> [paths...] # Returns an array of folder paths in the given absolute folder path. 104 | * ```GetFiles(folderPath)``` --> [paths...] # Returns an array of media and file listings in the given absolute folder path. Note that media listings may be logically consolidated entries. 105 | * ```RevealInStorage(path)``` --> None # Expands and displays a given file/folder path in Resolve’s Media Storage. 106 | * ```AddItemsToMediaPool(item1, item2, ...)``` --> [clips...] # Adds specified file/folder paths from Media Store into current Media Pool folder. Input is one or more file/folder paths. 107 | * ```AddItemsToMediaPool([items...])``` --> [clips...] # Adds specified file/folder paths from Media Store into current Media Pool folder. Input is an array of file/folder paths. 108 | ### `MediaPool` 109 | * ```GetRootFolder()``` --> Folder # Returns the root Folder of Media Pool 110 | * ```AddSubFolder(folder, name)``` --> Folder # Adds a new subfolder under specified Folder object with the given name. 111 | * ```CreateEmptyTimeline(name)``` --> Timeline # Adds a new timeline with given name.``` 112 | * ```AppendToTimeline(clip1, clip2...)``` --> Bool # Appends specified MediaPoolItem objects in the current timeline. Returns True if successful. 113 | * ```AppendToTimeline([clips])``` --> Bool # Appends specified MediaPoolItem objects in the current timeline. Returns True if successful. 114 | * ```CreateTimelineFromClips(name, clip1, clip2, ...)```--> Timeline # Creates a new timeline with specified name, and appends the specified MediaPoolItem objects. 115 | * ```CreateTimelineFromClips(name, [clips])``` --> Timeline # Creates a new timeline with specified name, and appends the specified MediaPoolItem objects. 116 | * ```ImportTimelineFromFile(filePath)``` --> Timeline # Creates timeline based on parameters within given file. 117 | * ```GetCurrentFolder()``` --> Folder # Returns currently selected Folder. 118 | * ```SetCurrentFolder(Folder)``` --> Bool # Sets current folder by given Folder. 119 | * ```CreateEmptyTimeline(timelineName)``` --> Timeline # Creates a new timeline with specified name is timelineName (text) is unique. 120 | ### `Folder` 121 | * ```GetClips()``` --> [clips...] # Returns a list of clips (items) within the folder. 122 | * ```GetName()``` --> string # Returns user-defined name of the folder. 123 | * ```GetSubFolders()``` --> [folders...] # Returns a list of subfolders in the folder. 124 | ### `MediaPoolItem` 125 | * ```GetMetadata(metadataType)``` --> [[types],[values]] # Returns a value of metadataType. If parameter is not specified returns all set metadata parameters. 126 | * ```SetMetadata(metadataType, metadataValue)``` --> Bool # Sets metadata by given type and value. Returns True if successful. 127 | * ```GetMediaId()``` --> string # Returns a unique ID name related to MediaPoolItem. 128 | * ```AddMarker(frameId, color, name, note, duration)``` --> Bool # Creates a new marker at given frameId position and with given marker information. 129 | * ```GetMarkers()``` --> [markers...] # Returns a list of all markers and their information. 130 | * ```AddFlag(color)``` --> Bool # Adds a flag with given color (text). 131 | * ```GetFlags()``` --> [colors...] # Returns a list of flag colors assigned to the item. 132 | * ```GetClipColor()``` --> string # Returns an item color as a string. 133 | * ```GetClipProperty(propertyName)``` --> [[types],[values]] # Returns property value related to the item based on given propertyName (string). if propertyName is empty then it returns a full list of properties. 134 | * ```SetClipProperty(propertyName, propertyValue)``` --> Bool # Sets into given propertyName (string) propertyValue (string). 135 | ### `Timeline` 136 | * ```GetName()``` --> string # Returns user-defined name of the timeline. 137 | * ```SetName(timelineName)``` --> Bool # Sets timeline name is timelineName (text) is unique. 138 | * ```GetStartFrame()``` --> int # Returns frame number at the start of timeline. 139 | * ```GetEndFrame()``` --> int # Returns frame number at the end of timeline. 140 | * ```GetTrackCount(trackType)``` --> int # Returns a number of track based on specified track type ("audio", "video" or "subtitle"). 141 | * ```GetItemsInTrack(trackType, index)``` --> [items...] # Returns an array of Timeline items on the video or audio track (based on trackType) at specified index. 1 <= index <= GetTrackCount(trackType).``` 142 | * ```AddMarker(frameId, color, name, note, duration)``` --> Bool # Creates a new marker at given frameId position and with given marker information. 143 | * ```ApplyGradeFromDRX(path, gradeMode, item1, item2, ...)```--> Bool # Loads a still from given file path (string) and applies grade to Timeline Items with gradeMode (int): 0 - "No keyframes", 1 - "Source Timecode aligned", 2 - "Start Frames aligned". 144 | * ```ApplyGradeFromDRX(path, gradeMode, [items])``` --> Bool # Loads a still from given file path (string) and applies grade to Timeline Items with gradeMode (int): 0 - "No keyframes", 1 - "Source Timecode aligned", 2 - "Start Frames aligned". 145 | ### `TimelineItem` 146 | * ```GetName()``` --> string # Returns a name of the item. 147 | * ```GetDuration()``` --> int # Returns a duration of item. 148 | * ```GetEnd()``` --> int # Returns a position of end frame. 149 | * ```GetFusionCompByIndex(compIndex)``` --> fusionComp # Returns Fusion composition object based on given index. 1 <= compIndex <= timelineItem.GetFusionCompCount() 150 | * ```GetFusionCompNames()``` --> [names...] # Returns a list of Fusion composition names associated with the timeline item. 151 | * ```GetFusionCompByName(compName)``` --> fusionComp # Returns Fusion composition object based on given name. 152 | * ```GetLeftOffset()``` --> int # Returns a maximum extension by frame for clip from left side. 153 | * ```GetRightOffset()``` --> int # Returns a maximum extension by frame for clip from right side. 154 | * ```GetStart()``` --> int # Returns a position of first frame. 155 | * ```AddMarker(frameId, color, name, note, duration)``` --> Bool # Creates a new marker at given frameId position and with given marker information. 156 | * ```GetMarkers()``` --> [markers...] # Returns a list of all markers and their information. 157 | * ```GetFlags()``` --> [colors...] # Returns a list of flag colors assigned to the item. 158 | * ```GetClipColor()``` --> string # Returns an item color as a string. 159 | * ```AddFusionComp()``` --> fusionComp # Adds a new Fusion composition associated with the timeline item. 160 | 161 | @ Author - Fodé Diop - Computer Science Student at Make School, San Francisco CA. -------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | davinci-resolve-script - Davinci Resolve Scripting Documentation 6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "davinci-resolve-script", 3 | "version": "1.0.0", 4 | "lockfileVersion": 1 5 | } 6 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "davinci-resolve-script", 3 | "version": "1.0.0", 4 | "description": "Davinci Resolve Scripting Documentation", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [ 10 | "davinci", 11 | "resolve", 12 | "scripting", 13 | "documentation" 14 | ], 15 | "author": "Fodé Diop", 16 | "license": "MIT", 17 | "dependencies": {} 18 | } 19 | --------------------------------------------------------------------------------