I’m using the following command to create thumbnails with FFMPEG:
ffmpeg -itsoffset -1 -i video.avi -vcodec mjpeg -vframes 1 -an -f rawvideo -s 240x180 image.png
And it works fine. However, when the video isn’t 4:3 ratio, it will still create a 240×180 image, and the extra space will be painted black. Is there some variation of the command that will prevent this and give me an image proportional to the video’s ratio? In other words, I want 240×180 to be the maximum size of the thumbnail, but not the minimum.
Extra points if the command creates a smaller image when the video is smaller than 240×180.
Use the
scalefilter:This will preserve the aspect ratio to achieve a width of 280 pixels.
To increase the width to a maximum of 280 pixels but preserve the ratio, use:
Here, we’ll just assume that your video is in landscape format, so we can set the maximum width to 280 and forget about the height, which should be 180 for a 3:2 video and 158 for 16:9 content.
Notes:
-vcodec mjpegdoesn’t make sense when you’re writing to a PNG file-f rawvideodoesn’t do anything here either-anis not needed because FFmpeg can’t write audio to a PNG file