
- Posts: 841
- Joined: Thu Sep 26, 2019 10:15 am
- Real Name: Christoph Schmid
Vojta Filipi wrote:The new problem I´m facing now is that I want to place the clip to my playhead (in the same way as pasting by ctrl+v) but the AppendToTimeline is placing the clip behind the latest clip on the timeline instead.
This little script appends clip at playhead position:
- Code: Select all
#!/usr/bin/env python
import DaVinciResolveScript
from timecode import Timecode
DR_FRAMERATES = {16: 16, 18: 18, 23: 23.976, 23.976: 23.976, 24: 24, 25: 25,
29: 29.97, 29.97: 29.97, 30: 30, 47: 47.952, 47.952: 47.952,
48: 48, 50: 50, 59: 59.94, 59.94: 59.94, 60: 60, 72: 72,
95: 95.904, 95.904: 95.904, 96: 96, 100: 100, 119: 119.88,
119.88: 119.88, 120: 120}
resolve = DaVinciResolveScript.scriptapp('Resolve')
project_manager = resolve.GetProjectManager()
project = project_manager.GetCurrentProject()
current_timeline = project.GetCurrentTimeline()
curr_timeline_fr = current_timeline.GetSetting('timelineFrameRate')
curr_timeline_fr = DR_FRAMERATES.get(float(curr_timeline_fr))
mediapool = project.GetMediaPool()
current_bin = mediapool.GetCurrentFolder()
clips = current_bin.GetClipList()
clipProperty = clips[0].GetClipProperty()
startFrame = int(clipProperty['Start'])
endFrame = int(clipProperty['End'])
tl_curr_tc = Timecode(curr_timeline_fr, current_timeline.GetCurrentTimecode())
recordFrame = int(tl_curr_tc.frame_number)
mediapool.AppendToTimeline([{'mediaPoolItem': clips[0],
'startFrame': startFrame,
'endFrame': endFrame,
'recordFrame': recordFrame}])
The "recordFrame" variable is the playhead position.
You might have to install the python timecode library with:
- Code: Select all
pip install timecode
Davinci Resolve Studio 20.0B3 Build 38
Windows 10 Pro 22H2
Davinci Resolve Studio 19.1.4 Build 11
Linux Ubuntu Studio 24.04 (Rocky 8.6 Container)