black frame at the end of a rendered movie

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
pirelouit
Posts: 18
Joined: January 16th, 2006, 12:08 pm

Hi! I made a script that makes a composition out of selected footage and then adds a timecode, project title, etc. It works really fine except for one thing. On some movies, when I render the composition, there is an extra black frame at the end of the movie.

If I manually adjust the work area that black frame dissapears. I tried to automatically adjust the work area with something like this:
myComp.workAreaDuration = curDuration;

but I get an error message saying that workAreaDuration is a read only attribute (contrary to what is written in the documentation).

Is there a way to prevent that black frame from appearring?

Thank you for your help!
pirelouit
Posts: 18
Joined: January 16th, 2006, 12:08 pm

I found a way to correct the length of my compositions, but I'm scared that it is going to remove a frame in some cases. Could somebody who is better in math than me tell me if what I did make sense?

the way I set the composition length used to be:
var compTime = curDuration
where curDuration was the length of the AVitem

now it is (the frame rate of my project is 24):
var compTime = Math.floor(curDuration*10000)/10000;

I think the black frame was added because After effect would round up the number of frames in some cases, but I don't know why...
davestewart
Posts: 114
Joined: March 10th, 2005, 5:50 am
Location: London, UK
Contact:

Did you check that the starttime of your footage layer was 0 and not 1 or -1?
pirelouit
Posts: 18
Joined: January 16th, 2006, 12:08 pm

I just verified by adding each time a composition is created
myNewMovie = myComp.layers.add(curItem);
alert(myNewMovie.startTime);

and all their startTime is set to 0. I also tried setting it to 1 (just in case) and the length of the total composition stayed the same.
w_m0zart
Posts: 20
Joined: June 6th, 2005, 1:52 pm
Location: Hengelo, Netherlands
Contact:

I found this peculiar behaviour in my script. Please see code:

Code: Select all

//###############################################################################
//#
//# Create a new comp with length size and framerate
//#
//# --> crProj      ;project object (=app.project)
//# --> myFoot      ;this is the avi or mov file for which a new layer will be created with same length
//# --> NM          ;Name of comp
//# <-- created composition
//#
//# There is some inaccuracy problem. At 25 fps:
//# Creating a comp with duration 5.96 wil give 150 frames (wrong, should be 149 frames)
//# Creating a comp with duration 6.00 wil give 150 frames (is correct)
//# How is this possible???
//###############################################################################
   function createNcomp(crProj,crCurItem,NM)
   {
      return crProj.items.addComp(NM, myFoot.width, myFoot.height, myFoot.pixelAspect, myFoot.duration-.005, myFoot.frameRate);
   }
I solved this problem, by subtracting .005

I hope this helps.
Last edited by w_m0zart on January 18th, 2006, 5:19 pm, edited 2 times in total.
pirelouit
Posts: 18
Joined: January 16th, 2006, 12:08 pm

Thanks, I feel better knowing that I am not the only one with this problem at least. I was wondering, what is the frame rate of your comp, 25 fps? Do you know if the frame rate makes a difference whether or not you obtain an 'extra frame' ? Because if no, it would mean that the duration is rounded somehow before calculating the number of frames...

Have you tested your solution extensively, could it possibly remove a frame on some duration?

Thank you again
w_m0zart
Posts: 20
Joined: June 6th, 2005, 1:52 pm
Location: Hengelo, Netherlands
Contact:

The frame rate was indeed 25 fps when the inaccuracy occurred. I guess the frame rate is based on an NTSC standard at 29,97 fps, but I did not check that. But this is just an assumption. I have no proof of that.

I did test it extensively, but it's really impossible to guarantee that all durations will work properly as well.

Together with testing, simple math gives you the following relation:

duration = n / fps

where n = number of frames, fps = number of frames per second

n is a natural number (We have only complete frames). When fps is 25, duration should have numbers which fit in a grid of 0.04 (s). [0, 0.04, 0.08, 0.12 ... etc]. I thought the calculating error is only caused by a wrong internal formula in After Effects, which uses probably some floating point math. I though just by changing one digit lower, should be enough to force the internal formula to select the proper amounts of frames. The reason to subtract is that all numbers between [5.96, 6.00] (i.e. including 5.96) will give the same amount of frames, where a duration of 5.96 should actually give one frame less. By subtracting just a little bit (0.005) we force After Effects to create something with the correct duration.
A duration of 6.00-0.005=5.995 will still create the right amount of frames, because 5.96 < 5.995 < 6.00
Nevertheless I think it is a shame that After Effects doesn't do this by default.

I used it in the 'Enhance Footage' script. The script processed about 250 avi files, all had a different length. The durations did not change any frame after processing. So I guess this solution works.
Post Reply