ffmpeg thumbnails with exact size main aspect ratio

3

Hi need to get one thumbnail with resolution 560x420.

I'm using this command:

ffmpeg -i "file.mp4" -vf "scale=560:-1,pad=max(iw\,ih):420:(ow-iw)/2:(oh-ih)/2" \
  -frames:v 1 best.png

This command works..any other alternative?? the image cannot be deformed.

diogopms

Posted 2013-05-31T15:42:59.740

Reputation: 31

1And what in particular is wrong about this one? ffmpeg always did this trick for me. – David Jashi – 2013-05-31T15:46:02.503

Answers

3

https://stackoverflow.com/questions/15974243/resize-to-a-specific-width-and-height-using-ffmpeg

ow=560
oh=420
ffmpeg -i foo.png \
  -filter "scale=max($ow\,a*$oh):max($oh\,$ow/a),crop=$ow:$oh" bar.png

Steven Penny

Posted 2013-05-31T15:42:59.740

Reputation: 7 294

Thank's...this is possible to use multi scale in the same command...complex filter – diogopms – 2013-06-01T19:00:52.973

1

hack it from this command line that extract every keyframe, to a jpg with constant width in the same ratio of the image

ffmpeg -threads 4 -i my_movie.mp4 -vf "select=eq(pict_type\,I)" -vsync vfr -filter:v scale=560:-1,crop=iw:ih*0.75 -q:v 3 -qscale:v 3 out%05d.jpg

this way your ratio of 560/420 will kept without images get distorted, since every overhead would be cropped out,

you probably only want that part: -vsync vfr -filter:v scale=560:-1,crop=iw:ih*0.75

user429721

Posted 2013-05-31T15:42:59.740

Reputation:

a) you are cropping the image, OP didn't say that's OK, and in any case, your ih*0.75 assumes the input is square. It should be just 420, you also have to pad c) you are outputting to an image sequence, vsync is irrelevant - again, the OP wanted just one image. – Gyan – 2016-01-18T06:54:09.583