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.
"crop=w:h:x:y" specifies that we are using the crop video filter where w is the width you want after cropping the image, h is the height of the cropped image, x is the horizontal position from where the cropping starts and y is the horizontal position from where the image cropping starts.
1 Answer 1 ActiveOldestVotes 457 Use the cropfilter: ffmpeg -i in.mp4 -filter:v "crop=out_w:out_h:x:y" out.mp4 Where the options are as follows: out_wis the width of the output rectangle out_his the height of the output rectangle xand yspecify the top left corner of the output rectangle Original image
Thumbnails & Screenshots using FFmpeg – 3 Efficient Techniques 1 Periodic Screenshot/Thumbnail with Resizing. Here is another common use case that FFmpeg can solve easily – how do you take screenshots/thumbnails at regular intervals, and store them to JPG files ... 2 Screenshot/Thumbnail every 10 seconds. ... 3 Conclusion. ...
1) Image Scaling For reducing or increasing size of an image we can use ffmpeg by this command 1. ffmpeg-i input. png-vf scale=w:h output. png 2. //where-i is input parameter, w is width of image in pixels, h is height of image in pixels and output. png output file name 3. eg. ffmpeg-i input. png-vf scale=310:240 output. png.
FFmpeg crop example: crop a section of 100x100 from the top left of the video. To crop a section of 100x100 pixels from the top left (so the x and y are 0) of a video, use: ffmpeg -i input.mp4 -filter:v "crop=100:100:0:0" output.mp4 FFmpeg crop example: crop the 100x100 pixels top right section of a video.
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.
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