Skip to main content
H-FITS
Participant
August 1, 2025
Answered

Setting the in and out points of a clip using an extension, and other related questions.

  • August 1, 2025
  • 1 reply
  • 439 views

Hello,

I'm a beginner in developing extensions for Premiere Pro, and I have a few questions while writing .jsx scripts:

Is there a way to create an undo group in Premiere Pro extensions, similar to After Effects scripts?
For example, like this in AE:


app.beginUndoGroup("tttest"); app.endUndoGroup();
Is it possible to modify the text content created using the Text Tool (Essential Graphics) via the extension?

I tried to set the in and out points of a graphic clip in the sequence to a specific range — for example, from frame 24 to frame 48.
However, setting .clip.start doesn't seem to work correctly. Could you provide a working code example for how to reposition and trim a graphic clip in the timeline?

 

 

 

Here is a portion of the .jsx code related to my third question.

 

function but3onClick() {
var sequence = app.project.activeSequence;
if (!sequence) { app.setSDKEventMessage("没有活动序列", "warning"); return; }

var selectedClips = getSelectedClips(); // 获取选中的剪辑
if (!selectedClips) return;
if (selectedClips.length > 1) { app.setSDKEventMessage("请只选择单个剪辑", "warning"); return; }
var selectedClip = selectedClips[0].clip; // 获取选中的剪辑对象
var track = sequence.videoTracks[selectedClips[0].trackIndex]; // 获取选中剪辑所在的轨道
var ticksPerFrame = sequence.timebase; // 获取时间基准(每帧的ticks数)


for (var i = track.clips.length - 1; i >= 0; i--) { // 遍历轨道上的所有剪辑
var clip = track.clips[i];
if (clip.start.ticks == selectedClip.start.ticks && clip.end.ticks == selectedClip.end.ticks)
continue;

track.clips[i].remove(0, 0);
}

selectedClip.start = new Time();
selectedClip.start.ticks = 24 * ticksPerFrame;

}


//获取选中的剪辑
function getSelectedClips() {
var sequence = app.project.activeSequence;
if (!sequence) { return; }

var selectedClips = [];
for (var i = 0; i < sequence.videoTracks.length; i++) {
var track = sequence.videoTracks[i];
for (var j = 0; j < track.clips.length; j++) {
var clip = track.clips[j];
if (clip.isSelected())
selectedClips.push({
clip: clip,
trackIndex: i,
});

}
}

if (!selectedClips || selectedClips.length == 0) { // 如果没有选中剪辑
app.setSDKEventMessage("当前没有选中任何剪辑", "warning"); return;
}

var baseTrackIndex = selectedClips[0].trackIndex; // 获取第一个选中剪辑的轨道索引
for (var i = 1; i < selectedClips.length; i++)
if (selectedClips[i].trackIndex != baseTrackIndex) {
app.setSDKEventMessage("选中的剪辑不在同一轨道上", "warning");
return;
}

return selectedClips;
}

Correct answer Bruce Bullis

Here's some example code that removes 3 seconds from the end of a trackItem.

var seq = app.project.activeSequence;
if (seq) {
	var firstVidItem = seq.videoTracks[0].clips[0];
	if (firstVidItem){
		var oldEnd = firstVidItem.end;
		var newEnd = oldEnd;
		newEnd.seconds = newEnd.seconds - 3;
		firstVidItem.end = newEnd;
	}
}

1 reply

Bruce Bullis
Community Manager
Community Manager
August 1, 2025

Is there a way to create an undo group in Premiere Pro extensions, similar to After Effects scripts?

Not in ExtendScript; UXP plugins (supported in PPro beta builds) do support undo groups.

>Is it possible to modify the text content created using the Text Tool (Essential Graphics) via the extension?

No; the ExtendScript APIs work on the editable parameters exposed by .mogrts created in After Effects.

 

Here's PProPanel moving trackItems.

H-FITS
H-FITSAuthor
Participant
August 1, 2025

Thank you very much.
By the way, besides using .move(), is there a way to set the duration or end time of a graphic clip?

Bruce Bullis
Community Manager
Bruce BullisCommunity ManagerCorrect answer
Community Manager
August 1, 2025

Here's some example code that removes 3 seconds from the end of a trackItem.

var seq = app.project.activeSequence;
if (seq) {
	var firstVidItem = seq.videoTracks[0].clips[0];
	if (firstVidItem){
		var oldEnd = firstVidItem.end;
		var newEnd = oldEnd;
		newEnd.seconds = newEnd.seconds - 3;
		firstVidItem.end = newEnd;
	}
}