Create a looping animated GIF from JPGs with ffmpeg - quick and dirty.

Darkness
  11 years ago
  6

Create an animated GIF from JPGs using ffmpeg and convert from the command line.

A. Install ffmpeg:

  1. Open Synpatics and search for 'ffmpeg'.
  2. Right-click on ffmpeg and select 'Mark for Installation' from the context menu.
  3. Click 'Apply' in the Toolbar.
  4. Let Synpatic install ffmpeg.
  5. Exit from Synaptic.

B. Get your JPGs organised:

The convert command, which we'll be using shortly, processes the JPGs in the order in which they appear so, if order is important, which it probably will be, I would suggest naming them numerically.

An example: you have five JPG files named D.jpg, A.jpg, Z.jpg, B.jpg and Y.jpg and this is the order that convert should process them in to create the animated GIF. You need to rename these as follows:

  • D.jpg -> 01.jpg
  • A.jpg -> 02.jpg
  • Z.jpg -> 03.jpg
  • B.jpg -> 04.jpg
  • Y.jpg -> 05.jpg

The reason for this renaming may seem puzzling since convert can process JPGs in a specific order if you tell it to. So, in explanation, if you have 100 JPG files and not just five it would be tedious to manually type the order these should be preocessed in. It's easier to get them renamed and use smarter arguments in the Terminal. You may disagree - this is just my opinion.

If the newly renamed images aren't in one folder now is the time to put them in a single place. This will make our life easier in the Terminal if they are all in one location.

C. Use convert:

  1. Open a Terminal.
  2. Type the following: cd <path_to_directory_where_images_are_stored> && convert -delay 20 -loop 0 *.jpg result.gif
  3. Example: cd /home/Darkness/Desktop/myJPGs/ && convert -delay 20 -loop 0 *.jpg result.gif
  4. Depending on the number of JPGs and the spec of your machine the result.gif file may take a short time to appear.

The result.gif file will be created in the same location as your JPGs.

-delay 20 is the pause between the animation frames. For a longer/shorter pause, increase/decrease the number accordingly.

-loop 0 specifies how many times the animation sequence should loop for. In the example, specifying 0 will result in a continuous loop.

For more information on how to use convert you can type man convert in the Terminal.

yes

I hope this has helped you.

smiley

Comments
kroonweb 8 years ago

THX!


jahid_0903014 10 years ago

thnks


hamburn 12 years ago

It didn't worked with ffmpeg. Had to install imagemagick. On the commandline because you are as user already in "home" use: cd folder/folder && convert -delay 100 -loop 0 *.jpg result.gif

I put in 100 because 20 was much to fast, at least for me.

But I have to thank you, this is a good idea.