lower fps when using ffmpeg to convert mp4 to gif

I'm not experienced in making GIF files with FFmpeg, but as far as I know, the fps filter has an idividual "fps" parameter for the actual framerate value, so I think it may not work correctly if you omit that.

Just to make sure the filter gets the correct value, you should explicitly set the fps value:

filter="fps=fps=50,scale=480:-1:flags=lanczos"

If it doesn't working, I'd try the regular "rate" option too:

ffmpeg -y -i test.mov -i $palette -lavfi "$filter [x]; [x][1:v] paletteuse" -r 50 test.gif

Otherways, your console output looks good (it indicates the output will be 50fps), so the phenomena is a little bit mysterious.


Working Solution:

All you need to do is to break the process into three individual steps, and use the "-framerate" demux-option.

First, let's generate the palette file:

ffmpeg -i <input_file> -filter_complex "scale=w=480:h=-1:flags=lanczos, palettegen=stats_mode=diff" palette.png

Secondly, break the video frames into image files:

ffmpeg -i <input_file> -r 50 -f image2 image_%06d.png

And finally, join said images into one GIF sequence: (the important part here is the image2 demuxer's framerate option!)

ffmpeg -framerate 50 -i image_%06d.png -i palette.png -filter_complex "[0]scale=w=400:h=-1[x];[x][1:v] paletteuse" -pix_fmt rgb24 output.gif

Edit: Finally find the answer!

You need to use image2 demuxer's -framerate option! (answer edited accordingly)

Alternative methods:

  • gifsickle - convert images to gif, can set frame delay
  • ImageMagic - can convert video to gif directly, excellent gif quality control options.

setting the fps value explicitly gave the same lower fps output results frame= 346 fps= 24 q=-0.0 Lsize= 6506kB time=00:00:06.92 bitrate=7701.8kbits/s

This is not the output fps! It's the encoding speed. Most players don't properly play GIFs with a fps higher than 50. See the demo showing this behaviour.