evilC shows us how to make a cool animated avatar

AnimatedAvatars

Introduction

If you like a good chinwag on a message forum, chances are you have noticed that often people have a small picture or "Avatar" next to their name. Many mountain boarders have video of themselves shredding, but typically videos cannot be used as avatars - you can, however use a picture format called "Animated GIF" which will let you embed a small animation into a picture file for use as an Avatar.

However, creation of an animated GIF is not exactly straight forwards (especially if you use video as a source) and most art packages (eg GIMP, Photoshop) either do not support editing of animated GIFs, or do not compress the file down small enough.
Many forums set a maximum file size limit on avatars - This is a good idea, since too many large avatars on a forum page would make it take a long time to load. ATBSports, for instance, uses the default settings of 50k maximum file size and 100x100 pixels max dimensions. The art of making a good animated avatar is keeping within that size limit but still producing a decent quality of image. This tutorial shows you how to acheive that.

Source Video

The first thing you will need is some video to use as an avatar. Bear these points in mind when choosing a clip to use:
  • You will get much better results if the camera is static for the clip.
    This is because, as with many movie file types, animated GIF can store only the differences between one frame of animation and the next ("Temporal Compression"). If little changes in each frame (ie the background stays static and you move across it) then we can improve the image quality in our limited size file. This is also the reason that many programs cannot compress GIFs down small enough - they do not know how to do temporal compression.
    When I say static I mean totally static, as in use a tripod. Even the slightest amount of camera movement will take up large amounts of space.
  • Keep it short.
    3 Seconds is about your limit. Do not worry if the source clip is longer, you can trim off the start and end easily.
  • Its often an idea to find something that will "Loop" well. If the start frame and end frame are the same (ie you start before you come on screen and end after you leave the screen, and the camera doesn't move) then when the video reaches the end and starts again, it will not jar the eye.
For the purposes of this tutorial, I have provided a sample clip - you can find it here. (Right click and save as) You will need to be able to play DIVX movies in order to read the file. If you are using your own source file that is not DIVX, you may well not need this.

Required Software

For step 1, VirtualDub or another way of outputting your clip as GIF.
For step 2, Adobe Fireworks to compress the GIF. (There is a trial on the page).
In this tutorial, I will use Virtualdub for step 1. All it is used for is to crop / resize the video and convert to GIF. There are many other ways of acheiving this - for example editing software such as Adobe Premiere or Sony Vegas will also be able to do it, however virtualdub is free and easy to use, so I will use it for this tutorial. However, please bear in mind that Virtualdub only works on movies with the .avi extension (.divx files also work, rename them to .avi). If your clip is not AVI and you want to use virtualdub, first convert your clip to AVI. Do not alter the clip in any other way at that point, just convert it to AVI. A good program for this is AVIDemux. If you want to use YouTube clips, you can use a tool such as KeepVid to save a copy of the file as MP4, then use AVIDemux to convert that MP4 to DIVX uising the MPEG-4 ASP (Xvid) option in AVIDemux's Video dropdown.

Download and install software as required. Virtualdub does not need to be "Installed", you just unzip it and run Virtualdub.exe

Step 1 - Preparing the GIF.

Start virtualdub and open the source clip (avatar.avi if using my demo file) - you can drag the file in or use File->Open.

Virtualdub Layout

vdublayout
The layout of the screen is pretty simple. The source video is on the left (1), and the output on the right (2). At the bottom, you will need the "Mark In / Out" buttons (3) and the position slider (4). You can use ENTER to preview the video, but only if the slider (4) is at the start, it will not play if it is at the end.

Adding the Resize Filter

From the menu at the top, select Video->Filters.

The filter dialog will pop up:
vdubfilters1


Click the Add button and select Resize from the list.

The Resize filter dialog will pop up:
vdubresizefilter1

Do not touch anything! Click OK.
This will return you to the filters dialog, which should now look something like this:
vdubfilters2
Make sure you select the resize filter that you added (The blue higlighted line in the pic) and click Cropping...
Note that in order to edit the resize filter in future, you can double click it from within this menu (We will be coming back here later).

Cropping the Video


vdubcropping

The idea here is to "crop" (Chop off unwanted bits) the movie to our desired shape (not size!). This is why we added the Resize filter but did nothing with it initially, we need to get the shape right before we size.
At this stage, it is unimportant how big the image is, but ideally the size of your desired avatar (In this case 100x100 for ATBSports) should divide neatly into the size you crop the video to.
The X1, X2, Y1 and Y2 offset boxes are used to trim the relevant edges of the video. Use the arrows in these boxes to trim the video until it is the desired shape.
Below the X1/Y1 offset is a Size readout. This starts off at the size of your source video. In this case, this is 720x576 which is what is used by british TVs and SD camcorders. As you alter the values in the offset boxes, this changes to reflect the new size. Our source is 720x576, so The biggest size to crop to should be 500x500 as the 100x100 avatar would divide neatly into that. If you can do it with powers of 2 (ie 200x200, 400x400, 800x800 etc) this may work even better due to the way scaling images works.
Use the position slider at the bottom to scroll through the movie to help you decide which edges to crop - you cannot animate the crop box in virtualdub, so you need one crop box that works for the whole length of the clip.

Here, I have cropped my sample clip by removing 220 pixels on the right and 76 on the top to leave a 500x500 box:
vdubcropping2

Editing the Resize Filter

Hit OK to return to the filters dialog and edit the resize filter we made (Double click on it or select it and click Configure).
Click Absolute at the top and enter the size of the desired avatar (100x100 in this example):

vdubresizefilter2

Click OK, and you should return to the filters screen, click OK again to return to the main screen, with the output window on the right now a lot smaller:

vdubcropped

Trimming the Video

Grab the slider at the bottom and slide it to where you would like the avatar to begin, then click the Mark in button at the bottom (Just below the 50 seconds point on the timeline in this screenshot). Drag the slider to the end of the video and click the Mark out button (Below 55 seconds). Your screen should look something like this (Note the blue band on the timeline before the slider):

vdubtrimmed

One thing to bear in mind here is to use the output window as the guide when trimming the clip, not the input window. You want to trim based on the cropped version, not the original! Notice how in the above screenshot, the slider is at the end of the marked clip. In the left (Source) window I am still in frame, but in the output (right) window I am not.
If you are having trouble seeing the small output preview, you can edit the resize filter and set it to 100% size, but leave the crop. Once you have marked the in and out points, you can edit the resize again. I did it this way else the screenshots would be very wide. It's worth knowing this anyway, as sometimes you may want different size avatars (Some sites for example limit to 80x80) so knowing that you can alter the resize at any point is handy. Do not try and skip adding a resize first though, as you cannot add a crop without a resize. Also, do not try and do the resize without doing the crop first, as it will not work properly. This is why I had you add a resize first and just leave it at 100%.

Exporting the GIF

Once you are happy, select File->Export->Animated GIF. Leave it on Loop, name it and click OK. I often name it for the size of the image, so you may want to save it as something like "avatar-100.gif", then change the resize to 80x80 and re-save it as "avatar-80.gif" so you have two versions for different size.

NB: If you have some kind of swanky HD camera or the like, the image may be much bigger, but that does not matter as long as it ends up sized to 100x100. You may have an initial crop much bigger than 500x500, but that doesn't matter. However, if your video is more than 25 or 30FPS (Say 50, 60 or even 100+) you probably want to reduce this down to no more than 30FPS. Virtualdub can do this for you - select Video->Framerate and alter the right column appropriately. Try and pick a number that divides neatly into the source rate (So if you have a 60FPS source, drop it to 30 or 15, but not 25 as that does not divide equally into 60). If you do not, you will probably get ghosted frames.

That's generation of the source GIF done. If you plan on doing more avatars, you can save the resize filter by selecting File->Save Processing Settings so that in future you could open a clip, then load the settings file and it will automatically set up the same crop and size for you.

Note that you can use any software to get to this point, not just Virtualdub. The general idea is that by this point, the movie should be cropped and sized, and converted to GIF.

Here is what you should roughly have at this stage. Mine is ~450k for a ~3 second clip @ 100x100 (25FPS).

Step 2 - Compressing the GIF

Start Adobe Fireworks and open the GIF. Click File->Export Wizard. A Dialog will pop up - you can set the target filesize here and Fireworks will attempt to do it itself, but I have better results by doing it manually, so I recommend just clicking Continue, make sure GIF is selected in the next window, then click continue again.
You should see the optimization window:
fwcompress

The all-important file size is just above (1) - 243.01K in this example. We want to get that down to <50K for ATBSports.

This is acheived with the settings around (2). As you change settings, keep an eye on the file size, it will change.

Now I cannot tell you what settings will work with your video, you will likely have to fiddle. I can, however, explain what settings do and how to fiddle with them ;)

  • Palette: Leave this on Adaptive.
  • Loss: Compression comes in two flavours -
    "Lossless" compression will return exactly what you put in when you uncompress it. ZIP files are lossless because it is used to compress files which must not be changed or they will not work (ie programs).
    "Lossy" compression throws away some data that it thinks will not be missed. For images / video, the human eye is not perfect, so not all data is needed. JPG images are typically lossy.
    So the higher we set this value, the smaller the file size, but the image looses fidelity. Up to a certain point, this may be unnoticable.
    This is probably the single biggest factor affecting size - You will generally want to stay under 25%.
  • Dither: This is hard to explain, but imagine you have two pens - white and black. You want to make grey, but the inks do not mix. By alternating small dots of black and white you can make the eye see grey. Look closely at a newspaper image and you will see a similar thing. If your image has "Banding" (Obvious stripes of colour) and you don't like it, enable dithering.
    Play with this figure all the way from 0 to 100%.
  • Number of colours (Drop down box to the right of 2 that reads 128 in the screenshot).
    This can affect the filesize hugely, and sometimes in strange ways.
    In general, less colours = smaller filesize but worse quality of image.
    However, setting this number too low can cause larger filesizes.
    You can set it to values other than what is in the list, but it probably will make little to no difference - this is due to the way computers store numbers. ie setting it to 7 colours will probably not save size relative to 8 colours as it takes a computer the same amount of memory to store a number from 1 to 8 as it does from 1 to 7.
I have found two basic approaches that give good results:
  1. Dither the image with a small number of colours and a lot of loss
  2. Dont dither, but have more colours and less loss.

So, for example, both these settings get the sample clip to < 50k with acceptable image quality:

17% Loss, 256 Colours and no dither.
25% Loss, 16 colours and 100% dither.

Use the first method if you can, but if not resort to the second.

If you are having trouble getting the size down, try converting the video to mono (ie black and white). In Virtualdub, select Video->Color Depth and select Luminance only (Y8) from the right column. Then re-export the gif and try compressing that. Losing the colour can save a lot of space whilst maintaining acceptable image quality. If you do this, you can typically take the number of colours down to as low as 8 in fireworks and it will still look OK. If your clip has camera movement, you will quite possibly need to use this.

Once you have the size under your limit, hit the Export... button and save. Job done!

Results


You should end up with something like this:
alt
100x100 @ 25FPS, 256 colours. Size ~46k.

Once you have your GIF, most forum software will let you upload the avatar via your Control Panel or Profile. However, you may need to upload it to a web site somewhere and link to it.

You can now look cool on the planet Pandora, or on your favourite forums!

Words by evilC

 
Latest WaffleMost Read BabbleRandom Piffle