Given a specific frame I need to extract an image (a thumbnail) from a video using ffmpeg.
E.g. I can do:
ffmpeg -i test.mp4 -ss 00:01:14.35 -vframes 1 out2.png
I can extract an image from a specific time (00:01:14.35), but what I need is to extract an image from a specific frame.
Click the arrow next to export video at the top right corner of the Studio and select export as image. Use the slider that appears below the video to select the exact frame you want to download.
The trick is to simply change the frame rate of the output to whatever we want using the -r n option where n is the number of frames per second. 1 frame per second would be -r 1 , one frame every four seconds would be -r 0.25 , one frame every ten seconds would be -r 0.1 and so on.
Use the following method
ffmpeg -ss 00:10:20 -t 1 -s 400x300 -i <INPUT_FILE> -f mjpeg <OUTPUT_FILE>
-ss and the time argument that follows tells ffmpeg at what point you want the screenshot snapped. In this example, ffmpeg will take a shot at the 10 minute and 20 second point. -t tells ffmpeg that you want only 1 shot, -s is the size of the pic, and -f tells it to make a photo (but not limited to jpg). For example, to generate a png screenshot for Batman.avi at the 1 hour, 12 minute, and 30 second point:
ffmpeg -ss 01:12:30 -t 1 -s 400x300 -i Batman.avi -f mjpeg Batman.png
To get to some specific frame you should use filter select. Command to extract frame 100 out of video should look like this:
ffmpeg -i in_video.avi -vf "select=gte(n\,100)" -vframes 1 out_img.png
or just
-vf "select=eq(n\,100)" 100.png
the -vframes
option could be omitted
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With