One of the most important aspects of video editing is the ability to add effects to clips, and Premiere Pro offers an extensive library of effects that can be applied to footage. Consequently there are many use cases where ExtendScript developers would want to add an effect to a clip. One might think that it should be pretty straightforward to achieve this task, right?
It might not be immediately obvious how to add effects to clips using ExtendScript, but it is still possible to add effects to clips / TrackItems by using the undocumented QE API. In the example provided, the Gaussian Blur effect is added to the currently selected clip, but the same method can be used to add other effects as well.
var BLUR_EFFECT_NAME = 'AE.ADBE Gaussian Blur 2'; var effect = qe.project.getVideoEffectByName(BLUR_EFFECT_NAME, true); var qeClip = qe.project.getActiveSequence().getVideoTrackAt(0).getItemAt(0); qeClip.addVideoEffect(effect);
In the screenshot below, you can see how the above code is executed in the ExtendScript Developer Tools.
The first step is to define the name of the effect that you want to add to the clip. In this example, we’re using the Gaussian Blur effect, which has the name “AE.ADBE Gaussian Blur 2”.
You can get a complete list of all Effects by calling qe.project.getVideoEffectList(). When using the ExtendScript Developer Tools, you can easily use the inspect functionality to learn more about the QE API. You can also refer to this article for more information: Understanding the Adobe Premiere Pro QE API.
Next, we’re using the qe.project.getVideoEffectByName() method, to retrieve the effect object based on its name.
Once we have the effect object, we can get the first clip in the timeline on video track 1 by using the qe.project.getActiveSequence().getVideoTrackAt(0).getItemAt(0) function. This returns the first item of the first video track in the active sequence, which is the currently selected clip.
ExtendScript Developer Tools
You can quickly test and debug ExtendScript code with the help of the ExtendScript Developer Tools. Before incorporating your code into your project, make sure it runs without any problems. You can quickly find and fix any coding errors by using tools like auto completion and object inspection, which can boost your workflow and productivity.
Finally, we can add the effect to the clip by calling the addVideoEffect() method on the clip object and passing in the effect object as a parameter.
It is important to note that while the QE API provides additional functionality, it is not officially supported by Adobe, and changes to the API may occur in future updates of Premiere Pro. Keep in mind that using undocumented APIs may have some risks.