Skip to content

Instantly share code, notes, and snippets.

@ss44
Last active July 27, 2023 04:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ss44/7fe0a1d2497b996fb155a5859f5c3d16 to your computer and use it in GitHub Desktop.
Save ss44/7fe0a1d2497b996fb155a5859f5c3d16 to your computer and use it in GitHub Desktop.
WIP Lua Script for Davinci Resolve to convert Subtitles (SRT) tracks to Text+ media comps.
--[[
SRT to Text+
Author Shinda Singh <ss@ss44.ca>
This is a Davinci Resolve Script or at least an attempt at one
that reads text from a subtitle track and converts them to text+ comps so that
effects can be applied (think Mr Best Subtitles)
Unfortunately this is kind of stalled since it only creates the text+ with text
but fails to place them in the correct position just couldn't figure out how
with the limited documentation.
Shoutouts: https://note.com/hitsugi_yukana/n/n1601e81df8d7
A similar and more working script / plugin can be found:
https://www.youtube.com/watch?v=DKwNJm4hajo
But my main beef with this implemtnation is it requires an external app to launch Davinci
so this was an attempt to find a cleaner solution, which I did not.
]]
print ('loading ;)')
resolve = Resolve()
projectManager = resolve:GetProjectManager()
project = projectManager:GetCurrentProject()
timeline = project:GetCurrentTimeline()
if (timeline == nil) then
print ("No Active Timeline")
os.exit()
end
-- grab current subtitles
subtitles = timeline:GetItemListInTrack("subtitle", 1)
timeline:SetTrackLock("subtitle", 1, true)
-- goal is to eventually add the tracks to this timeline
-- but not sure how just yet!
timeline:AddTrack("video")
-- last track is the newly created track
total_tracks = timeline:GetTrackCount("video")
last_track_name = timeline:GetTrackName("video", total_tracks)
print("generated track is -- " .. last_track_name)
for key, value in pairs(subtitles) do
if key == "__flags" then
os.exit()
end
caption = value:GetName()
-- add a new text item to the video track
text_item = timeline:InsertFusionTitleIntoTimeline("Text+")
toolList = text_item:GetFusionCompByIndex(1):GetToolList()
toolList[1].StyledText = caption
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment