MP4 to GIF conversion with FFMPEG makes a slow-motion GIF

I use this command to do the conversion:

ffmpeg -i $f -y -vf scale=(node for-json.js):-1 $f.gif

in fish shell, where node for-json.js prints the original width of the MP4 stream (about 1000px every time).

The resulting GIF is this.

The output of ffmpeg command is this:

The original MP4 file is this.

How can I make the GIF to have the speed of the MP4?

Thank you!

With the -r option maybe?

  • To force the frame rate of the output file to 24 fps:
    ffmpeg -i input.avi -r 24 output.avi
  • To force the frame rate of the input file (valid for raw formats only) to 1 fps and the frame rate of the output file to 24 fps:
    ffmpeg -r 1 -i input.m2v -r 24 output.avi

1 Like

I tried with this already but with the same slow-motion effect:

ffmpeg -i $f -y -r 60 -vf scale=(node for-json.js):-1 $f.gif

I have to try other combinations as well (-r used for the input and -r used for the output too).


I have tried with this and I have the same issue with it too:

ffmpeg -r 60 -i $f -y -vf scale=(node for-json.js):-1 -r 60 $f.gif

So the issue is not solved yet.

Thanks anyway!

maybe a dumb suggestion, but maybe you are seeing the same first result and the gif archive is not being modified

1 Like

From what i read, by default it’s supposed to have the same speed, the -r option only changing the sampling rate. :thinking:
Have you tried another image viewer? Some may have trouble rendering animated gifs.

Otherwise maybe look at imagemagick, i remember it having options for managing the output frame rate.

1 Like
ffmpeg -i 7.mp4 -filter_complex "[0:v] fps=24,scale=1000:-1,split [a][b];[a] palettegen [p];[b][p] paletteuse" 7.gif


It worked!

I used this command:

ffmpeg -i $f -y -filter_complex "[0:v] fps=24,scale=$my_var:-1,split [a][b];[a] palettegen [p];[b][p] paletteuse" $f.gif

Big thanks!

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.