-
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
Extracting frames #702
Comments
No clear what you mean by "frames in jpg to python numpy. import moviepy.editor as mpe
video = mpe.VideoFileClip('some_video.mp4')
np_frame = video.get_frame(2) # get the frame at t=2 seconds
np_frame = video.get_frame(frame_number * video_fps) # get frame by index
video.save_frame('my_image.jpeg', t=2) # save frame at t=2 as JPEG |
Hey zulko, Thank you for quick reply.I meant i have a video from which i need to extract frames at a particular FPS.But conditions are the image format is jpg and a certain quality like "qscale:v" parameter in ffmpeg and i need the extracted images(frames) in numpy |
You can do it in moviepy with: my_numpy_array = mpe.ImageClip('my_image.jpeg').get_frame() But there are many more libraries that can do that such as Pillow, certainly Scipy, etc. |
Yes in many other libraries including the ones you mentioned, the issue is ffmpeg extracts the frames for a certain size(file size).When I load the "ffmpeg extracted" image using (say) OpenCV's imread the size in memory is increased.My application requires thousands of images to be loaded in memory.So an 100MB files in harddisk increases to 2GB in RAM.any thoughts on this direction ? |
can you explain what is the end goal of your project ? image analysis ? making a video ? |
It is image analysis from a video. 14400 files taking 92MB disk space |
I will close this as it is not Moviepy related anymore. For this kind of support it is better to post to Stackoverflow or Reddit/Moviepy, we try to keep this section for bug reports or feature requests. You should give more details when you post on these sites, such as what kind of analysis you are doing. The key question here is - are you really obliged to open all the images at the same time ? |
Sure,I understand what you are saying.will think about the approach.Between the point am trying to make is opencv or scipy when decoding the image (extracted from ffmpeg) the file size changes.Thank you for such a quick response. |
Hello @Zulko. Asking to reopen this ticket for its generic title. I am noticing that Would you be available to discuss this offline in email? |
@davidbernat It'd be better to open a new issue for this than for us to reopen this very old one, especially since nothing in OP's original question suggests it had anything to do with what you are asking here. Subject lines aren't necessarily good indicators for if older issues match what you're looking for, and we don't want to make anyone, including ourselves, waste time by reading through years-old threads only to discover they are of little relevance to what's being asked now. |
Is there a way to extract frames in jpg to python numpy?
The text was updated successfully, but these errors were encountered: