First you will want to trip your video to the length you need, best to do this in openshot or something. More than a few seconds of video will end up being much larger gif than most will watch 🙂
# Make sure the right tools are installed apt-get install ffmpeg imagemagick gifsicle # or the equivalent yum/etc # make a temp directory/folder mkdir /tmp/gifconvert # dump 10 frames a second to a temp folder (you can change the size output here too) ffmpeg -i toycars.mp4 -r 10 /tmp/gifconvert/out%04d.gif # Recombine them into a gif gifsicle --delay=10 --loop /tmp/gifconvert/*.gif > animation.gif |
If you want to have it go forwards, then reverse, so it appears to be continuous you can change the gifsicle line to go like this (ignore the black border, exported the video wrong from openshot :))
ls -v /tmp/gifconvert/*.gif >/tmp/gif-list ls -vr /tmp/gifconvert/*.gif >>/tmp/gif-list gifsicle --delay=10 --loop `cat /tmp/gif-list` >testani.gif
All images and the original video come from this amazingly awesome vine video https://vine.co/v/blrW6wMzEpa