After Effects

Pre-compose to layer duration (a script)

Ever since I started using After Effects I’ve been annoyed at how the pre-compose function works. It’s always bugged me that when you pre-compose a layer the new composition is the duration of the original composition, not the individual layer.

Pre-compose - How it normally works

It bugged me a lot. Then I found a script on Dan Ebbert’s site which solved this quirk and introduced me to the world of scripting. I was absolutely thrilled by this discovery because it meant that a few lines of text could add new features to After Effects without the need to eagerly await the next version release, hope that your feature requests had been included, and then pay for the upgrade.

Although the script on Dan’s site was a great improvement there was one additional tweak I wanted to make: when I pre-compose a layer I sometimes want the layer to begin at the start of the new pre-composition and not maintain its original in-point. So I took Dan’s code, modified it slightly, and came up with a version that did exactly what I wanted.

You can download it here.

Pre-composing by using the script

You may be wondering why this is useful. So let me describe a typical working scenario:

A video production company is working on an fx-intensive project. They’ve pitched the concept, won the job, written the script, shot the images and an editor has come up with an approved edit. The next step is to start the graphics and fx work- which is your job. All the visual-fx in the project will be completed using After Effects. The editor exports the approved edit from Final Cut Pro as a single quicktime file because the production company is too tight to purchase Automatic Duck. You import the quicktime file into After Effects and run the brilliant Magnum edit detector script by Lloyd Alvarez. This automatically cuts the Quicktime file into individual shots. But if you were to build all of the graphics and fx into this one composition you’d end up with a monstrous creation that has thousands of layers! So you decide to pre-compose each fx shot into its own composition. Some of the shots will have additional elements in them that have been rendered out of a 3D program like Cinema 4D, and the 3D artist has rendered them out as TIFF sequences that all begin at 0. To make sure they line up properly it helps if each pre-composition in After Effects also begins at frame 0. This way if you need to alter shots or identify specific frames then the frame number in AE will be the same as the frame number in Cinema 4D. So this is where the script comes in handy… and also explains why it renames each pre-composition according to the original layer number.

Your finished timeline would look like this:

And your project window would look like this:

Other AE users have also generously modified the script to add different functionality they would prefer and you try them all over at the AE Enhancers web site.

If you’re not familiar with scripts then all you need to do is drop the downloaded .jsx file into the “Scripts” folder of the After Effects application folder. Next time you start After Effects it will appear in the list with the other scripts.