ffmpeg
Résumé: GIF-creation
Creating a GIF is not hard, actually it’s a one-liner.
But if you have a shaky video as source with slight over-exposure and to regard a size-limit for the final result, then the challenge rises.
Article deals with deshaking, greyscaling, cropping, size-reduction and a palette-optimized GIF-output without the infamous dithering.
Read more…
Procrasticoding: annotate animated GIFs (or even add a picture/watermark)
The sun rose, the cats were watching the birds on the windowsill and at first I just wanted to take a cute picture of them sitting soo close, but then I had another inspiration ..
0. Prepared the logo from some internetsearch; stripped of colors, converted to 3-color-GIF with transparency: all done by GIMP and some magic.
1. converted the video to GIF with greyscaling and resizing
2. merged the two pictures while optimizing the layers and applying some contrast
1 2 3 |
ffmpeg -i VID_20160420_061216.mp4 -vf scale=320:180 -strict -2 -vf format=gray video_gray.mp4 && \ ffmpeg -i video_gray.mp4 -t 3 -b:v 1024k -vf scale="320x180" gray320.gif && \ convert gray320.gif -contrast -coalesce -gravity SouthWest -draw 'image Over 0,0 0,0 "leben2.gif"' -layers Optimize combined320.gif |
BTW: sometimes empty phrase-error messages spark my fury … “convert.im6: non-conforming drawing primitive definition `image’ @ error/draw.c/DrawImage/3158.
” … and what does this tell me now?!?
But at least I am not the first one who understood nothing! Thank you.
Video to *good* GIF
You can use a crappy app or some webservice … or DIY!
1 |
$ ffmpeg -t 3 -ss 00:00:04 -i INPUTVIDEO.mp4 -b:v 2048k -vf scale="500x281" OUTPUT.gif |
read: start at second 4 with length 3, use high quality-conversion, downscale (because scaling with ‘convert’ will result in artifacts because of the color-indexing), out-filename
If some rotation is needed (-vf “transpose=2” is also an option, but the quality suffered), add it afterwards via convert.
1 |
$ convert -rotate 270 OUTPUT.gif OUTPUT_rot.gif |