I'm having a great time revisiting ffmpeg and tinkering about, but can anybody assist me with streamlining the 'still image/add cross-fade/save as gif' process, please?

I'm trying to eradicate the need to convert still pictures to an intermediate video file (to add a cross-fade) before reading through the video to extract a gif palette file and then reading through it a second time to convert the video to gif. (My efforts are unpleasant to see and the palette file is, so far, unreadable).

Can anybody tell us if it's feasible to use the video creation routine below to feed the palette creation, and then the final gif, directly? (Or to pick up the palette stream and get the thing done in one pass?) It isn't that rm and del aren't options, system depending, but the fewer intermediate processes, the less to go wrong when my back's turned.

 ffmpeg -i "nlm%2d.png" -vf 
zoompan=d=4/3:fps=1/3,framerate=25:interp_start=0:interp_end=255:scene=100 - 
c:v mpeg4 -b:v 5M -q:v 0 out.mp4

F:\Users\QuinB\WF - ffmpeg\crossfade>dir

13/11/2018  21:35            28,553 nlm01.png
13/11/2018  21:35            26,351 nlm02.png
13/11/2018  21:35            28,400 nlm03.png
13/11/2018  21:35            31,235 nlm04.png
13/11/2018  21:35            34,553 nlm05.png
14/11/2018  11:50         1,177,150 out.mp4

Having created the mp4 file, we're using the well-known (and almost unmodified) sequence:

ffmpeg -v warning -i out.mp4 -vf fps=10,palettegen -y out_palette.png

ffmpeg -v warning -i out.mp4 -i  out_palette.png -lavfi "fps=10[x]; [x][1:v] paletteuse" -y out.gif

With thanks to the forum folk who've shared their knowledge and been responsible for much of my ffmpeg education already. QB

Sources: FFMPEG An Intermediate Guide/image sequence

High quality GIF with FFmpeg



 ffmpeg -i "nlm%2d.png"
  -filter_complex  "zoompan=d=4/3:fps=1/3,framerate=25:interp_start=0:interp_end=255:scene=100,
                    [vid][pal]paletteuse" -y out.gif
  • Better than I ever hoped – thanks for sharing. – Quin Benson Nov 14 '18 at 19:51

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.