A-frames @ 23.98fps (and slates in general)

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
erikhansen
Posts: 3
Joined: October 30th, 2007, 9:33 pm

Hello,

First time caller, short time listener...

So I am delving into making some scripts for my day job and running into problems. Basically, daily I layoff vfx/elements that come to me usually as file sequences to HD/23.98 (D5, HDCam SR, HDCAM). Now, the good companies actually inclusde slates. But that's probably half of the shows we work with...

The other thing is that we like to lay things off so that each shot lands on an A-frame (for down conversions). So my initial thoughts were to make (steal) a script that added a 1 sec slate and made the duration round up to an even second.

For the time being, as I'm new to this (haven't scripted in 4+ years). I am using one of Paul's scripts as basis for the duration and Lloyd's for the slate.

Well all seemed ok with the duration UNTIL I ran into a duration of over 4000 frames. It seems there is a math problem, because if I force the rame rate to 24 solid, then all is well but since it needs to be 23.98 it doesn't work. So now I come to you all for help...

- Erik

Code: Select all

// Original code by Paul Tuersley
// This is for 23.98 (maybe 24) Projects only.
//
// This script will take a 23.98 comp and will create a new comp with 1 sec
// added to the head, as well as X+24 frames to the end to make a quicktime
// file for laying off to tape - ie. 24fps VFX reel.
//
// Purpose is so that each shot starts on an A frame for downconverts. Just drop
// footage in a FCP timeline and go...


{

   // create an array of selected comps
   var selectedComps = new Array();

   for (var i = 1; i <= app.project.items.length; ++i) {
      if (app.project.items[i] instanceof CompItem && app.project.items[i].selected) {
         selectedComps[selectedComps.length] = app.project.items[i];
      }
   }


   // for each of the selected comps
   for (var i = 0; i < selectedComps.length; ++i) {

      // create new comp, make it one frame longer and add S to it's name
      currentComp = selectedComps[i];
      slateCompName = "_111_" + currentComp.name
	  var compBG = [0/255,0/255,0/255] 		// Set background color to black

// 		adds 1 frame to head
//      slateCompDuration = currentComp.duration + (currentComp.frameDuration * 0.99);
//		This is for 29.97fps
//		slateCompDuration = Math.round(currentComp.duration) + (2 * 0.99);
//		slateCompDuration = Math.round(currentComp.duration) + (1 * 0.99);

//      slateCompDuration = Math.round(currentComp.duration) + 1 + (currentComp.frameDuration * 0.99);
//      slateCompDuration = Math.round(currentComp.duration) + 1 + (currentComp.duration * 0.99);
//		slateCompDuration = Math.round(currentComp.duration) + 1 + (currentComp.frameDuration * 1.04170142527805);
//		slateCompDuration = Math.round(currentComp.duration) + 1.04170142527805;
//		slateCompDuration = Math.round(currentComp.duration);

		alert("currentComp is " + currentComp.name);
		alert("currentComp.frameRate is " + currentComp.frameRate);

		alert("currentComp.duration is " + currentComp.duration);

//		eFindDuration = currentComp.duration/24;
//		eMathDuration = Math.ceil(eFindDuration);
		
		eNewDuration = Math.ceil(currentComp.duration) + 1;
		alert("eNewDuration is " + eNewDuration);

//		eFps = Math.round((1.001/currentComp.frameDuration)); 
//		alert("eFps is " + eFps);

//		alert("eFindDuration is " + eFindDuration);
//		alert("eMathDuration is " + eMathDuration);
		
		slateCompDuration = (eNewDuration) + .005;

		alert("slateCompDuration is " + slateCompDuration);

//		slateComp = app.project.items.addComp(slateCompName, currentComp.width, currentComp.height, currentComp.pixelAspect, slateCompDuration, currentComp.frameRate);
// Forcing new comp frame rate to 24 solid
		slateComp = app.project.items.addComp(slateCompName, currentComp.width, currentComp.height, currentComp.pixelAspect, slateCompDuration, 24);

//		alert("slateComp.frameRate is " + slateComp.frameRate);
//		slateComp.frameRate = 23.98;
//		alert("slateComp.frameRate is " + slateComp.frameRate);

      // add orignal comp
      precompLayer = slateComp.layers.add(currentComp);

	  slateComp.bgColor = compBG;

//		FYI - 1 frame @ 24fps = 0.04170142527805
//      precompLayer.startTime = 1

   }


}
Paul Tuersley
Posts: 704
Joined: June 5th, 2004, 7:59 am
Location: London, UK

What exactly is the problem? It works fine unless the duration is over 4000 frames, at which time it doesn't work properly in what way?

Paul
erikhansen
Posts: 3
Joined: October 30th, 2007, 9:33 pm

Yes, I seemed to have left out some important details...

Seems to me that this is all how timecode/frame rate is dealt with. 4000 is also not quite right, not sure where it actually happens, just happens that the first compostion I tried it on at work was over 4000 frames in duration.

For example, let's say I have a comp that has a duration of 3999 frames at 23.98. If I have the line -

Code: Select all

// Forcing new comp frame rate to 24 solid
slateComp = app.project.items.addComp(slateCompName, currentComp.width, currentComp.height, currentComp.pixelAspect, slateCompDuration, 24); 
The duration is 4008 at 24fps (solid). 4008/24 = 167. Good. (actually my script makes it 4009 frames to deal with the "inclusive" nature of After Effects).

However, as I ultimately need a broadcast standard of 23.98fps to layoff to tape. If I keep the framerate at 23.98, I end up with 4005 frames.

Code: Select all

slateComp = app.project.items.addComp(slateCompName, currentComp.width, currentComp.height, currentComp.pixelAspect, slateCompDuration, currentComp.frameRate);

So I guess it boils down to some math of timecode that I don't understand, or know how to account for. Any help would be appreciated.

Thanks,
- Erik
Paul Tuersley
Posts: 704
Joined: June 5th, 2004, 7:59 am
Location: London, UK

When I run the script you posted on a 3999 frame 23.976 fps comp, I get a 4033 frame 24 fps comp, not 4008. Why are you even trying to convert to 24 fps when you say that's no good for you?

Living in PAL land, I've never had to deal with drop frame so I don't know what's required for comp conversion. But I'm guessing this is related to using currentComp.duration which is in seconds, when perhaps you should be thinking in frames. Basically, a conversion error that only becomes apparent with longer durations.
erikhansen
Posts: 3
Joined: October 30th, 2007, 9:33 pm

Hey Paul,

I guess I don't really consider it "drop-frame" but I guess it is... The thing is that you can't go to HD tape (23.98fps) with 24fps footage.

You got 4033 frames because I added 1.005 seconds to the duration.

I'm converting to 24 so that the duration is correct.

So if currentComp.duration is in seconds, how do I use to set duration in frames?

Thanks for the help!

Best,
- Erik
Paul Tuersley
Posts: 704
Joined: June 5th, 2004, 7:59 am
Location: London, UK

A 23.98 fps comp has a slightly longer duration than a 24 fps comp with the same number of frames. It's about a 4 frame difference at 3999 frames, which sounds like what you're experiencing.

3999 frames / 23.978 fps = 166.7779 seconds
3999 frames / 24 fps = 166.625 seconds

I don't know, but I'd think the proper way to deal with this is to ensure you're doing a frame for frame conversion, which would also involve timestretching the layer.

To read the 3999 frames at 23.98 comp duration in frames:
Math.ceil(thisComp.duration / thisComp.frameDuration) = 3999

To set the duration in the 24 fps comp:
3999 / 24 = 166.25 seconds

To timestretch the layer speed up to 24 fps:
23.98 / 24 = 99.916666%

I guess if it's only 4 frames out after 2 mins 46 seconds it's easy to ignore.

Paul
Post Reply