Skip to main content
Participant
November 22, 2022
Question

Visibility of a layer related to sound

  • November 22, 2022
  • 3 replies
  • 856 views
Hi all,

I've searched the forums a lot on the subject but I can't find a solution to my problem. The closest would be this article but it doesn't match the animation I want to make...

I'm working on an animation for an audio podcast. I would like the thumbnail of the speaker who speaks to appear automatically when he starts speaking and disappears when he finishes.

So I need to link an animation of the layer opacity from 0 to 100 and from 100 to 0 with the audio spectrum. do you think that is doable?

Thank you to all of you !
This topic has been closed for replies.

3 replies

Community Expert
November 23, 2022

You can not get an expression to recognize a voice, but you can get an expression to recognize when audio levels move above the base noise level or look at layer markers. This means you would have to separate the audio into two tracks, one for the speaker and one for the host, or you would have to add an audio marker every time the speaker starts to talk and, another one when they stop. By far, the simplest solution is to split the audio track so the speaker is only on one track, then add layer markers or just all layer markers when you want the opacity to change. 

 

To tell you the truth, if the podcast is longer than about 1 minute, I would do the whole thing in Premiere Pro  by just making cuts in the layer containing the speakers' image and using the keyboard shortcuts to add fade in and fade out. You could do all of the cutting in real-time while the clip was playing by just hitting a key, then jump back into the timeline and delete all of the parts where the primary speaker wasn't talking. 

Participant
November 23, 2022

Thank you Rick Gerard,

There will be 3 speakers and a host. I will receive each track individually, cleaned.

I'm going to have 3 podcasts over an hour each, so my effect needs to be automated.

By converting each audio tracks to keyframes, and with a low threshold, after effects should easily recognize when the speaker is speaking. You just have to manage to tell him to launch a fadein and a fadeout at the right moment...

Community Expert
November 23, 2022

To write an expression that looks for empty spots in an audio track, you are going to have to pick a time value that is long enough to prevent all normal pauses a person makes when they are talking from turning off the layer while at the same time calculating the start and end time of that pause and creating a transition instead of a cut from 100% opacity to zero. Even if that could be done, the expression would be recursive and extremely slow to render. 

 

If you drop your images and your audio tracks into Premiere Pro, expand the audio tracks enough that you can see the levels when the different people are talking, then use Ctrl/Cmnd + K to make a cut every time somebody else talks; you should be able to trim an hour-long podcast in just a few minutes manually. You can then use the Up and down arrow key to jump from cut to cut, delete where you don't want to see the image, then select all the sections in the timeline, and press D to add the default Fade In and Out transition to every selected section. You could even use the L key to playback the sequence in real-time or speed it up and just press Ctrl/Cmnd + K to make a cut every time you want the photo to change. I can't imagine that the entire process would take more than 15 or 20 minutes. 

Dan Ebberts
Community Expert
Community Expert
November 22, 2022

Assuming you have converted your audio to keyframes, something like this could possibly work, although it will probably be slow (unless maybe you convert the expression to keyframes once you're happy with how it works):

threshold = 5;
fadeTime = .5;
L = thisComp.layer("Audio Amplitude");
audio = L.effect("Both Channels")("Slider");
tIn = L.inPoint;
tOut = L.outPoint;
for (i = L.inPoint; i <= L.outPoint; i += thisComp.frameDuration){
  if (audio >= threshold){
    tIn = i;
    break;
  }
}
for (i = L.outPoint; i >= L.inPoint; i -= thisComp.frameDuration){
  if (audio >= threshold){
    tOut = i;
    break;
  }
}
if (time < (tIn + tOut)/2){
  linear(time,tIn,tIn+fadeTime,0,100);
}else{
  linear(time,tOut-fadeTime,tOut,100,0);
}
 
Participant
November 23, 2022

Thank you Dan Ebberts,
Yes I did convert audio to keyframes.
I applied your expression to the opacity of my layer, I have a fade in and fade out but only at the beginning and end of the composition (the ajustement of the fadeTime work well).

We would say that it does not react with the audio keyframes even by adjusting the threshold...

Mylenium
Legend
November 23, 2022

Rick answered your question and that's why it doesn't work. Spoken language has no distinct peaks for any expression algorithm to determine anything. As Rick and I already said you have to actually chop up your file or create markers so the marker times or in- and out-points can be used.

 

Mylenium

Mylenium
Legend
November 22, 2022

You cannot link anything to an effects internal stuff unless it is exposed as a regular property. That being the case, whatever you have in mind will need to be prepeared by e.g. using Premiere's audio tools to create cuts and markers and reference those as per the expressions you already found. Point in case: AE is neither an audio nor an actual video editing tool. It's really just meant for graphics and you have to include other tools in your workflow.

 

Mylenium