Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pymiere
- import time
- from pathlib import Path
- def get_track_selection(sequence):
- track_count = sequence.videoTracks.numTracks
- print(f"\nAvailable Video Tracks: {track_count}")
- for i in range(track_count):
- track = sequence.videoTracks[i]
- clip_count = len(track.clips)
- print(f"Track {i+1}: {clip_count} clips")
- while True:
- track_num = input("\nWhich track would you like to process? (Enter 1-{}): ".format(track_count))
- if track_num.isdigit() and 1 <= int(track_num) <= track_count:
- return int(track_num) - 1
- def confirm_clips(track):
- clip_count = len(track.clips)
- print(f"\nFound {clip_count} clips to process:")
- for i, clip in enumerate(track.clips):
- print(f" {i+1}. {clip.name}")
- while True:
- ready = input("\nReady to process? (y/n): ").lower()
- if ready == 'y':
- return True
- elif ready == 'n':
- return False
- def batch_encode():
- sequence = pymiere.objects.app.project.activeSequence
- selected_track_index = get_track_selection(sequence)
- video_track = sequence.videoTracks[selected_track_index]
- if not confirm_clips(video_track):
- print("Operation cancelled")
- return
- preset_path = r"Path\To\Export\Settings\Preset.epr"
- export_base = r"Path\To\Export\Folder"
- print(f"\nProcessing clips from Track {selected_track_index + 1}")
- # Audio frame tick offset (5292000 ticks)
- AUDIO_FRAME_OFFSET = 5292000
- TICKS_PER_SECOND = 254016000000
- for clip in video_track.clips:
- export_path = Path(export_base) / f"{clip.name}"
- print(f"Queuing: {clip.name}")
- # Add audio frame offset to ensure correct frame boundaries
- start_ticks = clip.start.ticks + AUDIO_FRAME_OFFSET
- end_ticks = clip.end.ticks + AUDIO_FRAME_OFFSET
- # Convert ticks to seconds
- start_seconds = start_ticks / TICKS_PER_SECOND
- end_seconds = end_ticks / TICKS_PER_SECOND
- sequence.setInPoint(start_seconds)
- sequence.setOutPoint(end_seconds)
- time.sleep(0.1)
- pymiere.objects.app.encoder.encodeSequence(
- sequence,
- str(export_path),
- preset_path,
- 1,
- 0
- )
- print("\nStarting batch export...")
- pymiere.objects.app.encoder.startBatch()
- if __name__ == "__main__":
- batch_encode()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement