Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Extract keyframes from audio without opening the composition in the viewer?

  • Extract keyframes from audio without opening the composition in the viewer?

    Posted by Ted Mihu on September 19, 2014 at 5:48 pm

    Hello,

    I have this script, and part of the script deals with opening the comp in the viewer so that it can select the audio layer and create an audio null from it. I was wondering if there is a way to do this without opening the composition in the viewer, as this makes After Effects pop up over any active windows and makes the computer unusable for the duration the script is running.

    I have other issues with my script but this is the most important one which will make the most difference.

    Thank you,

    Ted Mihu

    myComp.layers.add(sel[i]); //This adds the VO track the composition is based on to the composition
    myComp.layers.add(bodyComp);
    myComp.layers.add(mouthComp);
    myComp.openInViewer(); //This opens the composition the loop is currently working on in the comp viewer. It is the reason AE constantly goes to the front of the screen and a highly inefficient part of the script, but it is the only way I know of extracting audio from the VO.
    myComp.layer(1).timeRemapEnabled = true;
    myComp.layer(1).selected = false;
    myComp.layer(3).selected = true; //These two lines make sure that the audio layer is selected for the next step
    app.executeCommand(app.findMenuCommandId("Convert Audio to Keyframes")); //This extracts audio data from voice over track in the form of keyframe data in a null layer
    myComp.layer(2).timeRemap.expression = "X = thisComp.layer(\"Audio Amplitude\").effect(\"Both Channels\")(\"Slider\"); linear(X,0,"+finalMaxVal+",0,"+tolerance+");"
    myComp.layer(3).position.expression = "comp(\""+bodyCompName+"\").layer(\"DogTransform\").transform.position";
    myComp.layer(3).scale.expression = "comp(\""+bodyCompName+"\").layer(\"DogTransform\").transform.scale"
    myComp.layer(3).rotation.expression = "comp(\""+bodyCompName+"\").layer(\"DogTransform\").transform.rotation"
    myComp.layer(3).selected = false;
    myComp.layer(1).selected = true;
    app.project.activeItem.layer(1).effect("Both Channels")(1).expression = "smooth("+smooth1+", "+smooth2+", time);"; //This adds a smooth expression to the null, this is the only way I've found to do this to date
    myComp.layer(2).outPoint = compDur;

    Dan Ebberts replied 11 years, 8 months ago 2 Members · 1 Reply
  • 1 Reply
  • Dan Ebberts

    September 19, 2014 at 6:29 pm

    I can’t think of a solution because to do the audio-to-keyframe conversion, your script needs to use a menu command, which (I believe) requires the comp to have focus.

    Dan

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy