Skip to main content
Known Participant
March 20, 2014
Question

Finding Start Time of Footage

  • March 20, 2014
  • 1 reply
  • 680 views

I'm trying to get the starting timecode of footage via scripting. The only way I can think of doing this is using the "New Comp from Selection" app.executeCommand to create a comp. Then I can use displayStartTime function on the new comp. Is there a smarter way to do this? I'd rather not use the app.executeCommand but I can't think of anything else. If there isn't a better way, could someone tell me why the script below isn't working? It does the first loop but after that the remaining loops don't execute fully. Thanks for the help!

--

var selectedFootage = app.project.selection;

var footageComps = new Array();

var startTimes = new Array();

for (var i=0; i<selectedFootage.length; i++)

{

          // Deselect All

          app.executeCommand(2004);

          // Select Footage Item

          selectedFootage.selected = true;

          // New Comp From Selection

          app.executeCommand(2796);

          // Deselect Footage Item

          selectedFootage.selected = false;

          // Set footageComps Varible

          footageComps = app.project.activeItem;

          // Get Start Time

          startTimes = footageComps.displayStartTime;

          alert(startTimes);

}

This topic has been closed for replies.

1 reply

Known Participant
April 1, 2014

Can anyone help with this?

I did find this expression method: sourceTime(t = time), which returns the source time corresponding to time t. This works fine in an expression but dosen't seem work via script.

Is there any sort of trickery one could use to get the embedded starting timecode of footage?

Thanks again.

Participant
April 2, 2014

Maybe it's just me and my not so well eng.

can you post screenshot w/ big red arrow on yours 'footage' ?

how about 'workflow', selections, layers, project panel ?

Known Participant
April 2, 2014

I was able to figure it out using a bit of a hack. It was actually something I read in another post on this forum but didn't understand it till just now. Here it is if anyone is interested.

function getStartSourceTime(footage)

{

          // Create comp with footage attributes

          footageComp = app.project.items.addComp(footage.name, footage.width, footage.height, footage.pixelAspect, footage.duration, footage.frameRate);

          // Add selected footage to the new comp

          footageLayer = footageComp.layers.add(footage);

          // Add type layer with expression reading the start time of the footage layer

          var startTimeText = footageComp.layers.addText("Start Time");

          startTimeText.property("Source Text").expression = "thisComp.layer(2).sourceTime(0)";

          // retrieve the value from the type layer

          startSourceTime = startTimeText.property("Source Text").value;

          // Delete the created comp

          footageComp.remove();

          return startSourceTime;

}