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

488

Likes

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

Likes

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?

Likes

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
Adobe Community Professional ,
Jul 02, 2019 Jul 02, 2019

Copy link to clipboard

Copied

LATEST

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

Likes

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