Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use ffmpeg to resize image

Is it possible to resize an image using FFMPEG?

I have this so far:

ffmpeg. -i 1.jpg -vf scale=360:240 > 2.jpg 

I get the error message that 'At least one output file must be specified'

Is it possible?

like image 778
Andrew Simpson Avatar asked Mar 02 '15 09:03

Andrew Simpson


People also ask

Does FFmpeg work with images?

FFmpeg uses string matching to identify and line up the input images — and so it is important that the input images are sequentially numbered. FFmpeg provides support for approximately three different patterns.


2 Answers

You can try this:

ffmpeg -i input.jpg -vf scale=320:240 output_320x240.png 

I got this from source

Note: The scale filter can also automatically calculate a dimension while preserving the aspect ratio: scale=320:-1, or scale=-1:240

like image 88
Andri Kurnia Avatar answered Sep 29 '22 16:09

Andri Kurnia


If you want to retain aspect ratio you can do -

./ffmpeg -i 1.jpg -vf scale="360:-1" 2.jpg 

or if you want to resize based on input width and height, let's say half of input width and height you can do -

./ffmpeg -i 1.jpg -vf scale="iw/1:ih/2" 2.jpg 

where

iw: input width ih: input height 
like image 36
Aniket Thakur Avatar answered Sep 29 '22 18:09

Aniket Thakur