• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Applying a scale change through scripting

New Here ,
Mar 28, 2018 Mar 28, 2018

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);

}

}

}

}

}

}

}

}

TOPICS
SDK

Views

1.2K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jul 02, 2019 Jul 02, 2019

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
...

Votes

Translate

Translate
LEGEND ,
Mar 28, 2018 Mar 28, 2018

Copy link to clipboard

Copied

This might be better asked in the SDK forum.  You're more likely to find programming folks there.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 28, 2018 Mar 28, 2018

Copy link to clipboard

Copied

Is it possible to get it moved or should I just repost?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 02, 2019 Jul 02, 2019

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 23, 2022 Mar 23, 2022

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines