Adobe Premiere Sink
Adobe Premiere Pro scripting and stuff
· API · #note/sink · #code/js ·
Premiere file XML classes model
Internal ticks
1 Second = 254016000000 ticks
Versioning
<?xml version="1.0" encoding="UTF-8" ?>
<PremiereData Version="3">
<Project ObjectRef="1"/>
<Project ObjectID="1" ClassID="62ad66dd-0dcd-42da-a660-6d8fbde94876" Version="26" >
Version | ID |
---|---|
version 7 | 15 |
PP2 | 18 |
CS3 | 19 |
CS4 | 22 |
CS5 | 23 |
CS5.5 | 24 |
CS6 | 25 |
CS7 ...CC2013 | 26 |
CS8.1..CC2014.1 | 27 |
CS8.2..CC2014.2 | 28 |
CS9... CC2015.0 | 29 |
CS9.2..CC2015.1 & 2 | 30 |
CS10.. CC2015 3 & 4 | 31 |
CS11.. CC2017.0 | 32 |
CS11.1 CC2017.1.2 | 33 |
CS12.. CC2018 | 34 |
CS12.1 CC2018.1 | 35 |
14.0 CC2020 | 38 |
Scripting
Premiere sample code by Adobe
[[Premiere_samplecode.jsx]]
Focus to Timeline
cs = app.project.activeSequence;
hs = app.project.sequences[1]; // some hidden sequence?
//app.project.openSequence(cs.sequenceID);
app.project.activeSequence = hs;
app.project.openSequence(cs.sequenceID);
Resample Keys
//alert("premiere version " + app.version);
//var myClip=app.project.activeSequence.videoTracks[1].clips[0];
//var eff=myClip.components;
//alert("The clip "+ myClip.name + " has " + eff.numItems + " effects applied");
//var lst="";
//~ for (var i=0; i<app.project.rootItem.children.numItems; i++) {
//~ currItm = app.project.rootItem.children[i];
//~ lst += currItm.name + "\n "
//~ if (currItm.name == "Adjustment Layer") {
//~ //alert(currItm.getFootageInterpretation.toString());
//~ currItm.setOverridePixelAspectRatio(1,3);
//~ }
//~ }
//~ //alert(lst);
function kfdata() {
var curSeq=app.project.activeSequence, curClip=curSeq.videoTracks[1].clips[0], lst="";
for(var i=0; i<3; i++) { //curClip.components.numItems
var curComp = curClip.components[i];
lst+= "fx: " + curComp.displayName + " has animated props: ";
for (var pr=0; pr<curComp.properties.numItems; pr++) {
if (curComp.properties[pr].isTimeVarying()) {
lst += curComp.properties[pr].displayName + ":: ";
var keysArr = curComp.properties[pr].getKeys();
if (keysArr) {
lst += "kf#:" + keysArr.length + "::";
for(kf=0; kf<keysArr.length; kf++) {
lst += "kf: " + kf + "@" + keysArr[kf].seconds.toFixed(2) + "=" + curComp.properties[pr].getValueAtKey(keysArr[kf]).toFixed(2) + ", " ;
}
}
}
}
lst+= "\n";
}
alert("The clip: " + curClip.name + "\n" + lst);
}
function resampleKeys(prop, clip) {
var tm = new Time, pkf = prop.getKeys(), kfCount = 0;
if (pkf) {
$.writeln("Property " + prop.displayName + " has " + pkf.length + " keyframes and starts @" + pkf[0].seconds.toFixed(2) + " ends @" + pkf[pkf.length-1].seconds.toFixed(2));
$.write("keyframe list: ");
for (var i=clip.inPoint.seconds; i<=clip.outPoint.seconds; i+= frameTime) {
tm.seconds = i;
$.write("@" + i.toFixed(2) + "=")
if (prop.findNearestKey(tm, 0) != undefined) {
$.write(parseFloat(prop.getValueAtKey(tm)).toFixed(2));
} else {
prop.addKey(tm);
$.write("*"+parseFloat(prop.getValueAtKey(tm)).toFixed(2));
kfCount++;
}
}
$.writeln("");
$.writeln(kfCount + " new keyframes added\n");
}
}
//main
app.enableQE();
var curSeq=app.project.activeSequence, curClip=curSeq.videoTracks[1].clips[0], lst="", curSettings = curSeq.getSettings(), frameTime = curSettings.videoFrameRate.seconds;
$.writeln("");
$.writeln("=======================");
$.writeln("Current sequence \"" + curSeq.name + "\" frame time is " + frameTime);
$.writeln("Clip \"" + curClip.name + "\" start @" + curClip.start.seconds.toFixed(2) + " end @" + curClip.end.seconds.toFixed(2) + " in @" + curClip.inPoint.seconds.toFixed(2) + " out @" + curClip.outPoint.seconds.toFixed(2));
var si = qe.project.undoStackIndex();
qe.project.undoStack(si+1);
for(var ci=0; ci<curClip.components.numItems; ci++) {
var curComp = curClip.components[ci];
for (var pri=0; pri<curComp.properties.numItems; pri++) {
if (curComp.properties[pri].isTimeVarying()) {
resampleKeys(curComp.properties[pri], curClip , frameTime);
}
}
}
qe.project.undoStack(si+2);
=Seamless Transitions= Batch1.jsx
app.enableQE();
var curSeq = app.project.activeSequence;
var seqTrackGroups = [curSeq.videoTracks, curSeq.audioTracks];
var curClip = null;
$.writeln();
$.writeln("=== sequence: \"" + curSeq.name);
//clear the in out points
curSeq.setInPoint(-400000);
curSeq.setOutPoint(-400000);
//add the cut marker if needed
var markers = curSeq.markers;
$.writeln("found markers: " + markers.numMarkers);
if (markers.numMarkers == 0) {
var new_marker = markers.createMarker(curSeq.getPlayerPosition().seconds);
new_marker.name = "Cut";
new_marker.setTypeAsComment();
new_marker.setColorByIndex(1);
$.writeln("new marker at: " + new_marker.start.seconds);
} else {
markers[0].name = "Cut";
$.writeln("marker renamed to Cut");
}
// browse through all clips in the current sequence
for (var g=0; g<seqTrackGroups.length; g++) {
var seqTracks = seqTrackGroups[g];
for (var i=0; i<seqTracks.numTracks; i++) {
var curTrack = seqTracks[i];
$.writeln("track: " + curTrack.name + " clips: " + curTrack.clips.numItems);
curTrack.setMute(0);
for (k=0; k < curTrack.clips.numItems; k++) {
var curClip = curTrack.clips[k];
$.writeln(" clip " + k + ": " + curClip.name);
//check if it has Glitch FX applied
var rgbCmp = false;
for (var m=0; m<curClip.components.numItems; m++) {
if (curClip.components[m].displayName == "VR Digital Glitch") { rgbCmp = true; break } ;
}
if (rgbCmp) curClip.name="RGB" else curClip.name = curSeq.name;
//curClip.projectItem.setColorLabel(4);
curClip.setSelected(1,0);
}
}
}
qe.project.getActiveSequence().makeCurrent();
//project.activeSequence = curSeq;
//project.openSequence(curSeq.sequenceID);
=Seamless Transitions= Batch2 no marker.jsx
app.enableQE();
var curSeq = app.project.activeSequence;
var seqTrackGroups = [curSeq.videoTracks, curSeq.audioTracks];
var curClip = null;
$.writeln();
$.writeln("=== sequence: \"" + curSeq.name);
//clear the in out points
curSeq.setInPoint(-400000);
curSeq.setOutPoint(-400000);
// browse through all clips in the current sequence
for (var g=0; g<seqTrackGroups.length; g++) {
var seqTracks = seqTrackGroups[g];
for (var i=0; i<seqTracks.numTracks; i++) {
var curTrack = seqTracks[i];
$.writeln("track: " + curTrack.name + " clips: " + curTrack.clips.numItems);
curTrack.setMute(0);
for (k=0; k < curTrack.clips.numItems; k++) {
var curClip = curTrack.clips[k];
$.writeln(" clip " + k + ": " + curClip.name);
//check if it has Glitch FX applied
var rgbCmp = false;
for (var m=0; m<curClip.components.numItems; m++) {
if (curClip.components[m].displayName == "VR Digital Glitch") { rgbCmp = true; break } ;
}
if (rgbCmp) curClip.name="RGB" else curClip.name = curSeq.name;
//curClip.projectItem.setColorLabel(4);
curClip.setSelected(1,0);
}
}
}
qe.project.getActiveSequence().makeCurrent();
//project.activeSequence = curSeq;
//project.openSequence(curSeq.sequenceID);