Skip to main content
Participant
November 19, 2021
Question

CEP Premiere - Subsequence from selected clips

  • November 19, 2021
  • 3 replies
  • 953 views

Hi Everyone,

I'm wondering about if how I'd go about creating a sequence with some clips from the active sequence with ExtendScript.

The #track-insertclip function won't really work since it's looking for a project item, so my cuts would be lost. 

I noticed that I can call #trackitem-setselected  on clips but calling #sequence-createsubsequence does not create a subsequence from only the selected clips like it does in the UI.

The last thing I tried was calling #trackitem-remove on the clips I don't want in the sequence clone. But this one is too slow if my project is larger than a basic case.

 

Is there a way to do this directly? Or alternatively, can I mass delete all selected clips in anyway?

I'd appreciate any pointers and thoughts.

Thanks!

3 replies

Participating Frequently
April 21, 2022

Hi jerryr64396987,

 

I am not aware of a simple function suited for your usecase. As cloning the sequence and removing unused clips this is too slow for your needs, what you could do is create a new sequence using the project items and then restoring the properties such as effects, transitions, rotation, start / end etc.

 

Below you can see a small proof of concept that is very similar to the "nests" functionality in Premiere Pro. It creates a new sequence and moves the selection to this sequence. The cuts (start / end) are then restored in the nested sequence.

sequence = app.project.activeSequence;
var selection = sequence.getSelection();
var projectItems = [];
for (var i = 0; i < selection.length; i++) {
    projectItems.push(selection[i].projectItem)
}
var newSequence = app.project.createNewSequenceFromClips("New Sequence", projectItems);
var firstItemStartTicks = selection[0].start.ticks;
for (var i = 0; i < selection.length; i++) {
    var start = new Time();
    var end = new Time();
    start.ticks = (selection[i].start.ticks - firstItemStartTicks).toString();
    end.ticks = (selection[i].end.ticks - firstItemStartTicks).toString();
    newSequence.videoTracks[0].clips[i].start = start;
    newSequence.videoTracks[0].clips[i].end =  end;
    newSequence.audioTracks[0].clips[i].start = start;
    newSequence.audioTracks[0].clips[i].end = end;
}
sequence.overwriteClip(newSequence.projectItem, firstItemStartTicks, 0, 0);

Below you can see a screenshot where the above script is executed in the Dev Tools extension. After executing the script, a "nested" sequence is created. However, effects are lost in this very basic implementation. But copying those should also be possible. Depending on your needs this might be an alternative to the approach where you are removing unused clips from a copy of the active sequence.

Hopefully this helps!

Participant
October 19, 2025
  

Hi, thank you for your kind sharing.

 

I'm following your instructions and want to increase or decrease the duration of a clip on the timeline. I'm curious: I can modify the start value, but when I modify the end value, I get an unknown error exception.

 

I'm wondering if there's any difference between setting the start and end values, or if there's anything I should be aware of when setting the end value? Has this interface been updated?

 

Thank you.

 

 

 

 my code:

try {
	// Add 1 second to the beginning (extend in point)
	var oneSecond = new Time();
	oneSecond.seconds = 1;
	
	// Store original values
	var originalStart = clip.start.ticks;
	var originalEnd = clip.end.ticks;
	
	// Calculate new times
	var newStart = new Time();
	newStart.ticks = (originalStart - oneSecond.ticks).toString();
	
	var newEnd = new Time();
	newEnd.ticks = (originalEnd + oneSecond.ticks).toString();
	
	// Only test backward operations (outPoint and end)
	try {
		// For outPoint, we need to go forward 1 second in the source
		var newOutPoint = new Time();
		newOutPoint.ticks = (clip.outPoint.ticks + oneSecond.ticks).toString();
		clip.outPoint = newOutPoint;
		$._PPP_.updateEventPanel("Video Clip: " + clip.name + " - Source outPoint updated successfully");
	} catch (outPointError) {
		$._PPP_.updateEventPanel("Video Clip: " + clip.name + " - Source outPoint update failed: " + outPointError.toString());
	}
	
	try {
		clip.end = newEnd;
		$._PPP_.updateEventPanel("Video Clip: " + clip.name + " - Clip end updated successfully");
	} catch (endError) {
		$._PPP_.updateEventPanel("Video Clip: " + clip.name + " - Clip end update failed: " + endError.toString());
	}
 
Inspiring
October 20, 2025

end/ outpoint seems cant be used

Participant
January 30, 2022
Unified_Email_-_Verification_code.pdf
Participating Frequently
December 4, 2021

مرحبا من