-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Rendered output missing first frame #155
Comments
I think it's an issue with your code, you are iterating before rendering the frame, so the first frame being rendered is indeed 1. Try this to see the problem:
|
Maybe I am missing something obvious, but the image returned by render_frame() is rendered prior to the myobj.iterate() call, so I think the first frame should be 0. I tried this to test this, and I get 5 images generated by moviepy, and 6 images generated from the savefig call: def render_frame(t):
img = myobj.show_f()
myobj.iterate()
plt.savefig('i_%d'%myobj.i)
return mplfig_to_npimage(img) |
Ah yes, sorry. Now I see where the problem may be: it comes from the fact that MoviePy will always compute once the first frame of a clip and then throw it away (unless you tell your clip to memoize it). This is not optimal because that means the first frame gets computed twice in many situations, but it also makes a lot of things easier (debugging, interactivity, etc.). Normally it shouldn't cause any problem because you are supposed to call your clip with a time t, and if you ask twice for the frame at t=0 you will get twice this frame, no problem. But in your case where you try to hack to use indexes instead it causes a problem. I see several solutions: (1) If you only need an index, use the time to infer an index:
(2) If you need to update a clip or to use different data at each index i you can have a look at these two classes, UpdatedVideoClip and DataVideoClip (3) If you really need to work frame by frame with an update between each and UpdatedVideoClip doesn't work as you want, the simpler is to use directly imageio:
|
Thanks for the suggestions. I'll have to look more closely at UpdatedVideoClip when I have some time; it seems like the solution that might match my use case. I tried (1) and (3) and they won't work directly for me. |
Has this issue been resolved? |
@gazzar Did you manage to solve your problem, can we close this issue? |
Sure, go ahead and close it. That was so long ago that I can't remember what I eventually did to resolve my problem anyway. |
First, thanks for moviepy; very nice work! I was inspired to try it after seeing your blog post data-animations-with-python-and-moviepy
I think moviepy is dropping the first frame in all rendered output. Here is a minimal(-ish) example that should render the first frame with a label of 0, but actually starts at 1. This may be related to bug #122.
The text was updated successfully, but these errors were encountered: