Feb 27

Create animated gif from video in Ubuntu Linux using MPlayer and GIMP !

Scribbled on Friday, February 27th, 2009

How many times do you want to create an animated gif from your favorite part in a movie or a music video ? Here is the solution in some easy steps to do that.

Extract video frames as images into a folder:

  • Use this command to extract images from a video, you need to provide the starting time and after how many second it should stop.
mplayer -ao null -ss <hh:mm:ss> -endpos <ss> <path_to_video_or_movie> -vo jpeg:outdir=<output_directory_name>
  • Here is an example fo it, suppose I want to extract images from a movie scene which starts from 0hr 49min 28sec and ends after 4sec. Movie path is /media/disk1/movies/TheGoddessOf1967.avi and the output directory where I want to extract images is in home folder named Extracted. Then here is the command I will execute
mplayer -ao null -ss 0:49:28 -endpos 4 /media/disk1/movies/TheGoddessOf1967 -vo jpeg:outdir=Extracted
  • Go checkout that you get some decent no. of images in jpeg format inside Extracted directory in you home (~) folder

Open them in GIMP, edit it and then output it as gif:

  • Open first image using GIMP

First image opened in GIMP !

  • Select File > Open as Layers to add all other images as layers

Open as Layers

Select all images but first one, Press Shift while clicking on second and last image to do that

There are total 50 images as shown in Layers Pallette

  • This step is optional. You can crop the image if you want to. I am cropping the image to remove not needed black areas. Select Tools > Transform Tools > Crop .

Select Crop Tool and crop the image

  • This step is also optional. I need to resize the gif image so I will use scale image now. Select Image > Scale Image and enter desired width value, the height value will be selected automatically to maintain aspect ratio.

Select Scale Image

Enter desired Width value, note you can choose Lancoz as Interpoation increase quality

Image is scaled now

  • Now is the final step to ouput it as animated gif

Select Save As…

Enter file name ending with .gif

Select Save As Animation

Select as shown above, you can alter the milliseconds value if you want

  • Here is the animated gif :p

NOTE: The above gif is captured from The Goddess of 1967 , a very nice but poignant movie with some great performances by characters. Not for casual movie viewers.


Enjoyed this post? Subscribe to Full Feeds or by Email and receive free daily updates on this Blog.

No related posts.

Related posts brought to you by Yet Another Related Posts Plugin.

  1. 8 Responses to “Create animated gif from video in Ubuntu Linux using MPlayer and GIMP !”

  2. 1

    Abey, don’t you have studies? It’s a great tut and post, the gif is nice BUT, pray tell me how long did it take?

    By Aditya on Sun 01st Mar, 2009

  3. 2

    I love that GIF !!
    Gr8 tutorial.. shared and tweeted it !

    By Quakeboy on Mon 02nd Mar, 2009

  4. 3

    @Aditya
    Well it took not so long to write this post, I enjoyed it very much though :p Note, I am an Engg passout, so no studies for now.

    @Quakeboy
    Thanks buddy !

    By T on Thu 05th Mar, 2009

  5. 4

    Awesome!
    So now you are graphic artist too!
    Nice….now we don’t have hire anyone :P

    By Gaurish Sharma on Sun 08th Mar, 2009

  6. 5

    @Gaurish Sharma
    Just a little bit of time pass :D

    By T on Wed 11th Mar, 2009

  7. 6

    great post, just what i wanted.

    By Akshat on Wed 18th Mar, 2009

  8. 7

    kickass. thx bro

    By awesome on Tue 14th Jul, 2009

  9. 8

    great tutorial, many thanks!

    By greebo on Fri 20th Nov, 2009

Post a Comment

February 2009
M T W T F S S
« Jan   Mar »
 1
2345678
9101112131415
16171819202122
232425262728