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

inconsistent behaviour of clip.get_frame() #751

Closed
TejasBob opened this issue Mar 23, 2018 · 3 comments
Closed

inconsistent behaviour of clip.get_frame() #751

TejasBob opened this issue Mar 23, 2018 · 3 comments
Labels
images Related to ImageClip, or handling of images in general.

Comments

@TejasBob
Copy link

TejasBob commented Mar 23, 2018

I'm trying following script in ipython terminal.

from moviepy.editor import *

clip = VideoFileClip(file_path, has_mask=True)
print(clip.duration) # 6.04
img = clip.get_frame(9)

This results in

OSError: MoviePy error: failed to read the first frame of video file file_path ...

but when I do

img = clip.get_frame(6)
img = clip.get_frame(9)

it doesn't fail. Instead it gives warning

... bytes wanted but 0 bytes read,at frame 225/152, at time 9.00/6.04 sec. Using the last valid frame instead.

@GarciaDelMolino
Copy link

when get_frame fails to read the requested frame, it returns "the last valid frame instead." If there is no previous frame, then it returns OSError. Check the source here.

In your case, you request the frame at time 9 seconds, which doesn't exist. If you have not requested any frame before (1st example), clip.get_frame will give an error. Otherwise (2nd example), a warning, returning the frame at time 6 seconds.

@TejasBob
Copy link
Author

got it.

@keikoro
Copy link
Collaborator

keikoro commented Dec 16, 2018

@TejasBob It sounds like the above comment helped solve the problem, I'm thus closing this issue. Please reopen if the problem persists.

@keikoro keikoro closed this as completed Dec 16, 2018
@keikoro keikoro added the images Related to ImageClip, or handling of images in general. label Dec 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
images Related to ImageClip, or handling of images in general.
Projects
None yet
Development

No branches or pull requests

3 participants