Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Script to trim Selected Video Layers to the length of its audio

  • Script to trim Selected Video Layers to the length of its audio

    Posted by Rafat Rifaie on November 3, 2017 at 6:40 pm

    I have 50+ layers. Each layer is a separate video clip with audio. All layers have different lengths, and the audio in each layer ends before the its video does [there’s a still image placed after the audio is over for a random amount of time **Random(that’s the problem)]. I basically want to trim all the unnecessary still footage of each layer, matching the layer’s length to its audio’s. The audio stops, the layer ends. Is this possible to do, and how?

    Rafat Rifaie replied 8 years, 9 months ago 1 Member · 1 Reply
  • 1 Reply
  • Rafat Rifaie

    November 3, 2017 at 8:38 pm

    Thanks for the reply dave, but this is actually a bit tedious

    • Select Layer
    • Click to unfold layer’s properties
    • Click to unfold audio properties
    • Click to unfold audio’s waveform
    • Scrub to the end of the waveform
    • Press ctrl ]
    • Scroll down to be able to see next layer
    • Repeat

    If this is a one time job, i would tame my impatience for a bit, but it would drive me crazy when i get the next batch of videos to process lol.
    On another note, while looking through the extendscript guide, i found this method “app.project.item(i).layer(i).audioActiveAtTime(time)”
    which is a good starting point. I’m thinking to loop through all the layers i want to trim, and with a nested for loop [i = layersLength; i > 0; i–] that decrements the time by 1 sec call the audioActiveAtTime method, until i get a false, then record that time and trim the layer to it.
    Hopefully this all works out when i’m out of work tomorrow.

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