├── BenermanResolveStartup.py ├── Resolve Documentation └── resolve_class_build.py /BenermanResolveStartup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # Benerman's Resolve Script 4 | 5 | # import DaVinciResolveScript 6 | from resolve_class_build import R 7 | import sys 8 | import time 9 | import tkinter as tk 10 | from tkinter import filedialog 11 | from tkinter import simpledialog 12 | import os 13 | 14 | root = tk.Tk() 15 | root.withdraw() 16 | 17 | 18 | ### Create and Name Project 19 | def create_project(): 20 | global project_name 21 | project_name = simpledialog.askstring("Input", "Please name the Project?", 22 | parent=root) 23 | if project_name is not None: 24 | print(f"Project name is: {project_name}") 25 | else: 26 | print("Error: Project name not set.\n\nScript is now exiting") 27 | sys.exit() 28 | 29 | if R.SetProjectName(project_name): 30 | print(f'Project {project_name} created successfully') 31 | else: 32 | print('Error: Failed to create project\nProject already potentially exists or dialog box is preventing script from continuing') 33 | create_project() 34 | 35 | create_project() 36 | 37 | ## Set Project Settings 38 | # Choose between 4k and 2k 39 | # Choose between 23.976p, 29.97p, 60p 40 | 41 | ### Create Folder Structure 42 | ## 'Master'(Root) 43 | ## 'Video', 'Audio', 'Stills', 'Exports', 'Projects' 44 | ## 'Video' > 'Raw', 'Converted' 45 | ## 'Audio' > 'Raw', 'Tracks', 'Foley' 46 | ## 'Stills' > 'Raw', 'Proofs' 47 | 48 | 49 | ### Import Media(Different Types) 50 | my_filetypes = [('all files', '.*'), ('text files', '.txt')] 51 | 52 | # Ask the user to select a one or more file names. 53 | # answer = tk.filedialog.askopenfilenames(parent=root, 54 | # initialdir=os.getcwd(), 55 | # title="Please select one or more files:", 56 | # filetypes=my_filetypes) 57 | 58 | 59 | 60 | 61 | 62 | mediaPath = filedialog.askdirectory(parent=root,initialdir="/",title='Please select a directory') 63 | if mediaPath: 64 | print(f'Media will be imported from: {mediaPath}') 65 | else: 66 | print('Error: No file path selected for file import') 67 | 68 | ### Create Timelines 69 | # 'All Clips' and 'Final' 70 | 71 | ## Add All Clips to 'All Clips Timeline' 72 | 73 | 74 | -------------------------------------------------------------------------------- /Resolve Documentation: -------------------------------------------------------------------------------- 1 | Resolve 2 | Fusion() --> Fusion # Returns the Fusion object. Starting point for Fusion scripts. 3 | GetMediaStorage() --> MediaStorage # Returns media storage object to query and act on media locations. 4 | GetProjectManager() --> ProjectManager # Returns project manager object for currently open database. 5 | OpenPage(pageName) --> None # Switches to indicated page in DaVinci Resolve. Input can be one of ("media", "edit", "fusion", "color", "fairlight", "deliver"). 6 | ProjectManager 7 | CreateProject(projectName) --> Project # Creates and returns a project if projectName (text) is unique, and None if it is not. 8 | 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. 9 | GetCurrentProject() --> Project # Returns the currently loaded Resolve project. 10 | SaveProject() --> Bool # Saves the currently loaded project with its own name. Returns True if successful. 11 | CreateFolder(folderName) --> Bool # Creates a folder if folderName (text) is unique. 12 | GetProjectsInCurrentFolder() --> [project names...] # Returns an array of project names in current folder. 13 | GetFoldersInCurrentFolder() --> [folder names...] # Returns an array of folder names in current folder. 14 | GotoRootFolder() --> Bool # Opens root folder in database. 15 | GotoParentFolder() --> Bool # Opens parent folder of current folder in database if current folder has parent. 16 | OpenFolder(folderName) --> Bool # Opens folder under given name. 17 | ImportProject(filePath) --> Bool # Imports a project under given file path. Returns true in case of success. 18 | ExportProject(projectName, filePath) --> Bool # Exports a project based on given name into provided file path. Returns true in case of success. 19 | RestoreProject(filePath) --> Bool # Restores a project under given backup file path. Returns true in case of success. 20 | Project 21 | GetMediaPool() --> MediaPool # Returns the Media Pool object. 22 | GetTimelineCount() --> int # Returns the number of timelines currently present in the project. 23 | GetTimelineByIndex(idx) --> Timeline # Returns timeline at the given index, 1 <= idx <= project.GetTimelineCount() 24 | GetCurrentTimeline() --> Timeline # Returns the currently loaded timeline. 25 | SetCurrentTimeline(timeline) --> Bool # Sets given timeline as current timeline for the project. Returns True if successful. 26 | GetName() --> string # Returns project name. 27 | SetName(projectName) --> Bool # Sets project name if given projectname (text) is unique. 28 | GetPresets() --> [presets...] # Returns a table of presets and their information. 29 | SetPreset(presetName) --> Bool # Sets preset by given presetName (string) into project. 30 | GetRenderJobs() --> [render jobs...] # Returns a table of render jobs and their information. 31 | GetRenderPresets() --> [presets...] # Returns a table of render presets and their information. 32 | 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. 33 | 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. 34 | StopRendering() --> None # Stops rendering for all render jobs. 35 | IsRenderingInProgress() --> Bool # Returns true is rendering is in progress. 36 | AddRenderJob() --> Bool # Adds render job to render queue. 37 | DeleteRenderJobByIndex(idx) --> Bool # Deletes render job based on given job index (int). 38 | DeleteAllRenderJobs() --> Bool # Deletes all render jobs. 39 | LoadRenderPreset(presetName) --> Bool # Sets a preset as current preset for rendering if presetName (text) exists. 40 | SaveAsNewRenderPreset(presetName) --> Bool # Creates a new render preset by given name if presetName(text) is unique. 41 | SetRenderSettings([settings map]) --> Bool # Sets given settings for rendering. Settings map is a map, keys of map are: "SelectAllFrames", "MarkIn", "MarkOut", "TargetDir", "CustomName". 42 | GetRenderJobStatus(idx) --> [status info] # Returns job status and completion rendering percentage of the job by given job index (int). 43 | 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. 44 | SetSetting(settingName, settingValue) --> Bool # Sets project setting base on given name (string) and value (string). 45 | GetRenderFormats() --> [render formats...]# Returns a list of available render formats. 46 | GetRenderCodecs(renderFormat) --> [render codecs...] # Returns a list of available codecs for given render format (string). 47 | GetCurrentRenderFormatAndCodec() --> [format, codec] # Returns currently selected render format and render codec. 48 | SetCurrentRenderFormatAndCodec(format, codec) --> Bool # Sets given render format (string) and render codec (string) as options for rendering. 49 | MediaStorage 50 | GetMountedVolumes() --> [paths...] # Returns an array of folder paths corresponding to mounted volumes displayed in Resolve’s Media Storage. 51 | GetSubFolders(folderPath) --> [paths...] # Returns an array of folder paths in the given absolute folder path. 52 | 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. 53 | RevealInStorage(path) --> None # Expands and displays a given file/folder path in Resolve’s Media Storage. 54 | 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. 55 | AddItemsToMediaPool([items...]) --> [clips...] # Adds specified file/folder paths from Media Store into current Media Pool folder. Input is an array of file/folder paths. 56 | MediaPool 57 | GetRootFolder() --> Folder # Returns the root Folder of Media Pool 58 | AddSubFolder(folder, name) --> Folder # Adds a new subfolder under specified Folder object with the given name. 59 | CreateEmptyTimeline(name) --> Timeline # Adds a new timeline with given name. 60 | AppendToTimeline(clip1, clip2...) --> Bool # Appends specified MediaPoolItem objects in the current timeline. Returns True if successful. 61 | AppendToTimeline([clips]) --> Bool # Appends specified MediaPoolItem objects in the current timeline. Returns True if successful. 62 | CreateTimelineFromClips(name, clip1, clip2, ...)--> Timeline # Creates a new timeline with specified name, and appends the specified MediaPoolItem objects. 63 | CreateTimelineFromClips(name, [clips]) --> Timeline # Creates a new timeline with specified name, and appends the specified MediaPoolItem objects. 64 | ImportTimelineFromFile(filePath) --> Timeline # Creates timeline based on parameters within given file. 65 | GetCurrentFolder() --> Folder # Returns currently selected Folder. 66 | SetCurrentFolder(Folder) --> Bool # Sets current folder by given Folder. 67 | CreateEmptyTimeline(timelineName) --> Timeline # Creates a new timeline with specified name is timelineName (text) is unique. 68 | Folder 69 | GetClips() --> [clips...] # Returns a list of clips (items) within the folder. 70 | GetName() --> string # Returns user-defined name of the folder. 71 | GetSubFolders() --> [folders...] # Returns a list of subfolders in the folder. 72 | MediaPoolItem 73 | GetMetadata(metadataType) --> [[types],[values]] # Returns a value of metadataType. If parameter is not specified returns all set metadata parameters. 74 | SetMetadata(metadataType, metadataValue) --> Bool # Sets metadata by given type and value. Returns True if successful. 75 | GetMediaId() --> string # Returns a unique ID name related to MediaPoolItem. 76 | AddMarker(frameId, color, name, note, duration) --> Bool # Creates a new marker at given frameId position and with given marker information. 77 | GetMarkers() --> [markers...] # Returns a list of all markers and their information. 78 | AddFlag(color) --> Bool # Adds a flag with given color (text). 79 | GetFlags() --> [colors...] # Returns a list of flag colors assigned to the item. 80 | GetClipColor() --> string # Returns an item color as a string. 81 | 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. 82 | SetClipProperty(propertyName, propertyValue) --> Bool # Sets into given propertyName (string) propertyValue (string). 83 | Timeline 84 | GetName() --> string # Returns user-defined name of the timeline. 85 | SetName(timelineName) --> Bool # Sets timeline name is timelineName (text) is unique. 86 | GetStartFrame() --> int # Returns frame number at the start of timeline. 87 | GetEndFrame() --> int # Returns frame number at the end of timeline. 88 | GetTrackCount(trackType) --> int # Returns a number of track based on specified track type ("audio", "video" or "subtitle"). 89 | 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). 90 | AddMarker(frameId, color, name, note, duration) --> Bool # Creates a new marker at given frameId position and with given marker information. 91 | GetMarkers() --> [markers...] # Returns a list of all markers and their information. 92 | 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". 93 | 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". 94 | GetCurrentTimecode() --> string # Returns a string representing a timecode for current position of the timeline. 95 | GetCurrentVideoItem() --> item # Returns current video timeline item. 96 | TimelineItem 97 | GetName() --> string # Returns a name of the item. 98 | GetDuration() --> int # Returns a duration of item. 99 | GetEnd() --> int # Returns a position of end frame. 100 | GetFusionCompCount() --> int # Returns the number of Fusion compositions associated with the timeline item. 101 | GetFusionCompByIndex(compIndex) --> fusionComp # Returns Fusion composition object based on given index. 1 <= compIndex <= timelineItem.GetFusionCompCount() 102 | GetFusionCompNames() --> [names...] # Returns a list of Fusion composition names associated with the timeline item. 103 | GetFusionCompByName(compName) --> fusionComp # Returns Fusion composition object based on given name. 104 | GetLeftOffset() --> int # Returns a maximum extension by frame for clip from left side. 105 | GetRightOffset() --> int # Returns a maximum extension by frame for clip from right side. 106 | GetStart() --> int # Returns a position of first frame. 107 | AddMarker(frameId, color, name, note, duration) --> Bool # Creates a new marker at given frameId position and with given marker information. 108 | GetMarkers() --> [markers...] # Returns a list of all markers and their information. 109 | GetFlags() --> [colors...] # Returns a list of flag colors assigned to the item. 110 | GetClipColor() --> string # Returns an item color as a string. 111 | AddFusionComp() --> fusionComp # Adds a new Fusion composition associated with the timeline item. 112 | ImportFusionComp(path) --> fusionComp # Imports Fusion composition from given file path by creating and adding a new composition for the item. 113 | ExportFusionComp(path, compIndex) --> Bool # Exports Fusion composition based on given index into provided file name path. 114 | DeleteFusionCompByName(compName) --> Bool # Deletes Fusion composition by provided name. 115 | LoadFusionCompByName(compName) --> fusionComp # Loads Fusion composition by provided name and sets it as active composition. 116 | RenameFusionCompByName(oldName, newName) --> Bool # Renames Fusion composition by provided name with new given name. 117 | AddVersion(versionName, versionType) --> Bool # Adds a new Version associated with the timeline item. versionType: 0 - local, 1 - remote. 118 | DeleteVersionByName(versionName, versionType) --> Bool # Deletes Version by provided name. versionType: 0 - local, 1 - remote. 119 | LoadVersionByName(versionName, versionType) --> Bool # Loads Version by provided name and sets it as active Version. versionType: 0 - local, 1 - remote. 120 | RenameVersionByName(oldName, newName, versionType)--> Bool # Renames Version by provided name with new given name. versionType: 0 - local, 1 - remote. 121 | GetMediaPoolItem() --> MediaPoolItem # Returns a corresponding to the timeline item media pool item if it exists. 122 | GetVersionNames(versionType) --> [strings...] # Returns a list of version names by provided versionType: 0 - local, 1 - remote. 123 | -------------------------------------------------------------------------------- /resolve_class_build.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | #Resolve Class Build 4 | import sys 5 | import DaVinciResolveScript 6 | import time 7 | 8 | class R(): 9 | 10 | resolve = DaVinciResolveScript.scriptapp('Resolve') 11 | fusion = DaVinciResolveScript.scriptapp('Fusion') 12 | pm = resolve.GetProjectManager() 13 | ms = resolve.GetMediaStorage() 14 | proj = pm.GetCurrentProject() 15 | mp = proj.GetMediaPool() 16 | timeln = proj.GetCurrentTimeline() 17 | folder = mp.GetRootFolder() 18 | cfolder = mp.GetCurrentFolder() 19 | clips = folder.GetClips() 20 | 21 | 22 | def __init__(self): 23 | pass 24 | 25 | def type_check(type_to_check): 26 | if type(type_to_check) == None: 27 | print("Error: Ensure Resolve is running while this script executes\nScript will close now") 28 | sys.exit() 29 | 30 | def SwitchPage(self, page_number ): 31 | """ 32 | provide number 1-6 to switch pages in Resolve 33 | switch_page(2) = Edit Page 34 | 1:"Media", 2:"Edit", 3:"Fusion", 4:"Color", 5:"Fairlight", 6:"Deliver" 35 | """ 36 | if type(page_number) != int: 37 | print('Error: Provide a number 1-6') 38 | return 39 | elif page_number > 6 or page_number < 1: 40 | print(f'Error: Page number {page_number} does not exist\nUse a number 1-6') 41 | return 42 | pages = {0:None, 1:"Media", 2:"Edit", 3:"Fusion", 4:"Color", 5:"Fairlight", 6:"Deliver"} 43 | self.resolve.OpenPage(pages[page_number]) 44 | print(f'Page switched to {pages[page_number]}') 45 | return 46 | 47 | 48 | def GetCurrentProject(self): 49 | print(self.proj.GetName()) 50 | return self.proj.GetCurrentTimeline() 51 | 52 | 53 | def SetProjectName(self, project_name): 54 | return self.pm.CreateProject(project_name) 55 | 56 | 57 | def GetRootFolder(self): 58 | return self.mp.GetRootFolder() 59 | 60 | 61 | def GetCurrentFolder(self): 62 | return self.mp.GetCurrentFolder() 63 | 64 | 65 | def SetCurrentFolder(self, folder): 66 | """returns Bool""" 67 | # self.folder = self.mp.GetRootFolder() 68 | # cfolder = self.mp.GetCurrentFolder() 69 | # if cfolder != folder: 70 | # return self.mp.SetCurrentFolder(cfolder) 71 | return self.mp.SetCurrentFolder(folder) 72 | 73 | 74 | def GetSubFolders(self): 75 | self.folder = self.mp.GetRootFolder() 76 | return self.folder.GetSubFolders() 77 | 78 | 79 | def GetFolderName(self): 80 | print(self.cfolder.GetName()) 81 | return self.cfolder.GetName() 82 | 83 | 84 | def AddNewFolder(self, folder_name): 85 | """ 86 | add_new_folder('folder_name') 87 | 88 | ### Adding Folders 89 | 'Master' > 'Test1' 90 | R.add_new_folder("Test1") ## Always Adding 1 folder to Root level under 'Master' 91 | 92 | """ 93 | print('Added {} folder to rootFolder'.format(folder_name)) 94 | return self.mp.AddSubFolder(self.folder, folder_name) 95 | 96 | 97 | def AddSubFolder(self, folder_name, parent_folder=None): 98 | """ 99 | Add a subfolder to a created parent folder 100 | add_sub_folder(String of folder name, Pass a parent Folder object(Optional)) 101 | 102 | add_sub_folder("Test2") ## Adding 1 folder to most recent created folder or 'Master' if no folders exist 103 | .. > 'Test2' or 'Master' > 'Test2' 104 | 105 | ### Adding Sub folder named 'test8' to parent folder 'test7' to parent folder 'Test2' 106 | 'Master' > 'Test2' > 'test7' > 'test8' 107 | R.add_sub_folder("test8", R.add_sub_folder("test7", R.add_new_folder("Test2"))) 108 | """ 109 | self.folder = self.mp.GetRootFolder() 110 | self.cfolder = self.mp.GetCurrentFolder() 111 | print(self.get_folder_name()) 112 | if parent_folder == None: 113 | return self.mp.AddSubFolder(self.cfolder, folder_name) 114 | self.RevealInStorage(parent_folder) 115 | setcurrentFolder = self.mp.SetCurrentFolder(parent_folder) 116 | if setcurrentFolder == 'None': 117 | print(setcurrentFolder) 118 | addFolder = self.mp.AddSubFolder(self.cfolder, parent_folder) 119 | return self.mp.AddSubFolder(addFolder, folder_name) 120 | else: 121 | print(setcurrentFolder) 122 | return self.mp.AddSubFolder(self.cfolder, folder_name) 123 | 124 | 125 | def GetMediaSubFolders(self, folderPath): 126 | return self.ms.GetSubFolders(folderPath) 127 | 128 | 129 | def RevealInStorage(self, path): 130 | return self.ms.RevealInStorage(path) 131 | 132 | 133 | def GetCurrentTimeline(self): 134 | print(self.timeln.GetName()) 135 | return self.proj.GetCurrentTimeline() 136 | 137 | 138 | def GetTimeline_name(self): 139 | print(self.timeln.GetName()) 140 | return self.timeln.GetName() 141 | 142 | 143 | def SelectTimeline(self, idx): 144 | print("There are {} timelines in this project.\nYou selected timeline number {}".format(int(self.proj.GetTimelineCount()),idx)) 145 | return self.proj.SetCurrentTimeline(self.proj.GetTimelineByIndex(idx)) 146 | 147 | # DR Included in script Functions 148 | def DisplayProjectsWithinFolder(self, pm, folderString = "- ", projectString = " " ): 149 | folderString = " " + folderString 150 | projectString = " " + projectString 151 | 152 | projects = sorted(self.pm.GetProjectsInCurrentFolder().values()) 153 | for projectName in projects: 154 | print(projectString + projectName) 155 | 156 | folders = sorted(self.pm.GetFoldersInCurrentFolder().values()) 157 | for folderName in folders: 158 | print(folderString + folderName) 159 | if self.pm.OpenFolder(folderName): 160 | self.DisplayProjectsWithinFolder(self.pm, folderString, projectString) 161 | pm.GotoParentFolder() 162 | return 163 | 164 | def DisplayProjectTree(self, resolve ): 165 | self.pm.GotoRootFolder() 166 | print("- Root folder") 167 | self.DisplayProjectsWithinFolder(self.pm) 168 | return 169 | 170 | def DisplayTimelineTrack(self, timeln, trackType, displayShift ): 171 | trackCount = self.timeln.GetTrackCount(trackType) 172 | for index in range (1, int(trackCount) + 1): 173 | print(displayShift + "- " + trackType + " " + str(index)) 174 | clips = timeln.GetItemsInTrack(trackType, index) 175 | for clipIndex in clips: 176 | print(displayShift + " " + clips[clipIndex].GetName()) 177 | return 178 | 179 | def DisplayTimelineInfo(self, timeline, displayShift ): 180 | print(displayShift + "- " + timeline.GetName()) 181 | displayShift = " " + displayShift 182 | self.DisplayTimelineTrack(timeline , "video", displayShift) 183 | self.DisplayTimelineTrack(timeline , "audio", displayShift) 184 | self.DisplayTimelineTrack(timeline , "subtitle", displayShift) 185 | return 186 | 187 | def DisplayTimelinesInfo(self, project ): 188 | print("- Timelines") 189 | timelineCount = self.proj.GetTimelineCount() 190 | 191 | for index in range (0, int(timelineCount)): 192 | self.DisplayTimelineInfo(self.project.GetTimelineByIndex(index + 1), " ") 193 | return 194 | 195 | def DisplayFolderInfo(self, folder, displayShift ): 196 | print(displayShift + "- " + folder.GetName()) 197 | clips = folder.GetClips() 198 | for clipIndex in clips: 199 | print(displayShift + " " + clips[clipIndex].self.GetClipProperty("File Name")["File Name"]) 200 | 201 | displayShift = " " + displayShift 202 | 203 | folders = folder.GetSubFolders() 204 | for folderIndex in folders: 205 | self.DisplayFolderInfo(folders[folderIndex], displayShift) 206 | return 207 | 208 | def DisplayMediaPoolInfo(self, proj ): 209 | self.mp # = proj.GetMediaPool() 210 | print("- Media pool") 211 | self.DisplayFolderInfo(self.folder, " ") 212 | return 213 | 214 | def DisplayProjectInfo(self, proj ): 215 | print("-----------") 216 | print("Project '" + self.proj.GetName() +"':") 217 | print(" Framerate " + self.proj.GetSetting("timelineFrameRate")) 218 | print(" Resolution " + self.proj.GetSetting("timelineResolutionWidth") + "x" + self.proj.GetSetting("timelineResolutionHeight")) 219 | 220 | self.DisplayTimelinesInfo(proj) 221 | print("") 222 | self.DisplayMediaPoolInfo(self.proj) 223 | return 224 | 225 | def AddTimelineToRender(self, proj, timeline, presetName, targetDirectory, renderFormat, renderCodec ): 226 | self.proj.SetCurrentTimeline(timeline) 227 | self.proj.LoadRenderPreset(presetName) 228 | 229 | if not self.proj.SetCurrentRenderFormatAndCodec(renderFormat, renderCodec): 230 | return False 231 | 232 | self.proj.SetRenderSettings({"SelectAllFrames" : 1, "TargetDir" : targetDirectory}) 233 | return self.proj.AddRenderJob() 234 | 235 | def RenderAllTimelines(self, resolve, presetName, targetDirectory, renderFormat, renderCodec ): 236 | self.pm 237 | self.proj = pm.GetCurrentProject() 238 | if not project: 239 | return False 240 | 241 | resolve.OpenPage("Deliver") 242 | timelineCount = self.proj.GetTimelineCount() 243 | 244 | for index in range (0, int(timelineCount)): 245 | if not self.AddTimelineToRender(self.proj, self.proj.GetTimelineByIndex(index + 1), presetName, targetDirectory, renderFormat, renderCodec): 246 | return False 247 | return self.proj.StartRendering() 248 | 249 | def IsRenderingInProgress(self, resolve ): 250 | self.pm 251 | self.proj = self.pm.GetCurrentProject() 252 | if not self.proj: 253 | return False 254 | 255 | return self.proj.IsRenderingInProgress() 256 | 257 | def WaitForRenderingCompletion(self, resolve ): 258 | while self.IsRenderingInProgress(self.resolve): 259 | time.sleep(1) 260 | 261 | return 262 | 263 | def DeleteAllRenderJobs(self, resolve ): 264 | pm = self.resolve.GetProjectManager() 265 | proj = self.pm.GetCurrentProject() 266 | proj.DeleteAllRenderJobs() 267 | return 268 | 269 | 270 | R = R() #instantiate the Class 271 | 272 | # R.WaitForRenderingCompletion(R.resolve) 273 | # R.DeleteAllRenderJobs(R.resolve) 274 | 275 | # R.DisplayProjectInfo(R.proj) 276 | # R.DisplayProjectTree(R.resolve) 277 | 278 | # R.SwitchPage(2) 279 | # R.SelectTimeline(1) 280 | 281 | 282 | print(R.GetCurrentFolder().GetName()) 283 | print(R.GetRootFolder().GetSubFolders()[1].GetName()) 284 | R.SetCurrentFolder(R.GetRootFolder()) 285 | 286 | 287 | 288 | 289 | # if R.get_sub_folders(): 290 | # print('True') 291 | # R.get_current_folder() 292 | # R.get_folder_name() 293 | # else: 294 | # print('False') 295 | # R.get_root_folder() 296 | # R.get_folder_name() 297 | 298 | # R.set_current_folder(R.get_root_folder()) 299 | # R.get_folder_name() 300 | 301 | 302 | # if R.GetRootFolder(): 303 | # print('True') 304 | # else: 305 | # print('False') 306 | 307 | # if R.SetProjectName('Two'): 308 | # print('True') 309 | # else: 310 | # print('False') 311 | 312 | 313 | 314 | 315 | # list1 = R.GetSubFolders() 316 | # print(list1) 317 | # print(list1.values()) 318 | # print(R.GetFolderName()) 319 | 320 | # R.GetCurrentTimeline() 321 | # R.GetCurrentProject() 322 | # R.GetTimelineName() 323 | 324 | # R.select_timeline(1) 325 | # R.proj.GetTimelineByIndex(1) 326 | 327 | 328 | # #Get Timeline Names and Objects ----- Not Working 329 | # timeline_count = int(R.proj.GetTimelineCount()) 330 | # timelinenames = [] 331 | # for i in range(timeline_count+1): 332 | # R.proj.SetCurrentTimeline(i) 333 | # R.GetTimelineName() 334 | # R.proj.GetTimelineByIndex(i) 335 | # print(R.proj.GetTimelineByIndex(i)) 336 | 337 | # R.GetFolderName() 338 | # R.GetRootFolder() 339 | 340 | ### Adding Folders 341 | # R.add_new_folder("Test1") ## Always Adding 1 folder to Root level under 'Master' 342 | ### 'Master' > 'Test1' 343 | 344 | 345 | 346 | if __name__ == '__main__': 347 | 348 | # Instantiate Resolve objects 349 | resolve = DaVinciResolveScript.scriptapp('Resolve') 350 | fusion = DaVinciResolveScript.scriptapp('Fusion') 351 | pm = resolve.GetProjectManager() 352 | ms = resolve.GetMediaStorage() 353 | proj = pm.GetCurrentProject() 354 | mp = proj.GetMediaPool() 355 | timeln = proj.GetCurrentTimeline() 356 | folder = mp.GetRootFolder() 357 | cfolder = mp.GetCurrentFolder() 358 | clips = folder.GetClips() 359 | 360 | --------------------------------------------------------------------------------