Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question

migrated from stackoverflow.com Jun 28 '13 at 0:24

This question came from our site for professional and enthusiast programmers.

    
Why use -itsoffset instead of -ss? I've seen an increased usage of this lately by users making image outputs from videos. –  LordNeckbeard Jun 27 '13 at 17:58
    
@LordNeckbeard: Sorry, mixed up the options. Found this for more info about -itsoffset vs. -ss: superuser.com/questions/538031/… –  Georg Ledermann Jun 28 '13 at 5:12

1 Answer 1

up vote 5 down vote accepted

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 output quality with -qscale:v using a value of 2-5 is usually recommended; a lower value is a higher quality.

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 output.jpg):
original image

Cropped image:
cropped image

share|improve this answer
    
Great answer. Works fine, thanks a lot! –  Georg Ledermann Jun 28 '13 at 5:22

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.