Skip to content

Instantly share code, notes, and snippets.

@SObS
Last active February 18, 2022 13:09
Show Gist options
  • Save SObS/298c254f596a3ebbc5f2a01eeb8314de to your computer and use it in GitHub Desktop.
Save SObS/298c254f596a3ebbc5f2a01eeb8314de to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Автор/Author: https://t.me/msergeyy
# Постоянная ссылка/Permanent link: https://gist.github.com/SObS/298c254f596a3ebbc5f2a01eeb8314de
# Что делает: проходится по текущему таймлайну, по очереди выделяет клипы и создает для каждого задачу на рендер
# The script checks currently opened timeline, individually selecting clips and creates individual render jobs with desired parameters,
# preserving retimes and other edits without having to create compounds
# Внимание! Для работы необходим Python версии 2, под 3-й можете исправить код сами... :)
# Good news everyone! The script only works with Python v2. If you are the lucky one who has Python 3 then...
# Probably you are capable to make it work there too.
# Параметры скрипта
# Main parameters
# Название существующего пресета в Deliver. Должен быть настроен как Single clip
# Name of the existing preset in Deliver tab. Must be based on Single clip mode.
preset = "H.264 Master"
# Путь к папке на вашем компьютере
# Path to desired export folder
location = "C:\Users\m-ser\Videos\_OUT"
# Номер дорожки видео, если вдруг нужные клипы лежат не на 1-й дорожке
# Video track number in case if clips allocated on a track different from 1
video_track = 1
first_clip = 1
# Чтобы отрендерить все клипы, в last_clip нужно указать -1, иначе - номер последнего клипа
# To render the entire timeline the parameter last_clip must be -1, otherwise - the number of the last clip you wish to mark out
last_clip = -1
# Чтобы скрипт добавлял номер клипа в начало имени файла, в enumerate_clips нужно указать - True, иначе - False
# Внимание! Если клипы на таймалайне порезаны из одного исходника, необходимо выставить параметр в True, иначе файлы будут перезаписаны
# To add clip numbers as prefix in filename, type True, othrwise - False.
# Attention! If you have different trims from the same source you must use the parameter True, to avoid overwriting.
enumerate_clips = False
# Дальше код...
# The code...
import sys
def GetResolve():
try:
import DaVinciResolveScript as bmd
except ImportError:
if sys.platform.startswith("darwin"):
expectedPath="/Library/Application Support/Blackmagic Design/DaVinci Resolve/Developer/Scripting/Modules/"
elif sys.platform.startswith("win") or sys.platform.startswith("cygwin"):
import os
expectedPath=os.getenv('PROGRAMDATA') + "\\Blackmagic Design\\DaVinci Resolve\\Support\\Developer\\Scripting\\Modules\\"
elif sys.platform.startswith("linux"):
expectedPath="/opt/resolve/libs/Fusion/Modules/"
try:
import imp
bmd = imp.load_source('DaVinciResolveScript', expectedPath + "DaVinciResolveScript.py")
except ImportError:
print("Unable to find module DaVinciResolveScript - please ensure that the module DaVinciResolveScript is discoverable by python")
print("For a default DaVinci Resolve installation, the module is expected to be located in: " + expectedPath)
sys.exit()
return bmd.scriptapp("Resolve")
resolve = GetResolve()
project = resolve.GetProjectManager().GetCurrentProject()
project.LoadRenderPreset(preset)
project.SetRenderSettings({
"TargetDir": location
})
timeline = project.GetCurrentTimeline()
items = timeline.GetItemListInTrack("video", video_track)
first_clip -= 1
if first_clip < 0:
first_clip = 0
if last_clip == -1 or last_clip > len(items):
last_clip = len(items)
for i in range(first_clip, last_clip):
item = items[i]
start_frame = item.GetStart()
end_frame = item.GetEnd() - 1
if enumerate_clips == True:
custom_name = str(i + 1) + "_" + item.GetName()
else:
custom_name = item.GetName()
print custom_name
project.SetRenderSettings({
"MarkIn": start_frame,
"MarkOut": end_frame,
"CustomName": custom_name
})
job = project.AddRenderJob()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment