Highlighted

ExtendScript: No longer able to add effects using QE DOM

Explorer ,
Aug 11, 2020

Copy link to clipboard

Copied

I'm trying to add an effect to a Clip in my Sequence using this code in my CEP panel using addVideoEffect, as in this thread. However, when I run this code to get the Clip:

qeClip = qe.project.getActiveSequence().getVideoTrackAt(0).getItemAt(0);

it gives me an error that says "Object is invalid."

 

This call is working fine in Premiere v 13.1.5, but not in Premiere 14.3 or 14.3.1. The problem seems to be with the call .getItemAt(0). If I omit that and just return the first video track, I'm able to get the track's numItems and other properties... but when I try accessing any of the qeClip's properties, like qeClip.start.frames, or any of its methods, I get the "Object is invalid" error even though that works in an older version of Premiere on my machine. This is preventing me from making a call to the addVideoEffect method, which from my understanding is the only way to add an effect to a clip using ExtendScript.

 

I understand that the QE DOM is officially unsupported, but is there a workaround for this? Is there another way for me to return a desired clip from my Sequence using the QE DOM, so that I can add an effect to it? If not, is there any other way to add an effect to a clip?

Thanks.

This works fine, here. Perhaps there isn't a clip on track 0, in your project? 

app.enableQE();

var qeTrack = qe.project.getActiveSequence().getVideoTrackAt(0);
if (qeTrack){
    var qeClip = qeTrack.getItemAt(0);
    if (qeClip){
        var effectToAdd = qe.project.getVideoEffectByName("Crop");
        if (effectToAdd){
            qeClip.addVideoEffect(effectToAdd);
        }
    }
}

For diagnostic purposes as well as general paranoia, I'm mistrustful of using return values without checking them first. 🙂

TOPICS
Error or problem, SDK

Views

81

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

ExtendScript: No longer able to add effects using QE DOM

Explorer ,
Aug 11, 2020

Copy link to clipboard

Copied

I'm trying to add an effect to a Clip in my Sequence using this code in my CEP panel using addVideoEffect, as in this thread. However, when I run this code to get the Clip:

qeClip = qe.project.getActiveSequence().getVideoTrackAt(0).getItemAt(0);

it gives me an error that says "Object is invalid."

 

This call is working fine in Premiere v 13.1.5, but not in Premiere 14.3 or 14.3.1. The problem seems to be with the call .getItemAt(0). If I omit that and just return the first video track, I'm able to get the track's numItems and other properties... but when I try accessing any of the qeClip's properties, like qeClip.start.frames, or any of its methods, I get the "Object is invalid" error even though that works in an older version of Premiere on my machine. This is preventing me from making a call to the addVideoEffect method, which from my understanding is the only way to add an effect to a clip using ExtendScript.

 

I understand that the QE DOM is officially unsupported, but is there a workaround for this? Is there another way for me to return a desired clip from my Sequence using the QE DOM, so that I can add an effect to it? If not, is there any other way to add an effect to a clip?

Thanks.

This works fine, here. Perhaps there isn't a clip on track 0, in your project? 

app.enableQE();

var qeTrack = qe.project.getActiveSequence().getVideoTrackAt(0);
if (qeTrack){
    var qeClip = qeTrack.getItemAt(0);
    if (qeClip){
        var effectToAdd = qe.project.getVideoEffectByName("Crop");
        if (effectToAdd){
            qeClip.addVideoEffect(effectToAdd);
        }
    }
}

For diagnostic purposes as well as general paranoia, I'm mistrustful of using return values without checking them first. 🙂

TOPICS
Error or problem, SDK

Views

82

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
Aug 11, 2020 0
Adobe Employee ,
Aug 11, 2020

Copy link to clipboard

Copied

Can you provide a snippet of ExtendScript that worked in 13.x, but fails in 14.x? 

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
Reply
Loading...
Aug 11, 2020 0
Explorer ,
Aug 11, 2020

Copy link to clipboard

Copied

Sure. This properly adds the Crop effect to the first clip in the first video track in 13.x, but fails in 14.x. 

app.enableQE();
var qeTrack = qe.project.getActiveSequence().getVideoTrackAt(0);
var qeClip = qeTrack.getItemAt(0);
qeClip.addVideoEffect(qe.project.getVideoEffectByName("Crop"));

 

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
Reply
Loading...
Aug 11, 2020 0
Adobe Employee ,
Aug 11, 2020

Copy link to clipboard

Copied

This works fine, here. Perhaps there isn't a clip on track 0, in your project? 

app.enableQE();

var qeTrack = qe.project.getActiveSequence().getVideoTrackAt(0);
if (qeTrack){
    var qeClip = qeTrack.getItemAt(0);
    if (qeClip){
        var effectToAdd = qe.project.getVideoEffectByName("Crop");
        if (effectToAdd){
            qeClip.addVideoEffect(effectToAdd);
        }
    }
}

For diagnostic purposes as well as general paranoia, I'm mistrustful of using return values without checking them first. 🙂

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
Reply
Loading...
Aug 11, 2020 0
Explorer ,
Aug 11, 2020

Copy link to clipboard

Copied

Thanks for the code! I tested it out but it still didn't work for me, so I'm not sure what might be wrong. 

I also tried modifying the code to this: 

app.enableQE();
var qeTrack = qe.project.getActiveSequence().getVideoTrackAt(0);
alert(qeTrack.name + ", " + qeTrack.numItems)
if (qeTrack){
   var qeClip = qeTrack.getItemAt(0);
   if (qeClip){
      var effectToAdd = qe.project.getVideoEffectByName("Crop");
      if (effectToAdd){
         alert(('1'))
         qeClip.addVideoEffect(effectToAdd);
         alert(('2'))
      }
   }
}

When I run it, Premiere 14.x alerts me Video 1, 8, then alerts 1, then Object is invalid, and then terminates the script. In a similar Sequence in Premiere 13.x, it does the same thing except it also alerts 2 at the end, and successfully applies the Crop effect to the first clip in the Sequence. I definitely have clips (I tried with ProRes MOVs, H264 MP4s, and nested Sequences) on all available tracks in both versions of Premiere while running the script. 

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
Reply
Loading...
Aug 11, 2020 0
Explorer ,
Aug 11, 2020

Copy link to clipboard

Copied

Actually, just realized I had New World Scripting off. Not sure when I might have turned it off. I switched it on in the console and restarted Premiere, and it seems to be working fine! Sorry for the back and forth, but I can confirm your code is working for me now. 

Thanks again!

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
Reply
Loading...
Aug 11, 2020 1
Explorer ,
Aug 11, 2020

Copy link to clipboard

Copied

I have one more question regarding this:

I want to add effectToAdd to a clip that isn't necessarily the first one in its track. If I already have the index, x, of the clip so that

app.project.activeSequence.videoTracks[0].clips[x] returns my desired clip, what's the best way to make sure qeClip is that same clip? I'm noticing that qeTrack.getItemAt(x) might not return the clip I want to add the effect to, because it can return an Item of type either Clip or Empty (where Empty is an empty space between clips). So if there are two clips in qeTrack with empty space between them, and I remove the empty space, qeTrack.numItems decreases by 1 and the argument I would pass to qeTrack.getItemAt() decreases by 1.

I can try iterating through each item in the qeTrack and skip over Items that are of type Empty, but I'm wondering if there's a simpler way I'm not aware of, such as an argument to qeTrack.getItemAt(x) that ignores empty spaces or a way of applying effects to all selected clips in a Sequence.

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
Reply
Loading...
Aug 11, 2020 0
Adobe Employee ,
Aug 11, 2020

Copy link to clipboard

Copied

There's no way to call getItemAt(x) that'll ignore empties; that's up to you. 🙂 

trackItems in the regular (non-QE) DOM have an isSelected() method.

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
Reply
Loading...
Aug 11, 2020 1