[Premiere Pro SDK] add wiggle effect efficiently
Hello,
I've been trying to make a wiggle effect by scripting just like in AE (example: ([position[0],wiggle(44,22)[1]])) and I've came to this demo:
//gather project/clip/effects properties for this demo
var activeSequence = app.project.activeSequence;
var trackOne = activeSequence.videoTracks[0];//first track for testing
var clip = trackOne.clips[0];//first clip for testing + His time Properties
var start = clip.inPoint;
var end = clip.outPoint;
var duration = end.seconds-start.seconds;
var components = clip.components;
var transformComponent = components[2].properties[1];
//Represent how much the clip will Vertically move (increase value to move less)
var range = 80;
//Represent gap in seconds
var gap = 0.04;
//how many times it needs to repeat
var loopTimes = (duration/gap).toString();
//Allow the changes
if (!transformComponent.isTime) transformComponent.setTimeVarying(true);
for(var i = 1;i < loopTimes;i++){
var time = new Time();
time.seconds = gap *i ;
var diff = (Math.random())/80;
transformComponent.addKey(start.seconds+time.seconds);
transformComponent.setValueAtKey(start.seconds+time.seconds,[0.5,0.5+diff],1 );
}
It works fine but, as you can see it the screenshot, it is really demanding. for a 18second clip and the desired gap to make the desired look it can take around 30seconds or so (sadly I do not own a i9 & RTX3090). Just imagine for a 30min footage!
I tought about a solution in regard the ineficiency. It would be to make the effect for a 2second clip & repeat it multiple times to enhance the speed but I do not see how that could be possible since the projectItem.clone() does not seems in yet (DVAPR-4211779).
Any ideas of what alterate solution I could use?
thank you very much,
Maxime LP