qmasingarbe / pymiere

Python for Premiere pro
GNU General Public License v3.0
353 stars 46 forks source link

Adding Transitions using Pymiere - example included #77

Open seanmcnally98 opened 5 months ago

seanmcnally98 commented 5 months ago

Hey there, this isn't an issue, but a request to add this example to the documentation. It took me a long time to figure out how to add transitions between clips using pymiere, but I finally figured it out. This code will add a 25 frame cross dissolve at the third clip on V1. You can edit the duration, which transtion is used (by name) and which clip on which track will be targeted.

This is working code!

import pymiere

qe_project = pymiere.objects.qe.project

track = qe_project.getActiveSequence().getVideoTrackAt(0) # Example: target V1 (since indexing starts at 0)

# Specify the target clip index (0-based)
target_clip_index = 2  # Example: target the third clip (since indexing starts at 0)

clip = track.getItemAt(target_clip_index)
clip.addTransition(qe_project.getVideoTransitionByName("Cross Dissolve"), False, '00;00;00;25')

print(f"Transition added to clip at index {target_clip_index}")
print("Done")

Disclaimer, in my addTransition function, I have no idea what the "False" boolean does. In fact, the source I got this from has no idea what it does either. But, it works!

APISeeker commented 5 months ago

Hel @seanmcnally98 Its so weird that these codes are no longer existing anywher (only onthose youtube videos) and that youhad to watch the whole video to find that code..