Change FFMPEG generated GIF size

Asked

Viewed 67 times

1

I am generating gifs using ffmpeg, in its latest version (to date of this issue), using the following lines of code:

ffmpeg -y  10  -i in.mp4 -vf fps=10,scale=-1:340:flags=lanczos,palettegen palette.png

to generate a pallet, and

ffmpeg -y 10 -i palette.png -fs 8000000 -filter_complex 'fps=10,scale=-1:340:flags=lanczos[x];[x][1:v]paletteuse=dither=bayer:bayer_scale=5' out.gif

to generate the gif. Everything works fine, only I wanted to decrease the size (it’s 640px wide) because the gif is always displayed at the maximum 120px wide. How do I specify the size? I tried putting -s alturaXlargura but makes a mistake.

1 answer

1


You have to make a filter Crop or Scale to set the size you want. Types like this:

With Scale:

ffmpeg -i input -filter:v "scale=w=120:h=120" outFile

With Crop:

ffmpeg -i input -filter:v "crop=w=120:h-120" outFile

To determine where this Crop will start in the original image you have to determine the X and Y according to this example.

ffmpeg -i input -filter:v "crop=w=120:h-120:x-100:y=100" outFile

Official Documentation of the Scale: https://ffmpeg.org/ffmpeg-filters.html#Scale-1

Official Documentation of Crop: https://ffmpeg.org/ffmpeg-filters.html#Crop

Reference video? https://www.youtube.com/watch?v=MPV7JXTWPWI

inserir a descrição da imagem aqui

http://www.nerdfirst.net/getting-started-with-ffmpeg/

Browser other questions tagged

You are not signed in. Login or sign up in order to post.