ffmpeg: How to create cropped thumbnails?

For creating a video thumbnail with ffmpeg I'm using this command:

ffmpeg -itsoffset -4 -i video.mp4 -vframes 1 thumb.jpg

This gives me a thumbnail with the same size of the video (which has an unknown size, e.g. 960x540). But what I need is a square (cropped) thumbnail with a given size (e.g. 200x200). The result must not be resized, but cropped from the center, and the aspect ratio should not change.

How can this be accomplished?


You can use the crop video filter:

ffmpeg -ss 4 -i video.mp4 -vf crop=200:200 -vframes 1 output.jpg
  • By default the crop will be centered.

  • Use -ss instead of -itsoffset to choose your offset time.

  • You can control JPEG output quality with -qscale:v. Using a value of 2-5 is usually good; a lower value is a higher quality.

  • The crop filter can also accept the input and output width and height as values: iw, ih, ow, oh. This allows more flexible and creative filtering: crop=iw-100:ih-50.

You can test with ffplay to get a preview:

ffplay video.mp4 -vf crop=200:200

Original image (generated with the testsrc source filter:

ffmpeg -f lavfi -i testsrc -vframes 1 output.jpg 

original image

Cropped image:
cropped image


You can scale it first and then crop it for better output ;)

ffmpeg -ss 10 -i "Ali_Video.mp4" -vframes 1 -filter "scale=-1:300,crop=400:300" "output.jpg"

input video at 0:49 output image

ffmpeg -ss 10 -i "Ali_Video.mp4" -vframes 1 -filter "scale=-1:150,crop=200:150" "output.jpg"

another thumbnail