pymiere
pymiere copied to clipboard
Is it possible to add a list of clips to a sequence?
Trying to get all the mp4 files in a directory added to my project, then added to the active sequence. I'm aware a loop could add them one by one, but I'm wondering if it's possible to use insertClip to add multiple at once, similar to dragging them onto the timeline. I'm a bit of a novice when it comes to coding, so perhaps my syntax is wrong. Here's my code:
import pymiere
import os
from pymiere.wrappers import time_from_seconds
project = pymiere.objects.app.project
directory = r'D:\Media_Folder'
media_path = [os.path.join(directory, filename) for filename in os.listdir(directory) if filename.endswith('.MP4')]
# import media into Premiere
success = project.importFiles(
media_path, # can import a list of media if there are no brackets around media_path
suppressUI=True,
targetBin=project.getInsertionBin(),
importAsNumberedStills=False
)
#find media we imported
items = project.rootItem.findItemsMatchingMediaPath(media_path, ignoreSubclips=False)
#add clip to active sequence
project.activeSequence.videoTracks[0].insertClip(items[0], time_from_seconds(0))