programming
General
- A bit weird TBH especially the console.
- There is no File>Run Script Command.
- You need to copy and paste it to a directory and it becomes available under
Workspace > Scripts
- There seems to be a difference between running a script inside and outside resolve.
- Normally, scripts run inside the host software but for some reason, almost all tutorials, run the script outside the software.
- You can get the default library used in resolve by default through
- A decent API documentation. It's unofficial but its better than the official documentation 5. https://deric.github.io/DaVinciResolve-API-Docs/
- https://github.com/jjsawdon/DaVinci-Resolve-Utilities
- a bit of misnomer. under fusion pero can be execute in regular resolve:
- C:\ProgramData\Blackmagic Design\DaVinci Resolve\Fusion\Scripts\Color
Boiler Plate
import os
import time
loaded = os.system("open /Applications/Davinci/Resolve/Davinci/Resolve.app)
time.sleep(5)
# to run code. python script.py
# to run with interactive console. python -i script.py
# app is already imported by default.
resolve = app.GetResolve()
project_manager = resolve.GetProjectManager()
current_project = project_manager.GetCurrentProject()
project_name = current_project.GetName()
project_timeline = current_project.GetTimeline()
selected_clip = project_timeline.GetCurrentVideoItem()
# Create New Project
new_project = project_manager.CreateProject("new_project")
# Import Files
media_pool = current_project.GetMediaPool()
media_pool.ImportMedia([r'path/to/files'])
# Seems like A Different Importing of Media
media_pool = current_project.GetMediaPool()
media_storage = resolve.GetMediaStorage()
mp = r'path/to/files'
clips = media_storage.AddItemListToMediaPool(mp)
new_timeline = media_pool.CreateEmptyTimeline('new_timeline')
timeline = project.GetCurrentTimeline() # Isn't this redundant?. Ah okay. Different. CurrentTimeline means it is opened.
# if not current timeline
if not timeline:
if project.GetTimelineCount() > 0:
timeline = project.GetTimelineByINdex(1)
project.SetCurrentTimeline(timeline)
# Add Track
timeline.AddTrack("video")
timeline.AddTrack("audio")
# Append Clips to Timeline
# This one is weird. Shouldn't it be timeline.Append? It's a bit roundabout
appended = mediaPool.AppendToTimeline(clips)
# Setting Timeline
project.SetSetting("timelineFrameRate", 30)
project.SetSetting("timelineResolutionWidth", 1080)
project.SetSetting("timelineResolutionHeight", 1920)
# Adding Fusion Title Elements
timeline.InsertFusionTitleIntoTimeline("Text+")
resolve.OpenPage("fusion") # why go to fusion when you can edit the properties within edit page itself ?
fusion = resolve.Fusion()
comp = fusion.GetCurrentComp()
template = comp.FindTool("Template")
template.SetInput("StyledText", "my custom text")
resolve.OpenPage("edit")
# Adding Title Elements
timeline.InsertTitleIntoTimeline("Text")
items = timeline.GetItemsInTrack("video", 1)
item = items[1] # haha assuming there are no other items
item.SetInput("RichText", "Does it work?")
Default Libraries
['OrderedDict',
'_UIAutoTbl',
'_UIDefault',
'_UIDispatcher',
'_UIWindow',
'__annotations__',
'__builtins__',
'__doc__',
'__loader__',
'__name__',
'__package__',
'__spec__',
'_thisapp',
'app',
'bmd',
'fu',
'fu_stderr',
'fu_stdout',
'fusion',
'importlib',
'pprint',
'res',
'resolve',
'sys']