Premiere Pro ExtendScript
Rules for ExtendScript in Premiere Pro (jsx/ppro/): no undo groups, times in ticks, 0-based track and clip collections, no QE DOM, and the version range.
Read host.md first: it explains AP.host.eval and how jsx/ is
loaded. This page is about code that runs in Premiere Pro. Put code that only
makes sense in Premiere Pro in jsx/ppro/.
No undo groups
Section titled “No undo groups”Premiere Pro’s ExtendScript has no beginUndoGroup. Every change a script
makes (a clip moved, a marker added, a property set) is its own step in
Edit → Undo. Keep scripted edits small, do the checks before the first change,
and tell the user how many undo steps an action adds. ap host eval
cannot group them either.
The active sequence
Section titled “The active sequence”app.project.activeSequence is null when no sequence is open. Check it:
function myTool_sequenceInfo() { var sequence = app.project.activeSequence; if (!sequence) return JSON.stringify({ ok: false, message: "Open a sequence first." }); var clips = 0; for (var i = 0; i < sequence.videoTracks.numTracks; i++) { clips += sequence.videoTracks[i].clips.numItems; } return JSON.stringify({ ok: true, name: sequence.name, videoClips: clips });}Collections
Section titled “Collections”Tracks, clips, sequences and project items are 0-based collections with a
count property: sequence.videoTracks[0] with numTracks,
track.clips[0] with numItems, app.project.sequences[0] with
numSequences, app.project.rootItem.children[0] with numItems. Use a
for loop; they are not arrays.
Times are ticks
Section titled “Times are ticks”Premiere measures time in ticks: 254016000000 ticks per second. A Time
object has .seconds (a number) and .ticks (a string). Create one with
new Time() and set either:
var t = new Time();t.seconds = 2.5;app.project.activeSequence.setPlayerPosition(t.ticks); // move the playhead to 2.5 svar startSeconds = clip.start.seconds; // read a clip's startFrame-accurate maths: convert with the sequence’s timebase
(sequence.timebase, ticks per frame, a string) instead of rounding seconds.
Things not to use
Section titled “Things not to use”- The QE DOM (
app.enableQE(),qe.*): undocumented, unsupported, and it changes between versions. Do not ship code that needs it. - Dialogs (
alert,confirm,File.openDialog) block Premiere Pro while open; the panel can show its own UI instead.
Projects
Section titled “Projects”app.projectis the active project. Premiere Pro can have several projects open (app.projects,numProjects).- Save with
app.project.save().ap host scratchcreates a new project in the temp folder and leaves the user’s project open.
Versions
Section titled “Versions”The extension’s range is hosts[].minVersion in afterpresets.json (default
14.0, Premiere Pro 2020). Check app.version before using newer APIs and
return { ok: false, message } when they are missing.
Type hints
Section titled “Type hints”ap check --types checks jsx/ against the Premiere Pro 24.0 declarations
from types-for-adobe (the newest set; newer APIs may be missing) and lists
likely mistakes. Hints can be wrong; confirm with ap host eval.