If the JPEG encoding step is too performance intensive, you could always store the frames uncompressed as BMP images:
ffmpeg -i file.mpg -r 1/1 $filename%03d.bmp
This also has the advantage of not incurring more quality loss through quantization by transcoding to JPEG. (PNG is also lossless but tends to take much longer than JPEG to encode.)
Answer from Multimedia Mike on Stack OverflowIf the JPEG encoding step is too performance intensive, you could always store the frames uncompressed as BMP images:
ffmpeg -i file.mpg -r 1/1 $filename%03d.bmp
This also has the advantage of not incurring more quality loss through quantization by transcoding to JPEG. (PNG is also lossless but tends to take much longer than JPEG to encode.)
Came across this question, so here's a quick comparison. Compare these two different ways to extract one frame per minute from a video 38m07s long:
time ffmpeg -i input.mp4 -filter:v fps=fps=1/60 ffmpeg_%0d.bmp
1m36.029s
This takes long because ffmpeg parses the entire video file to get the desired frames.
time for i in {0..39} ; do ffmpeg -accurate_seek -ss `echo $i*60.0 | bc` -i input.mp4 -frames:v 1 period_down_$i.bmp ; done
0m4.689s
This is about 20 times faster. We use fast seeking to go to the desired time index and extract a frame, then call ffmpeg several times for every time index. Note that -accurate_seek is the default
, and make sure you add -ss before the input video -i option.
Note that it's better to use -filter:v -fps=fps=... instead of -r as the latter may be inaccurate. Although the ticket is marked as fixed, I still did experience some issues, so better play it safe.
How do I extract frames from a specific time range?
ffmpeg -ss 00:01:00 -i input.mp4 -t 10 -vf "fps=1" range_%03d.jpg
This extracts one frame per second from the 1:00 to 1:10 mark.
Can I extract frames as PNG instead of JPEG?
ffmpeg -ss 5 -i input.mp4 -frames:v 1 frame.png
What's the fastest way to extract a single frame?
I'm using the following command to grab the 10th frame from a video, I'm looking for a faster way to do this :
ffmpeg -i video.mp4 -vf "select=eq(n\,10)" -vframes 1 frame.jpg
Thank you.
Environment: Android
Hi, right now, I'm using ffmpeg -i videoInput /vbr_frame_%d.jpg to extract all frames from video, everything works fine, but it's a little slow.
a 3 minutes video takes almost 5 minutes to finish the frames' extraction.
Is there any possibility to speed up this process without losing any frame?

