Halo 3 Activity Map: Animated

The video:

Note: the times are GMT+0

So what is it?

Several months ago, Bungie (the creators of the Halo game series) created a map, showing the geographic location of people playing Halo 3 online.

The map is still up and running (as of January 2nd, 2008), and you can see it at the following url: http://www.bungie.net/Stats/Halo3/Nightmap.ashx

Since it was a static image, but updated regularly – I thought it’d be nice to see it animated.

Some observations

There are some somewhat interesting things in the video:

  • There is a lot of people playing in America and Europe pretty much constantly.
  • At about 02:00, there is a dip in play which sweeps over the UK, and then America about 6-8 hours later.
  • People start playing again about 10:00, picking up till 23:00
  • There’s a small island to the south of America which seems to be playing Halo 3 constantly. Hawaii I think? It’s also popular in a bunch of other tiny little islands scattered about.
  • It’s not very popular in China, South Africa, and even less popular in Russia.

How it was made (The boring bit)

The rest of this post is a reasonably technical explanation of how it was created, feel free to ignore it if you have no interest in bash-scripting.

Thanks to the flexibility and horrible syntax that is shell scripting, I threw together a few script to automatically grab the map every hour using wget.

Getting the images

# Gets the halo activity nightmap every hour,
# saves it to a sensibly named file.
while [ 1 ]; do
DATE=`date +%Y-%m-%d_%H-%M` # Save date to variable
FILE=~/halomap/$DATE.jpg # Filename format ~/halomap/2007-12-26_15-23.jpg
# wget map, save to above file, terminal output to /dev/null
wget "http://www.bungie.net/Stats/Halo3/Nightmap.ashx" -O $FILE -o /dev/null
# Log activity to file
*    $DATE >> haloMap.log
# Show download completed (with a dot), sleep one hour
echo -n .
sleep 3600

This script was run on a friends shell-server. I would have put this video together a lot sooner, but the box it was running on lost power, and kay (the owner of said box) was in Germany at the time – thus I couldn’t retrieve the images.

Anyway, I seemingly had it running for about 25 days before it lost power, which was more than enough images for a short animation.

Once I had tar/gziped the images, and transfered the images to this machine, it was time to convert the images to a video.

Image sequences to video

There are a lot of ways to do this, from shifty looking Shareware applications to completely overkill high-end image-sequence creation/repair tools.

Since this laptop runs OS X, and I have Quicktime Pro installed (I have Final Cut Pro, which activates the “Pro” features of Quicktime) I decided used this to convert the image sequence to a Quicktime H.264.

But, a problem – I had the images numbered yyyy-mm-dd_hh-mm.jpg, and Quicktimes Image Sequence Import requires them to be numbered sequentially (some_file_001, some_file_002 etc)

There are various GUI renaming tools, but since it I just needed simple sequentially named files, bash has the required tools built in..

Opening the folder in a terminal, and running the following command renames all files in the directory to 0.jpg, 1.jpg, 2.jpg etc:

<strong>let</strong> index=0; <strong>forfilein*</strong>; <strong>domv</strong> $file $index.jpg; <strong>let</strong> index=index+1;<strong>done</strong>

If you want to double check it’s not about to break stuff, change “do mv” to “do echo mv” and verify the output.

Importing this into Quicktime Pro, and exporting it worked as expected. But, watching the video, you have no sense of time. Was each frame 1 minute passing? 1 hour? 1 day?

Embedding Time-stamps

I decided to put the time-stamp on each frame of video. But, how to read the filename, format the time-stamp and embed it on the image?

There are a bunch of watermarking tools, but I doubted they would be able to read the filename, clean up the formatting and write to the image..

Then I remembered ImageMagick – a set of command-line tools for image processing. After a bit of searching around, I found some examples of labeling images..

What I ended up with was the following:

<strong>let</strong> c=0; <strong>for</strong> i <strong>in*</strong>; <strong>doecho</strong> convert -font <strong>/</strong>Library<strong>/</strong>Fonts<strong>/</strong>Arial.ttf -fill white -pointsize 18 -draw 'text 10,235 "$i"' $i $c.png <strong>>></strong> proc.sh; <strong>let</strong> c=c+1; <strong>done</strong>

This produces a file filled with incrementing lines such as:

{{lang:bash} convert -font /Library/Fonts/Arial.ttf -fill white -pointsize 18 -draw 'text 10,235 "2007-10-10 16:00"' 2007-10-10_16-09.jpg 0.png

Fun is it not? Basically it does the same as the first renaming script, but instead of renaming, it appends an image-magick command to open $i, write the filename on the frame, and output it as $c.png ($c being the frame count)

One slight problem I had was an error “convert: unable to read font”. This was solved by using an absolute path to the font. On OS X These are under /Library/Fonts/, thus /Library/Fonts/Arial.tff was what I used.

I wrote the commands to a file, so I could clean the text output manually. It saved messing around with sed in the loop, making it even more complicated and messy.. Since this was a one-of run, manually editing the file was fine.

I opened the “proc.sh” file created by the above loop in TextMate, and used its Regex find/replace to rewrite “2008-12-27_18-45.jpg” to “2008-12-27 18:45”

The regular expresion I used was horrible looking, like all regex’s, if you’re going to do this yourself, and there’s problems, just rewrite it – debugging regex’s is more hassle than rewriting them.. The quotes are included in the regex to stop it altering the filename as well.


And the replace field:

"$1 $2:$3"'

Time-stamped images!

So, now I had a shell-script full of the convert commands, ready to label the images.

chmod +x proc.sh

After 3.6 minutes (On a single core of a Intel C2D 2.33GHz processor – imageMagick isn’t multi-threaded), I had a nice image sequence, ready to convert to a video!

Loading it into Quicktime Pro, I exporting a 12FPS H.264 video, which you saw at the top of this post! The file-size was approx’ 1.3MB, and it was 403 frames long.

Rate this post

Leave a Comment