Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Floating point precision errors lead to blank frames at end of composite clips #210

Closed
Humper opened this issue Sep 20, 2015 · 1 comment · Fixed by #1195
Closed

Floating point precision errors lead to blank frames at end of composite clips #210

Humper opened this issue Sep 20, 2015 · 1 comment · Fixed by #1195

Comments

@Humper
Copy link

Humper commented Sep 20, 2015

Example:

clip duration = 0.56
fps = 12.5

When this gets written out to frames, we use (in Clip.py's iterframes):

        for t in np.arange(0, self.duration, 1.0/fps):

But numpy gives:

(Pdb) np.arange(0, .56, 1.0/12.5)
array([ 0.  ,  0.08,  0.16,  0.24,  0.32,  0.4 ,  0.48,  0.56])

This means that a composite video clip will try to generate an 8th frame at t=0.56. However, since the individual clips that make up the composite all have end=0.56, none of them is considered to be playing at that time. This results in a black final frame (just the background color, with no clips composited over it).

I don't think this is really a bug in the compositor so much as a result of numerical precision issues resulting in the extra t=0.56 frame being generated. Specifically, numpy says that arange generates a half-open interval [start, end), so in theory the arange array should end at t=0.48, but it doesn't, because the numbers 0.56 and 0.8 cannot be represented perfectly by floating point.

One quick hacky workaround to this specific problem is to change the upper limit of the arange to:

self.duration - 1.0/(2*fps)

This will prevent the spurious final frame from being generated.

@ghost
Copy link

ghost commented Mar 15, 2017

to avoid the floating point error issue, would it be better to do something like:

for t in np.arange(0, self.duration * fps, 1)
    new_t = t/fps

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant