forked from qmasingarbe/pymiere
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.py
42 lines (35 loc) · 1.58 KB
/
demo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
"""
This demo show basic interactions with Premiere Pro using the Pymiere library.
It will display some info about the currently opened project in Premiere Pro and an action in the timeline.
Before running this script make sure that you have a Premiere project opened with at least a sequence.
"""
import time
import pymiere
from pymiere import wrappers
# Check for an open project
project_opened, sequence_active = wrappers.check_active_sequence(crash=False)
if not project_opened:
raise ValueError("please open a project")
project = pymiere.objects.app.project
# Open Sequences in Premiere Pro if none are active
if not sequence_active:
sequences = wrappers.list_sequences()
for seq in sequences:
project.openSequence(sequenceID=seq.sequenceID)
# Set the first Sequence in the list as the active Sequence
project.activeSequence = sequences[0]
# List all videos clips in the active Sequence
clips = wrappers.list_video(project.activeSequence)
# Convert timebase in ticks per second to Frame Per Second (FPS)
fps = 1/(float(project.activeSequence.timebase)/wrappers.TICKS_PER_SECONDS)
print("Sequence as a framerate of {} fps".format(fps))
# Select the first video clip in the Timeline
clips[0].setSelected(True, True)
# The following code will not work in Premiere Pro 2017 (clips were not editable at the time)
# Periodically advance the first video clip through the Timeline
start_frame = 0
end_frame = 100
for i in range(30):
increment = i * 5
wrappers.edit_clip(clips[0], start_frame + increment, end_frame + increment, start_frame, end_frame, fps=fps)
time.sleep(0.1)