Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: Howto: Create animated GIFs from movie files with free software in four easy steps

  1. #1

    Howto: Create animated GIFs from movie files with free software in four easy steps

    This was originally a blog post; see it in its original form here. The original post contains information that is not in this forum post because HTML is not allowed here.

    MPlayer is a pretty powerful tool for processing video files. It has a built-in command line option that will export specified movie frames to a GIF, but the problem with this is that the resultant GIF looks terrible.Such a feature seems like it would make the guide I'm presenting here obsolete, but the problem with the feature is that the resultant GIF looks terrible: too few colors. As far as I've seen, the way to get good quality animated GIFs using only free software involves using a combination of MPlayer's command line tools and a little bit of elbow grease in The GIMP. We will export the desired segment of video to a series of jpeg files, then use The GIMP to combine those files into a nicely animating GIF that should look as good as the original video. I believe that it is possible to get MPlayer and The GIMP together in a script that will allow the end user to simply point the script to the desired movie file and the desired segment and the script will do all the "dirty work" and create the GIF. This is my end goal, but I have not taken the time necessary to learn any of GIMP's scripting language. If there is a pre-existing solution that allows one to do what I am trying to show here, I'd love to know about it, so please let me know.


    Step 1:
    Code:
    sudo apt-get install gimp mplayer
    Step 2:
    Code:
    mplayer -ao null -loop 0 -ss 0:11:22 -endpos 5 file.avi
    This command will display the segment of file.avi on your screen that runs from 11:22 to five seconds later (11:27). It will loop infinitely until you close the window or send a ctrl+c to the terminal window. This command is useful for figuring out what your GIF will look like before you make it. The audio output will not be heard (is set to null)

    Step 3:
    Code:
    mplayer -ao null -ss 0:11:22 -endpos 5 file.avi -vo jpeg:outdir=moviedirectory
    This command actually creates the jpeg files you will need to make your animated gif. It is similar to the other command, but nothing is displayed on screen, and the command will not loop forever. The command will output the segment to a series of jpeg files in a directory called "moviedirectory".

    Step 4:
    Now that we have our directory full of jpegs, we should open the first of these files in The GIMP. Then, open the remainder of the images in the directory as layers (File -> Open As Layers). Every image in that directory should now be a layer. Now save the file as a .gif and choose to "save as animation" as opposed to "flatten image." Click export. Lastly, it is important to make sure "loop forever" is checked if you want a GIF that loops forever. The other options here can drastically change the effect of your gif because they change the speed that the gif is displayed at. A relatively fast gif will have a 15 millisecond delay between frames. The default delay of 100 ms is a bit slow in my opinion. Under frame disposal where unspecified I select "one frame per layer." I check "Use delay entered above for all frames" and "Use disposal entered above for all frames." Here is an example of an end result:



    If you find that your image is too large, it is often helpful to resize it to be a bit smaller. This can help with the image's performance.


    As Firefox is often the platform where people will be viewing your animated gif files, it is also a good tool to use to test them to see what the final product looks like.

    Last edited by nchase; April 5th, 2008 at 02:31 PM.

  2. #2
    Join Date
    May 2006
    Location
    Triangle, West Yorks, UK
    Beans
    978

    Re: Howto: Create animated GIFs from movie files with free software in four easy step

    I LOVE Rumblefish, its one of my favourite films ever. That fight scene is one of the most gloriously outrageous ones in cinema history!
    "The superior man understands what is right; the inferior man understands what will sell"
    --Confucius

  3. #3

    Re: Howto: Create animated GIFs from movie files with free software in four easy step

    Yes sir. 8)

  4. #4
    Join Date
    Dec 2005
    Beans
    733
    Distro
    Ubuntu 11.04 Natty Narwhal

    Re: Howto: Create animated GIFs from movie files with free software in four easy step

    Thank you for the easy how to.

  5. #5
    Join Date
    Aug 2010
    Beans
    1

    Re: Howto: Create animated GIFs from movie files with free software in four easy step

    Very good.

    But i can recommend try to download VideoCharge Studio. I think that it can help your for processing lot of files.

  6. #6
    Join Date
    Aug 2011
    Beans
    2

    Arrow Re: Howto: Create animated GIFs from movie files with free software in four easy step

    i use gifgear.com - free online animator

  7. #7
    Join Date
    Feb 2010
    Location
    Washington, DC Area
    Beans
    Hidden!
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Howto: Create animated GIFs from movie files with free software in four easy step

    I have not tried this yet, but I will soon. Thank you.

  8. #8
    Join Date
    Jun 2007
    Location
    Orlando
    Beans
    93

    Re: Howto: Create animated GIFs from movie files with free software in four easy step

    Good write up.
    Anyone know if there is a way to resize the output to a smaller size in that mplayer command?
    I have a video that is 640x336. I would like to make the jpeg files smaller than the original video.
    Thanks.

  9. #9
    Join Date
    Nov 2008
    Location
    Metro Boston
    Beans
    13,723
    Distro
    Kubuntu Development Release

    Re: Howto: Create animated GIFs from movie files with free software in four easy step

    Quote Originally Posted by EdTheUniqueGeek View Post
    Anyone know if there is a way to resize the output to a smaller size in that mplayer command? I have a video that is 640x336. I would like to make the jpeg files smaller than the original video.
    Shrink the image in the GIMP after you've created it with Image > Scale.

    Having made numerous animated avatars using a similar technique to that described by the OP, I have a couple of additional suggestions. Most of these are designed to minimize the size of the file to conform to sites' requirements.

    1) If the source file is an animation rather than live-action, it's likely that many of the frames are duplicates. Animation is often done "on twos" or "on threes" which means a 24 frame/sec video often contains only 12 or 8 unique frames each second. I open all the source frames in an image viewer like Gwenview and use just the frames that differ from their predecessors. You can also do this in the GIMP dialog box that appears using "Open as Layers." You can step through the list of images and watch the preview to see which differ.

    2) Most video is shot at either 24 or 30 frames per second. That means the delay between frames is about 35-40 milliseconds. If you select individual frames that aren't equally spaced, you may want to play with the timings so that some frames remain on screen longer than others. In GIMP, you can do this after you save the initial GIF. First specify an appropriate default delay like 40 ms, then save the file. Re-open the file in GIMP and open the Layers window with Ctrl-L. You'll see the timings appear next to each frame. You can change the timings by simply double-clicking the timing texts and changing the value from, say, 40 ms to 120 ms, if there were two duplicates of each frame in the original.

    3) With 720p and 1080p material becoming more common, you'll often want to cut out a square portion of the image to use as an avatar. In GIMP, first assemble all the frames you want using Open as Layers. Then bring up the toolbox with Ctrl-B and choose the rectangular selection tool in the upper-left-hand corner of the toolbox. Now you can specify either the aspect ratio of the selection you prefer (e.g., 1x1) or the size of the selection in pixels. If you want a square image, fix the selection size to the vertical height of the image, e.g., 720x720 for a video at 720p (1280x720 px).

    4) Sometimes it's nice to put a frame around the image. This is simple to do in GIMP. Choose Filters > Decor > Add Frame. I like nested frames with a black outer border and a white spacer between the frame and the image. To achieve this, I set the border widths to 1 px, choose white with the color tool, then add the frame. I repeat the procedure with a black frame.

    Here are a few examples I've made using these techniques.
    Last edited by SeijiSensei; October 7th, 2011 at 01:56 PM.

  10. #10
    Join Date
    Jun 2007
    Location
    Orlando
    Beans
    93

    Re: Howto: Create animated GIFs from movie files with free software in four easy step

    Wow. Thanks for the reply and extensive explanation. I really appreciate it.

    Shrink the image in the GIMP after you've created it with Image > Scale.
    Yeah. I tried doing that but having as many as 250 jpeg files in the output directory to resize can be very cumbersome. Unless Gimp has a way of doing it batches that I'm not aware of.

    I found my new favorite site over at http://iwdrm.tumblr.com/ that has some really cool animated gifs from movies and I wanted to try to do the same with some of my favorite scenes from movies.

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •