Skip to main content
Inspiring
January 6, 2012
Question

Get comp fps, start, end

  • January 6, 2012
  • 2 replies
  • 1914 views

I'm wondering how to access composition attributes. I want the start and end time. So far I've found out how to get it in seconds, but I'd really like to have the frame numbers. The users might not have their settings at 24 by accident so a simple time*24 wont work but if I could get the fps I could do time*fps. Any thoughts?

This topic has been closed for replies.

2 replies

Legend
January 23, 2012

Here's a function I threw together that you can run in a loop on each of your layers to get the in and out points of your layers. It incorporates Dan's equation as well for seconds to frames conversion. I made it so you can choose frames or seconds as the returned value as well. There are two arguments to the function, the first should be your layer object and the second argument is true for frames or false for seconds. Be sure to paste the into a code editor like ExtendScript Toolkit which has code highlighting, it'll make this easier to read.

var curLayer = app.project.activeItem.layer(1);/*     TEMP layer object variable. This should be replaced by your layer object */

var ioPt = layerIO(curLayer, true);/*     Two arguments required for the function "layerIO(layerInput, frmSecInput)" true=frames/false=seconds     */

var inPt = ioPt.inPointVal;/*     Retrieves the in point val from the function.     */

var outPt = ioPt.outPointVal;/*     Retrieves the out point val from the function.     */

alert("In: "+inPt+"\nOut: "+outPt);/*     OPTIONAL: For testing the output     */

function layerIO(layerInput, frmSecInput){

     var frmSec = frmSecInput;

     var inP, outP;

     var curCompFR = app.project.activeItem.frameRate;

     (frmSec == true) ? inP = (Math.round(layerInput.inPoint * curCompFR)) : inP = layerInput.inPoint;

     (frmSec == true) ? outP = (Math.round(layerInput.outPoint * curCompFR)) : outP = layerInput.outPoint;

     return {

           "inPointVal": inP,

           "outPointVal": outP

     };

}

Dan Ebberts
Community Expert
Community Expert
January 6, 2012

Since a comp is an AVItem, you can just use AVItem attribute frameRate, like this:

Math.round(myComp.duration*myComp.frameRate);

Dan