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

Add Audio Effect using script

Explorer ,
Aug 05, 2019 Aug 05, 2019

Hi all,

I am trying to batch edit some simple videos, 3 clips. the 2nd clip will need to have a little audio work that I can do once and put in the 2nd clip in the final videos.

I already have 99% of this working, but I cannot seem to be able to add an effect via script. 

I have a template project that everything runs from.  It contains the 1st and 3rd clips, and empty Sequence (to put all the clips together).  I have put in another sequence that will contain a sample clip with the audio fixed for the end project.  (see the image below for the sample template)Project Screenshot.PNG

I basically need to copy / paste the audio effects from the AudioTemplate sequence (only one clip in there), to the 2nd clip in the final sequence to be rendered.  I am able to get the new effect into a variable (copy), but I am not able to add it to the sequence (paste) that I want to render.

We are talking about doing 100 clips the first time, and many more on future projects.

Sure, I can go in and copy/paste, but that is a lot of time to do something that should be kind of easy.

Thanks in advance.

Brad

TOPICS
SDK
2.9K
Translate
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

Explorer , Aug 07, 2019 Aug 07, 2019

Ok, I have the answer!  Thanks to all who pointed me in the right direction. I added the "getSequence" function I created to make it easy to get the sequence that has the audio effects to copy. Here is the code I have:

app.enableQE();

copyAudioEffectsToActiveSeqClip(getSequence(<<NAME OF SEQUENCE WITH EFFECTS TO BE COPIED>>),0);

// clipIndex is the index number of the clip in the TARGET (ACTIVE) sequence you want the

// effects copied TO.

function copyAudioEffectsToActiveSeqClip(OriginalSequence, cl

...
Translate
Adobe Employee ,
Aug 05, 2019 Aug 05, 2019

There's no supported way to apply effects using PPro's ExtendScript API. I'll add your vote to the feature request.

Translate
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
Explorer ,
Aug 05, 2019 Aug 05, 2019

Thanks.  I was afraid of that.

Translate
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 Beginner ,
Aug 06, 2019 Aug 06, 2019

Do you know about the QE function to add video effects?

addAudioEffect(qe.project.getAudioEffectByName("Effect name"))

?

You could read the effect properties from your "template clip", apply the effect to all clip using the function mentioned, and then set the properties accordingly. I don't have a working code sample, but should be possible.

Translate
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
Explorer ,
Aug 06, 2019 Aug 06, 2019

Yes, I was informed of it, and I have been playing around with it for the last hour (ish).  I can only get it to add the effects without any values.  The "getAudioEffectByName" only brings the effect without any values being set.  How do I set an active sequence to my audio template before I grab the values?  I haven't been able to do this.  If I can get that to work, I would be golden!

Thanks

Translate
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 Employee ,
Aug 06, 2019 Aug 06, 2019
How do I set an active sequence to my audio template before I grab the values?

I don't understand what "set an active sequence to my audio template" means...?

What's your audio template?

Translate
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
Explorer ,
Aug 06, 2019 Aug 06, 2019

My audio template is just a sequence that has the audio effects set the way I want to put on one clip in all of the new sequences.

Translate
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 Beginner ,
Aug 06, 2019 Aug 06, 2019

By the way, what don't you use the "Paste attributes" function in PP? You could select the template clip, then "Copy" then select all your target clips and "Paste attributes" (selecting the needed effects in the UI).

Translate
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
Explorer ,
Aug 06, 2019 Aug 06, 2019

Is that something that can be scripted?  I have to do this for hundreds of videos.

Translate
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 Employee ,
Aug 06, 2019 Aug 06, 2019

Is that something that can be scripted?

Yes, panels can create sequences based on .sqpreset templates:

https://github.com/Adobe-CEP/Samples/blob/dfb5dfa6e122848b61f51cee5a827815a42af5f5/PProPanel/jsx/PPR...

Translate
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
Explorer ,
Aug 06, 2019 Aug 06, 2019

I will check into that one!  Thanks

Translate
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
Explorer ,
Aug 06, 2019 Aug 06, 2019

That looks like it is creating a new sequence, I had issues with that code before.  I can't remember what, but it wouldn't do what I needed.  I don't need to create a new sequence, I just need to copy the audio effects from one sequence to an individual clip in another sequence (not the entire sequence).

Translate
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 Employee ,
Aug 06, 2019 Aug 06, 2019
That looks like it is creating a new sequence, I had issues with that code before.  I can't remember what, but it wouldn't do what I needed.

I'm not sure what you needed, but it's used by many panel devs to create sequences with specific settings.

I just need to copy the audio effects from one sequence to an individual clip in another sequence (not the entire sequence).

I'm confused; "copy the audio effects from one sequence" suggests that the source is a sequence, and the destination is a clip in other sequence. Is that correct?

Translate
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
Explorer ,
Aug 06, 2019 Aug 06, 2019

I have an empty sequence that I put the clips into, using that create sequence had issues, it was just easier to create an empty one and use it.  I am not creating a script for a panel.  I am creating one to run through multiple videos, put an intro and end screen on them, and add some audio fixing to the original clip (not the intro or end screen clips.  I have all of that complete, except for being able to put the audio effects onto the clip in the final sequence to render.  I literally need to copy the effects from a clip in one sequence to a clip in another sequence.  I want to do this 100% without any interaction, no button clicks, all completely automatic.

If I can get it to work to automatically copy and paste the audio effects, then that would be perfect.  At this point, I am able to do everything but that.  That means I will have to manually copy and paste to 100 clips in 100 sequences.  Not too HORRIBLE, but it would be a TON faster if the script could do it.  I already have the clips adding to the sequence, I already have a script to render all of the sequences.  So, I really only need to copy and paste the effects from one clip in one sequence into another clip into another sequence.

Translate
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 Employee ,
Aug 06, 2019 Aug 06, 2019
...using that create sequence had issues, it was just easier to create an empty one and use it

Glad you got it working, and I'd like to get specifics about any issues.

I am not creating a script for a panel.  I am creating one to run through multiple videos, put an intro and end screen on them, and add some audio fixing to the original clip (not the intro or end screen clips.


Understood. Panels are the intended platform, from which to execute automated sequence assembly workflows, like the one you describe.

I literally need to copy the effects from a clip in one sequence to a clip in another sequence.

That makes a lot more sense, thank you.

Translate
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
Explorer ,
Aug 07, 2019 Aug 07, 2019

So, with a little guidance in the right area, I have made some code that works.  I will post a nice clean version of the code once I have it done.  But, this IS doable, but you HAVE to use the QEDom to make it happen.


Thanks all!  Code post coming later today

Translate
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
Explorer ,
Aug 07, 2019 Aug 07, 2019
LATEST

Ok, I have the answer!  Thanks to all who pointed me in the right direction. I added the "getSequence" function I created to make it easy to get the sequence that has the audio effects to copy. Here is the code I have:

app.enableQE();

copyAudioEffectsToActiveSeqClip(getSequence(<<NAME OF SEQUENCE WITH EFFECTS TO BE COPIED>>),0);

// clipIndex is the index number of the clip in the TARGET (ACTIVE) sequence you want the

// effects copied TO.

function copyAudioEffectsToActiveSeqClip(OriginalSequence, clipIndex)

{

    // Copy audio effects to the ACTIVE sequence

    var seqTarget = app.project.activeSequence;

    var intTargetClipNum = clipIndex;

    var seqOriginal = OriginalSequence; //getSequence("AudioEffectAdded");

    var firstTargetTrack = seqTarget.audioTracks[0];

    var firstOriginalTrack = seqOriginal.audioTracks[0];

    // Change the array value on the TARGET to be the correct clip in the sequence

    var clipTarget = firstTargetTrack.clips[intTargetClipNum];

    var clipOriginal = firstOriginalTrack.clips[0];

    var componentsTarget = clipTarget.components;

    var componentsOriginal = clipOriginal.components;

    var effectToApply = Array();

    // put the effects into the target clip

    // this will always add more.  don't add them unnecessarily

    // need to loop through all of the ADDED effects and put them in the array (skip the first 2)

    for (var i = 2;i<componentsOriginal.numItems;i++)

    {

        effectToApply.push(qe.project.getAudioEffectByName(componentsOriginal.displayName));

    }

   

    for (var i=0;i<effectToApply.length;i++)

    {

        // add the effcets AND values to the target (ACTIVE) sequence

        qe.project.getActiveSequence().getAudioTrackAt(0).getItemAt(0).addAudioEffect(effectToApply);

       

        var thisEffect = componentsOriginal[i+2];  // need to make sure that items are added in the same order in new template

        var effectProps = thisEffect.properties;

       

        for(var j = 0;j<effectProps.numItems;j++)

        {

            componentsTarget[i+2].properties.setValue(effectProps.getValue());

        }   

    }

}

function getSequence(seqName)

{

    // EVERYTHING in the project root

    var mySeqs = myProject.sequences;

    // Find the sequence and return it

    var i;

    for (i=0; i<mySeqs.numSequences;i++)

    {

        if(mySeqs.name.toUpperCase() == seqName.toUpperCase())

        {

            return  mySeqs;

         }

     }

}

Translate
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