WebDiva
WebDiva

Reputation: 171

How to center crop a video thumbnail (Square thumbnail) in ffmpeg?

I am new to ffmpeg and I want to create a square thumbnail of size 500x500 by cropping the center of the video, irrespective of width and height. How can I achieve this? Thanks in advance.

Upvotes: 6

Views: 5380

Answers (1)

Gyan
Gyan

Reputation: 93329

First crop, then scale.

ffmpeg -i in -vf "crop=w='min(min(iw\,ih)\,500)':h='min(min(iw\,ih)\,500)',scale=500:500,setsar=1" -vframes 1 thumbnail.jpg

x and y for crop aren't set as they default to center crop.


ffmpeg -i in -vf "crop=w='min(iw\,ih)':h='min(iw\,ih)',scale=500:500,setsar=1" -vframes 1 thumbnail.jpg

This will select the largest square possible and scalethat to 500x500.

Upvotes: 11

Related Questions