Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extract a thumbnail from a specific video frame

Tags:

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.

like image 761
user2066408 Avatar asked Dec 05 '13 11:12

user2066408


People also ask

How do I extract a frame from a youtube video?

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.

How do I extract one frame of a video every second seconds into a photo?

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.


Video Answer


3 Answers

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 
like image 23
user3917039 Avatar answered Sep 22 '22 17:09

user3917039


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 
like image 156
ptQa Avatar answered Sep 23 '22 17:09

ptQa


or just

-vf "select=eq(n\,100)" 100.png

the -vframes option could be omitted

like image 28
mo-han Avatar answered Sep 23 '22 17:09

mo-han