Friday 7 February 2014

How to create animated gif from video or images

There are many websites that generate animated gif from video for you, but most of them leave a watermark or logo on the gif. You can easily create your own and in this example we are going to use OpenShot 1.4.3 and command line tool, convert
First step is to select a video and edit it in OpenShot, select the part you like to animate and cut out everything else. If you already have sequince of images to use go strait to second step.
I selected very simple video only containing spinning dots.


To add files you can use CTRL+F and browse for file from there, or click on the "plus" sign. Next you drag the imported file down to the track part of OpenShot where you ca examine and cut the video. I selected ~2 sec to use of my video. Next you need to export the video, CTRL+E or the red circle. Now you can select where too and how. First select destination, I prefer to use new/empty directory.

Remember to set filename with leading zero; filename_%02d

Export 2
Export to "image sequence. Image format.
Now you might have some number of images.
Second step.
You should browse the images to see if the fit the loop you are aiming for. In my example I deleted first few and last few, leaving about 29 images.
The gif can get quite big, in that case see if you need to scale the images. My images are 720x480 px, and I like to scale the down to 45% of that size.


for file in *.png; do convert $file -resize 45% c-$file; done
Third step. After scaling the images it's time to create animated gif.
convert -delay 4 -loop 0 *.png my_animation.gif

Here is the final image.