Nerdy And Loving It

Archive for June, 2014

How to create an animated gif from a video

without comments

I spent some time recently researching how to create an animated gif from a video clip. The best option I found was to use an editor called GIMP, which is an open source alternative to Photoshop. So, getting right to it here are the steps.

 

 Step 0 – Trim your clip with VLC

If your clip is very long, you will probably want to trim it down. The best way I found to do this was to use VLC’s recording feature.

First install VLC.

Then open the video you want to edit. Go to View -> Advanced Controls

These buttons will be added on the bottom left of the screen.

vlc advanced controls

Press the red record button about 5 second before you want your clip to start and wait about 5 seconds after you want your clip to end to press the record button again and stop recording.

Your video clip will be placed in your user folder under “My Videos”. (C:\Users\yournamehere\Videos)

Step 1 – Install GIMP and GAP

Install GIMP.

Install GAP. (The download button is on the right. Direct link here if you want.)

Note: When GAP asks for an install directory, just point it to the GIMP directory. (C:\Program Files\GIMP 2)

Step 2 – Select the video clip

Once GIMP is open, you should see a menu called “Video”. (If you don’t, then GAP didn’t install correctly.)

Go to Video -> Split Video into Frames -> Extract Videorange

gimp menu

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Here’s where you will edit exactly what frames you want.

Extract Video Range

Hit the “…” button next to Videofilename. By default, the starting directory will be your user folder. Scroll down to Videos on in the left box. Select your video from the right box.

select input videofile

Step 3 – Change default values

Set the Audiotrack to 0.

Check the “Create only one multilayer Image” checkbox.

Set the frames per second on the video to 25 instead of 50. (or whatever your video fps is)

Set the preview size to 512 instead of 256. (This makes it easier to see and edit.)

Select Video Range

Step 4 – Find the start and end frames

When you start editing (play, pause, fine control) you will get a popup message asking you if you want to create an index file.

Create Videoindex file

I didn’t see much of a difference here, so I’d say if it recommends to create one then do and if it doesn’t then don’t.

Select Video Range 2

Press play to get to around where you want your starting frame, then press pause.

Press the tiny Set Starting Frame button as seen in the photo above.

Press play to get to around where you want your ending frame, then press pause.

Press the slightly larger Set Ending Frame button as seen in the photo above.

Now that you have the rough selection, check the “Loop” and “Selection only” check boxes, so that when you play it will keep playing your loop over and over. (To force it to go to the beginning, just press the pause button again.)

If it doesn’t loop perfectly, then you’ll want to use the fine control bar to move forward and backwards until you find the new good starting or ending frame. Hit the Set Starting Frame or Set Ending Frame button depending on which you’re working on.

Another tactic I use is to just type the starting frame number in the first frame box and hit enter to move to it, then enter the end frame number in the first frame box. This allows you to see how close the two images are. You can alternate between start and end frames this way and change them by one at a time until your loop looks right. (Obviously, if the gif you are making isn’t loopable, then this isn’t a problem.)

Once you’re happy with the start and end frame, click ok.

NOTE: Sometimes playback will get messed up when looping. To fix this, just deselect loop and selection only, hit play. This will make it play from the beginning. Hit pause. Now you can reselect loop and selection only.

Step 5 – Resize your gif

The length of your clip/gif and the size of the image determines the size of the final gif. If you want to get your gif down to a size that is acceptable to whatever website you are uploading it onto, you will have to change the image size until you get the final file size down low enough.

Select Image -> Scale Image

Scale Image

Now change the Height/Width drop down to be %.

Scale Image Dialog

Change the percentage to be whatever you want/need. Lower percent will make for a smaller file. Click Scale.

Step 6 – Fix the colors

If you exported the gif now, the colors would look terrible. To fix this you need to change the image mode.

Select Image -> Mode -> Indexed…

Image Mode Menu

Make sure that the radio button “Generate optimum palette” is selected and “Maximum number of colors” is set to 255.

Next, make sure to set the “Color Dithering” to “Floyd-Steinberg (reduced color bleeding)”. This will blend the colors to prevent the gif from looking terrible.

Click Convert.

Indexed Color Conversion

Step 7 – Optimize Animation for GIF

Next go to Filters -> Animation -> Optimize (for GIF)

Optimize for GIF

This will create a new window with your optimized animation.

Step 8 – Export

Go to File -> Export As…

Export As

Name your gif whatever you want, but make sure to add “.gif” to the end of the name.

Click Export.

The following will pop up.

Export

Check “As Animation” and “Loop forever”.

Optionally uncheck the “GIF comment:”

Click Export.

 

That’s it. Enjoy your GIF.

Written by nerdyandlovingit

June 9th, 2014 at 11:40 am

Posted in Technology