Copy link to clipboard
Copied
Hi,
I'm trying to get to grips with JavaScripting on Premiere Pro CC 12 and my first task is to apply a scale change to a series of videos which runs for the first second scaling from 100 to 200 and then for another second scaling from 200 to 300. It seems as though everything is being correctly set when debugging the script but in the project window the keys I've made are not showing up and the final scaling is applied from time 0 so the end effect is that it's full size from the outset.
what am I missing?
TIA
Richard
var proj = app.project;
var seq = proj.activeSequence;
var time = seq.getPlayerPosition(); // CTI = Current Time Indicator.
var time2 = seq.getPlayerPosition();
var time3 = seq.getPlayerPosition();
time2.seconds += 1;
time3.seconds += 2;
var videoTracks = seq.videoTracks;
for (var i = 0; i < videoTracks.numTracks; i++) {
var track = videoTracks;
for (var j = 0; j < track.clips.numItems; j++) {
var clip = track.clips
if (clip.name == "Rectangle 720 576.png") {
for (var k = 0; k < clip.components.numItems; k++) {
var component = clip.components
if (component.displayName == "Trajectoire") { // Trajectory
for (var l = 0; l < component.properties.numItems; l++) {
var property = component.properties
if (property.displayName == "Echelle") { // Scale
if (!property.isTimeVarying()) {
property.setTimeVarying(true);
}
property.addKey(time);
property.addKey(time2);
property.addKey(time3);
var k = property.getKeys();
if (property.areKeyframesSupported() == true) {
var result = property.getValueAtKey(time);
property.setValueAtKey(time, 100, true);
property.setValueAtKey(time2, 200, true);
property.setValueAtKey(time3, 300, true);
}
}
}
}
}
}
}
}
Working fine for me when changing to Motion > Scale. Is that the same effect, just in a different app language? What is the timecode of your project?
var proj = app.project;
var seq = proj.activeSequence;
var time = seq.getPlayerPosition(); // CTI = Current Time Indicator.
var time2 = seq.getPlayerPosition();
var time3 = seq.getPlayerPosition();
time2.seconds += 1;
time3.seconds += 2;
var videoTracks = seq.videoTracks;
for (var i = 0; i < videoTracks.numTracks; i++) {
var track = videoTra
...
Copy link to clipboard
Copied
This might be better asked in the SDK forum. You're more likely to find programming folks there.
Copy link to clipboard
Copied
Is it possible to get it moved or should I just repost?
Copy link to clipboard
Copied
Working fine for me when changing to Motion > Scale. Is that the same effect, just in a different app language? What is the timecode of your project?
var proj = app.project;
var seq = proj.activeSequence;
var time = seq.getPlayerPosition(); // CTI = Current Time Indicator.
var time2 = seq.getPlayerPosition();
var time3 = seq.getPlayerPosition();
time2.seconds += 1;
time3.seconds += 2;
var videoTracks = seq.videoTracks;
for (var i = 0; i < videoTracks.numTracks; i++) {
var track = videoTracks;
for (var j = 0; j < track.clips.numItems; j++) {
var clip = track.clips;
if (clip.name == "Rectangle 720 576.png") {
for (var k = 0; k < clip.components.numItems; k++) {
var component = clip.components;
if (component.displayName == "Motion") {
// Trajectory
for (var l = 0; l < component.properties.numItems; l++) {
var property = component.properties;
if (property.displayName == "Scale") {
// Scale
if (!property.isTimeVarying()) {
property.setTimeVarying(true);
}
property.addKey(time);
property.addKey(time2);
property.addKey(time3);
var k = property.getKeys();
if (property.areKeyframesSupported() == true) {
var result = property.getValueAtKey(time);
property.setValueAtKey(time, 100, true);
property.setValueAtKey(time2, 200, true);
property.setValueAtKey(time3, 300, true);
}
}
}
}
}
}
}
}
You could remove a few loops if you are trying to change the Scale, since the Motion effect is on every video clip in Premiere and Scale is always at the same index on all clips:
clip.components[1].properties[1]; // Scale
Copy link to clipboard
Copied
I mean... you use collections instead of collection elements. There's a reason why you have those 'for' loops.
...
var track = videoTracks; --> var track = videoTracks[i];
...
var clip = track.clips; --> var clip = track.clips[j];
...
var component = clip.components; --> var component = clip.components[k];
...
var property = component.properties; --> var property = component.properties[l];
...
etc