Get project information

鬼猫猫小于 1 分钟

Get project information

Python
#!/usr/bin/env python

"""
Example DaVinci Resolve script:
Display project information: timeline, clips within timelines and media pool structure.
Example usage: 5_get_project_information.py
"""

from python_get_resolve import GetResolve

def DisplayTimelineTrack( timeline, trackType, displayShift ):
    trackCount = timeline.GetTrackCount(trackType)
    for index in range (1, int(trackCount) + 1):
        print(displayShift + "- " + trackType + " " + str(index))
        clips = timeline.GetItemListInTrack(trackType, index)
        for clip in clips:
            print(displayShift + "    " + clip.GetName())
    return

def DisplayTimelineInfo( timeline, displayShift ):
    print(displayShift + "- " + timeline.GetName())
    displayShift = "  " + displayShift
    DisplayTimelineTrack(timeline , "video", displayShift)
    DisplayTimelineTrack(timeline , "audio", displayShift)
    DisplayTimelineTrack(timeline , "subtitle", displayShift)
    return

def DisplayTimelinesInfo( project ):
    print("- Timelines")
    timelineCount = project.GetTimelineCount()

    for index in range (0, int(timelineCount)):
        DisplayTimelineInfo(project.GetTimelineByIndex(index + 1), "  ")
    return

def DisplayFolderInfo( folder, displayShift ):
    print(displayShift + "- " + folder.GetName())
    clips = folder.GetClipList()
    for clip in clips:
        print(displayShift + "  " + clip.GetClipProperty("File Name"))

    displayShift = "  " + displayShift

    folders = folder.GetSubFolderList()
    for folder in folders:
        DisplayFolderInfo(folder, displayShift)
    return

def DisplayMediaPoolInfo( project ):
    mediaPool = project.GetMediaPool()
    print("- Media pool")
    DisplayFolderInfo(mediaPool.GetRootFolder(), "  ")
    return

def DisplayProjectInfo( project ):
    print("-----------")
    print("Project '" + project.GetName() +"':")
    print("  Framerate " + str(project.GetSetting("timelineFrameRate")))
    print("  Resolution " + project.GetSetting("timelineResolutionWidth") + "x" + project.GetSetting("timelineResolutionHeight"))

    DisplayTimelinesInfo(project)
    print("")
    DisplayMediaPoolInfo(project)
    return

# Get currently open project
resolve = GetResolve()
projectManager = resolve.GetProjectManager()
project = projectManager.GetCurrentProject()

DisplayProjectInfo(project)
Lua
--[[
Example DaVinci Resolve script:
Display project information: timeline, clips within timelines and media pool structure.
--]]

local function DisplayTimelineTrack( timeline, trackType, displayShift )
	local trackCount = timeline:GetTrackCount(trackType)
	for index = 1, trackCount, 1 do
		print(displayShift.."- "..trackType.." "..index)
		clips = timeline:GetItemsInTrack(trackType, index)
		for clipIndex in pairs(clips) do
			print(displayShift.."    "..clips[clipIndex]:GetName())
		end
	end
end

local function DisplayTimelineInfo( timeline, displayShift )
	print(displayShift.."- "..timeline:GetName())
	displayShift = "  "..displayShift
	DisplayTimelineTrack(timeline , "video", displayShift)
	DisplayTimelineTrack(timeline , "audio", displayShift)
	DisplayTimelineTrack(timeline , "subtitle", displayShift)
	return
end

local function DisplayTimelinesInfo( project )
	print("- Timelines")
	local timelineCount = project:GetTimelineCount()
	
	for index = 1, timelineCount, 1 do
		DisplayTimelineInfo(project:GetTimelineByIndex(index), "  ")
	end
end

local function DisplayFolderInfo( folder, displayShift )
	print(displayShift.."- "..folder:GetName())
	local clips = folder:GetClips()
	for clipIndex in pairs(clips) do
		print(displayShift.."  "..clips[clipIndex]:GetClipProperty("File Name"))
	end
	
	displayShift = "  "..displayShift
	
	local folders = folder:GetSubFolders()
	for folderIndex in pairs(folders) do
		DisplayFolderInfo(folders[folderIndex], displayShift)
	end
end

local function DisplayMediaPoolInfo( project )
	mediaPool = project:GetMediaPool()
	print("- Media pool")
	DisplayFolderInfo(mediaPool:GetRootFolder(), "  ")
end

local function DisplayProjectInfo( project )
	print("-----------")
	print("Project '"..project:GetName().."':")
	print("  Framerate " .. project:GetSetting("timelineFrameRate"))
	print("  Resolution " .. project:GetSetting("timelineResolutionWidth") .. "x" .. project:GetSetting("timelineResolutionHeight"))
	
	DisplayTimelinesInfo(project)
	print("")
	DisplayMediaPoolInfo(project)
end


resolve = Resolve()
projectManager = resolve:GetProjectManager()
project = projectManager:GetCurrentProject()

DisplayProjectInfo(project)
上次编辑于:
贡献者: Yanru Mu,muyanru