7 Replies Latest reply on Oct 11, 2015 2:38 PM by appr39754143

    Layer Duration Fits MainComp Duration

    appr39754143 Level 1

      Hi guys,

      i've this problem...

      I'm creating few videos with a progressbar... I've created a comp with the progressbar, with a duration on 10Minutes...

      Now i'm importing the progressbar comp into the main comp, but i need the duration is automatically adjusted with the main comp duration, or better with a audiosample...

      There is a script way to accomplish it ?!

      Kind Regards,

      Michele

        • 1. Re: Layer Duration Fits MainComp Duration
          appr39754143 Level 1

          Could be useful too a script that i can use with scale and the duration of the transitions match the duration of my sound clip, so i can make a progress bar that fits the duration of my audioclip...

          Regards,

          Michele

          • 2. Re: Layer Duration Fits MainComp Duration
            Rick Gerard Adobe Community Professional & MVP

            I'm not sure how you are animating your progress bar but you could write an expression that looks at the in and out point of the layer and then performs a linear interpretation of between the in and out points. For example, if you place the anchor point of the bar at the far left edge of the layer and then animate X scale you could use this expression for scale.

            l = outPoint - inPoint;

            t = time - inPoint;

            x = Math.ceil(linear(t, 0, l, 0, 101))

            y = value[1];

            [x, y]

            Then all you have to do is go to the end of the timeline and set the outpoint for that layer by pressing Alt/Option ]

             

            You could replace outPoint with a layer marker by rewriting the expression like this:

            l = marker.nearestKey(1).time - inPoint;

            t = time - inPoint;

            x = Math.ceil(linear(t, 0, l, 0, 101))

            y = value[1];

            [x, y]

             

            You could even use the first three lines on a text layer's source property to generate numbers.

            • 3. Re: Layer Duration Fits MainComp Duration
              appr39754143 Level 1

              Hi Rick...

              I'll try your solution, but i'm searchin for a solution that doesn't need a single click to be accomplished..I need a system that auto adjust itself for my needs, because i'm going to render videos as a bulk project, like 20/30 videos at once and in this process i can't edit individually the single output...

              • 4. Re: Layer Duration Fits MainComp Duration
                Rick Gerard Adobe Community Professional & MVP

                If you want to use an animation preset then you're going to have to trim the composition to the length of your video anyway which is more than one click.  If you want to automate building these comps then you need to write a script and my expression will work perfectly inside a script.

                 

                If you wanted to use a shape layer for your progress bar then you could set up all of the properties for that shape layer  as an animation preset. With no layers selected in the timeline you could apply the animation preset and the new shape layer created by the preset would be in the right position and the length of the comp.

                 

                Let me just repeat one time that if you want to automate the entire process you will need to write a script.

                • 5. Re: Layer Duration Fits MainComp Duration
                  Mathias Moehl Adobe Community Professional

                  You can do this as follows:

                  1) make sure the first and last frame of your progress bar comp is empty (100% transparent)

                  2) enable time remapping on the progress bar layer in the other comp

                  3) apply the following expression to time remapping

                   

                  var referenceLayer = thisComp.layer("my audio layer");
                  
                  var newStartTime = referenceLayer.startTime;
                  var newEndTime = newStartTime + referenceLayer.outPoint-referenceLayer.inPoint;
                  var oldEndTime = startTime + outPoint - inPoint;
                  linear(time, newStartTime,newEndTime,startTime, oldEndTime)
                  

                   

                  where you replace "my audio layer" with the name of your audio layer.

                  • 6. Re: Layer Duration Fits MainComp Duration
                    Rick Gerard Adobe Community Professional & MVP

                    You could also use the in and out point of an audio layer in the expression that I gave you. This would not trim your comp to the length of the audio layer but it would give you a progress bar that would scale up as the audio layer played. Try this by naming your audio layer "audio" and applying this animation preset (CC or later). This was such a good idea that I built an animation preset to add to my library of more than 200 that I use all the time. Dropbox - Progress Bar to audio.ffx

                    Just save the preset to your user presets folder and then find it in the Effects and Presets panel or browse to the preset from the Animation>Apply Animation Preset menu. This preset will give you a new shape layer at the bottom of an HD comp that is filled with a gradient and that scales up from the left as the audio plays. It does not solve trimming the comp to the length right length but it will do the job.

                    Screen Shot 2015-10-08 at 3.23.08 AM.png

                    Screen Shot 2015-10-08 at 3.23.58 AM.png

                    Here's the expression:

                    l = thisComp.layer("audio").outPoint - thisComp.layer("audio").inPoint;

                    t = time - inPoint;

                    x = Math.ceil(linear(t, 0, l, 0, 101))

                    y = value[1];

                    [x, y]

                     

                    The solution my friend Mathias gave you would work just fine on an animated pre-comp, but it also would not give you a fully automated solution that trims your comp to the length of your audio or your video layers.

                     

                    You could also use Duration in the expression instead of the layer's in and out point for l. this would give you a progress bar that started to scale up with the in point of the layer and continued to scale up until the end of the composition.

                    l = thisComp.duration - inPoint;

                    t = time - inPoint;

                    x = Math.ceil(linear(t, 0, l, 0, 101))

                    y = value[1];

                    [x, y]

                    There are lots of ways to get this done with just an expression but none of those ways will give you a fully automated way of creating a comp with an audio layer and a progress bar that matches the duration of the audio or video layer in the comp. That takes a script.

                    • 7. Re: Layer Duration Fits MainComp Duration
                      appr39754143 Level 1

                      thanks Rick,

                      i used this expression:

                      l = thisComp.duration - inPoint;

                      t = time - inPoint;

                      x = Math.ceil(linear(t, 0, l, 0, 101))

                      y = value[1];

                      [x, y]

                      and it worked very well!

                      Regards!!