London in Fives: The Making Of

A few days ago I published a video called "London in Fives" on Vimeo. In this article I am explaining how I made this, including the hardware and software that I used.

But first, let's have a look at the video itself:

London in Fives

There are 25 sections in this video, each taking 5 seconds. Because the frame rate is 25 fps, that means there are 125 frames per segment. All those numbers are powers of 5, hence the title of the film: London in Fives.

The first and last segments are merely the title and end credits, and are just a series of images. The more interesting bits are the 23 segments in between.

Hardware

All these segments are made from single frame shots from my Nikon D300 DSLR camera. It has a feature that allows a picture to be taken every 5 seconds automatically. For all segments, except for the night time shot of Covent Garden and the Ice Skating, that created the raw images.

For each segment, I usually took a few more shots than the 125 required, usually up to a 150, to have a bit of a choice of where to start and end the segment. In one case (the Regent's Park sunrise in the fog segment), I was happy that I did! Due to a hard drive failure I fortunately managed to only lose a few images, so that I still had just 125 left!

Of course it is important to keep the camera steady between all of the shots. In most of the segments I used a GorillaPod, a three legged flexible tripod where each leg can wrap around objects. In the later scenes, I used a normal stand-up tripod, a Manfrotto befree.

astro.png

The camera movements are all done in post production, except for the night time shot of Covent Garden and the Ice Skating segments. Instead of using my camera's "take a photo every x seconds" feature, I relied on hardware to take both a photo every 5 seconds, but also rotate the camera slightly on top of its tripod. The time lapsing device that I used to rotate and instruct the camera to take a photo every 5 seconds is an Astro. This is a disk like device that can rotate around one axis and instruct the camera through a cable to take a photo at specific intervals over a certain period of time. I think that for future time lapses I will not rotate more than 30° for a 125 segment shoot as otherwise it goes a bit too fast.

To make sure I had my camera perfectly horizontal on my camera, I used a spirit level that sits on top of my flash socket.

Post Processing

After taking the photos, some post-processing was necessary. There are three types of post-processing that I had to do, depending on how the photos were shot.

For the two segments created with the Astro, I really only had to rescale the photos from the camera's native resolution to 1280x720.

For one other segment (Regent's Park sunrise in the fog), the GorillaPod was sitting on a bench that didn't turn out to be stable enough and lots of instability was introduced among the different images. I used Hugin's align_image_stack tool to align them in such a way they formed a stable sequence of images. This tool is usually used to "align overlapping images for HDR creation", but it also suited my use case very well. Basically, I ran the following command:

align_image_stack -a aligned/a -v -i -C --threads 3 *jpg

I first also tried enabling GPU support for remapping, but that just ended up crashing the tool. The tool here is called with an output prefix of aligned/a and the -C auto-cropped the image sequence so that it covered an area that all images shared.

londonin5s-align.png

After the image alignment for this particular segment, I could process it the same as the other 20 segments that were not taken with help from the Astro.

For the sequences not taken with the Astro, the resulting video still shows camera movement. This is absolutely artificial, and is basically done by cropping the right section out of each image. I varied the size and location of the cut out sections for each image to emulate a moving, and zooming camera. For one segment, the Oxford Circus crossing one, I also had to adjust rotation as the horizon wasn't flush. The rotating and cropping was done through fairly simple PHP scripts using the GD library.

londonin5s-camera-pan.png

A simple script that I used for this is looks like:

<?php
mkdir('tmp');
mkdir('small');

$fstart =  9800;
$fend   =  9924;

$xs = 1464;
$ys = 1008;
$ws = 1660;
$hs =  934;

$xe = 1208;
$ye = 1008;
$we = 1808;
$he = 1017;

for ($i = $fstart; $i <= $fend; $i++)
{
        $x = $xs + (($i-$fstart)/($fend-$fstart)) * ($xe - $xs);
        $y = $ys + (($i-$fstart)/($fend-$fstart)) * ($ye - $ys);
        $w = $ws + (($i-$fstart)/($fend-$fstart)) * ($we - $ws);
        $h = $hs + (($i-$fstart)/($fend-$fstart)) * ($he - $hs);

        $fn = sprintf( "tl3_%04d.jpg", $i );
        $cmd = sprintf( "convert -rotate 1.7 tl3_%04d.jpg tmp/tl3_%04d.jpg", $i, $i );
        `$cmd`;

        $img = imagecreatefromjpeg( "tmp/{$fn}" );
        $n = imagecreatetruecolor( 1280, 720 );
        imagecopyresampled( $n, $img, 0, 0, $x, $y, 1280, 720, $w, $h );
        imagejpeg( $n, "small/{$fn}", 100 );

        echo "Done with $i\n";
}

This script loops over all the images in the sequence (9800 to 9824). Given the x, y, width and height values for the beginning and end images of the sequence, it calculates the intermediate coordinates of where to crop from. Before cropping, the script uses convert to rotate each image by 1.7 degrees to put the horizon horizontal. After the rotation is performed, the call to imagecopyresampled cuts out the right part of the original image and scales it down to the target frame size of 1280x720.

Creating Video from Images

After I post-processed all the image sequences, I used ffmpeg with a "magic incantation" to create video segments. I wanted to render to webm as that seemed to be the best encoder. For a sample segment, the ffmpeg arguments looked like:

ffmpeg -y -framerate 25 \
        -start_number 5711 -i 12-south-bank/small/tl3_%04d.jpg \
        -vframes 125 -r 25 \
        -vcodec vp8 -b:v 50000k -vf scale=1280:720 -crf 8 \
        12.webm

Which basically means: use 125 frames starting from image number 5711 in directory 12-south-bank/small/ with file format tl3_%04d.jpg at 25 frames a second. The codec is vp8 with a video bit rate of 50mbit and a rescaled result of 1280:720 pixels. The -crf 8 selects ultra-high quality for vp8. The output file is 12.webm.

I wanted ultra high quality for each segment, as later on I would be re-encoding all the segments into the final video file, keeping as much image definition as I could.

Music

I have been a fan of Kevin MacLeod's Creative Commons licenced music for a while, having used it for some of the newer OpenStreetMap edit videos. In this case, I did not want to release the video under a Creative Commons license so I paid for one of his tracks: "Touching Moments Four - Melody".

With audacity I added the 5 beeps at the start, and I also slightly stretched the sound to cover the full two minutes that I needed it to last. I think the speed was reduced by about 8%. This does make the sound a bit lower in pitch, but I do not think it hurt its original composition.

Assembling

With the video segments and audio prepared, all I had to do is to stitch it all together. Again, I used ffmpeg with another magic incantation to do the dirty work. First I stitched all the videos together:

ffmpeg -y \
        -i 00.webm \
        -i 45.webm -i 01.webm -i 17.webm -i 18.webm -i 02.webm \
        -i 20.webm -i 03.webm -i 11.webm -i 12.webm -i 27.webm \
        -i 31.webm -i 48.webm -i 10.webm -i 30.webm -i 06.webm \
        -i 34.webm -i 39.webm -i 28.webm -i 23.webm -i 43.webm \
        -i 24.webm -i 47.webm -i 08.webm \
        -i 99.webm \
        -filter_complex concat=n=25:v=1:a=0 -b:v 100M -crf 8 temp.webm

And then I finally I added the music track:

ffmpeg -y \
        -i temp.webm \
        -i '/home/derick/media/mp3/cc-by/TouchingMomentsFour-Melody-updated.ogg' \
        -map 0 -map 1 -shortest -vcodec copy -acodec copy -strict experimental \
        final.webm

With this done, the full video was ready. I uploaded it to Vimeo, where you can see it in all its HD glory at http://vimeo.com/derickr/london-in-fives

I hope you enjoy the video as much as I did doing all the work for this!

Shortlink

This article has a short URL available: http://drck.me/ldni5s-b6a

Comments

No comments yet

Walking the London LOOP - part 23 and 24

The last one! So insisted we had our breakfast at Jack's. It was sort of a tradition when we started doing the LOOP, but we had got slightly bored of it. But for the last one, we had to. After that, tubes to Oxford Circus, Mile End and Upminster Bridge.

Section 23

Just after leaving Upminster Bridge station, we encountered a rather bizarre situation: an HGV lodged in a florist. Apparently it had clipped the bridge, and then went straight into the building. How rude.

loop23-d36_9720.jpg

Shortly after, we passed the Windmill pub, but only saw the Upminster Windmill in the distance. After crossing a bridge over the Ingrebourne River we took a right turn to follow the river. Almost for the entire length of this section. First we encountered some playgrounds, but after a while we made our way into the Ingrebourne Valley Local Nature Reserve, which connects to the Hornchurch Country Park. Lots of wetlands, some ponds with birds, and a few buildings remaining from the second World War, when this was RAF Hornchurch. It was a fairly pleasant and level walk. One of the stranger features was the Ingrebourne Hill Bike Park however, when you can try out some mountain biking!

loop23-d36_9738.jpg

At the bottom of the park, we had to cross the busy A1306, but a new pedestrian crossing made that easier. On the other side we found a big Tesco's where we acquired some water. Passing a few pubs, with, uhm, not so decent ratings brought us into Rainham Village, with its clock tower war memorial and an old Norman church. A few minutes later we reached Rainham station, and the end of section 23. Here we also ran into another group walking the LOOP—and they were also attempting to finish it on the same day.

Section 24

After passing the other group on the footbridge over High Speed One, and crossing underneath the busy A13, we soon came to the Rainham Marshes. We followed a LOOP sign on a path through the Marshes. However, after a few minutes we noticed it wasn't quite following either the directions off the Walk London website, but also wasn't following the mapped route from OpenStreetMap. We back tracked a little and instead had to go through some industrial area around Ferry Lane. We then also didn't spot a LOOP sign for quite some time, and the directions were also slightly misleading too. I have reported the mismatched signing, and I actually hope they redirect the LOOP through the Marshes instead of around factories and a land fill!

loop24-d36_9761.jpg

Taking the mapped route did get us to the Thames quite soon though. Here we spotted lots of birds as we went past the Tilda rice factory. Just beyond the factory we stumbled upon a dozen concrete barges, originally part of a Mulberry Harbour used in the D-Day landings of the second World War. We also spotted The Diver, an artwork by John Kaufman.

loop24-d36_9796.jpg

The rest of the walk around the landfill area was kinda tedious, but easy going. We were however confused by some fence once getting to the Rainham Marshes proper. This reserve, run by the RSPB, is one of the few left over ancient marshes. They have a nice visitor's centre on the East side, which also had a very decent café. After a restorative slice of cake, and crossing a new footbridge, we had some fun with photographing all the PHP Elephpants. Not long after, we left the coast and made our way to Rainham station and the end of our journey around London.

We celebrated with our certificates and a small bottle of procescco. Mission accomplished!

loop24-d36_9803.jpg

We took 3½ hours for the last 18km. The weather was really chilly at around 17°C. It got greyer and greyer but we managed not to get rained upon until we got to West Hampstead, nearly home. Getting home was a bit tricky though, as after a beer quest at St. Pancras the Thames Link was having some issues.

In any case, we made it! What's next?

The photos that I took on this section, as well as the photos of the other sections of the LOOP, are available as a Flickr set.

Shortlink

This article has a short URL available: http://drck.me/loop2324-b4n

Comments

No comments yet

Tweaking the Logitech R400 presenter tool on Linux

This article is a updated version of an earlier one.

Christmas 2002, I received a Logitech R400 presenter tool as a replacement for the php|architect one that has now fallen apart. However, to use it together with my presentation system—pres2, about which I previously wrote—I need it to provide left and right arrow keypresses. By default its left and right buttons generate Prior and Next events in X. It took me a while to get this to work, so in short, this is how I changed it.

First of all, I editted the file /lib/udev/hwdb.d/60-keyboard.hwdb as root. I searched for R400 and changed its entry to:

# Logitech Presenter R400
keyboard:usb:v046DpC52Dd*dc*dsc*dp*ic*isc*ip*in00*
 KEYBOARD_KEY_070029=f11
 KEYBOARD_KEY_07003e=f11
 KEYBOARD_KEY_070037=f5
 KEYBOARD_KEY_07004b=left
 KEYBOARD_KEY_07004e=right


logitech-r400.png

This maps the two scan codes that the Play button (lower-left) generates to f11, the empty screen button to f5 and the left and right buttons to the left and right arrow keys.

The first column represents the scancode, which I obtained by first looking up with input event the device was tied to:

stat -t /dev/input/by-id/usb-Logitech_USB_Receiver-event-kbd --printf "%N\n"

Which showed the following for me:

‘/dev/input/by-id/usb-Logitech_USB_Receiver-event-kbd’ -> ‘../event19’

To find out the scan codes, I had to download a getscancodes tool, and then compile it:

wget 'http://downloads.sourceforge.net/project/keytouch/getscancodes/getscancodes%201.0/getscancodes-1.0.tar.gz?r=http%3A%2F%2Fkeytouch.sourceforge.net%2Fdl-getscancodes.php&ts=1412723944&use_mirror=kent' -O getscancodes-1.0.tar.gz
tar -xvzf getscancodes-1.0.tar.gz
cd getscancodes/
make

With the new binary, and the event19 from above, I ran:

sudo ./getscancodes /dev/input/event19

Which showed:

458807 (0x70037)
458793 (0x70029)
458814 (0x7003e)
458827 (0x7004b)
458830 (0x7004e)

With these numbers, I now had enough information to edit the /lib/udev/hwdb.d/60-keyboard.hwdb file that I mentioned earlier.

After that, I had to run:

sudo udevadm hwdb --update

This consolidated the modified rules and made the keymapping active. My presenter tool now sends the correct key codes again.

The changes will persist after rebooting as well.

Shortlink

This article has a short URL available: http://drck.me/r400-b4d

Comments

No comments yet

Walking the London LOOP - part 21 (part 2) and 22

We traveled to Noak Hill by various means of transport. We traveled to Liverpool Street by tube, then train to Harold Wood and then by bus to the point where we aborted last time. Or sorta, as the bus stopped 50 meters short or so.

Section 21 (part 2)

loop22-d36_9621.jpg

Just after we got off the bus, we spotted another couple doing the LOOP. They were slightly faster than us, although we did catch up with them near the end of section 22. The first few hundred meters were tough going, as it was near a brook through some woods. With lots of fallen over trees and some very narrow paths. But this didn't last very long and we walked a bit besides Carter's Brook, a tributary of the Ingrebourne river, before entering Central Park. This Central Park is not nearly as large as the one in New York, but it did have a bench with Henry VIII behind it.

After Central Park we followed the path besides Paines Brook and after a while we walked past The Old Brickworks to get back to Harold Hill station to finish this short part of section 21. We skipped going to the pub The King Harold as we've only been going for about ¾s of an hour.

Usually at each section's start there is a nice brass plaque for that section. Unfortunately, at Harald Wood Station, it was gone. Likely vandalized.

Section 22

loop22-d36_9647.jpg

Continuing past the Archibald Road allotments we soon came upon Harold Wood Park with its cricket club and play ground. I attempted to take a nice photo of a tree with coloured leaves with the Sun just behind it, but the result wasn't as good as I would have hoped.

From Harald Wood Park we crossed into Pages Wood, although, most of the wood seemed to just have been planted. It was more of a walk through a meadow with some small trees on the sides, than a "wood". It was quite pleasant though, and because it was quite warm, we decided to have a little picnic just before we left it.

loop22-d36_9655.jpg

Then came a rather nasty section of the walk, past a road, and across the A127. Another mile later, we happily left the roads behind to go through some fields, and we walked besides the Emerson Park School's playing fields towards Upminster Bridge station, where the walk ended.


We really didn't stop at any pub throughout this walk, but on the way home, we called out our favourite cider pub, the Euston Cider Tap for some refreshing drinks. This was nearly the warmest walk that we did, so we thought we quite deserved our pints. Only one walk left now!


The weather was really warm and sunny at 25°C, although towards the end there were more clouds. We took 2¼ hours for the 11km.

The photos that I took on this section, as well as the photos of the other sections of the LOOP, are available as a Flickr set.

Shortlink

This article has a short URL available: http://drck.me/loop2122-b43

Comments

No comments yet

Walking the London LOOP - part 20 and 21 (part 1)

Another weekend, another walk. While having a few beers on Sunday, we had a look at the weather forecast for the day after. It looked really good, we decided that we were going to attempt 3 sections in one day. At a whopping 16½ miles. That meant getting up early too, and not spending ages getting breakfast. By the time we finished breakfast, we were already an hour behind schedule…

loop-logo.jpg

We traveled to Chigwell by means of Bakerloo to Oxford Circus and then the Central line out to Chigwell. On the way back from last time the trip via Woodford was recommended, instead of going the long way around via Hainault. So when we were waiting for the train at Oxford Circus we decided not to wait 7 minutes for the direct train via Hainault to Chigwell, but instead transfer again at Woodford. That ended up being a mistake, and we had to wait 20 minutes at Woodford to get to Chigwell. When we got to Chigwell, and the start of the walk by 11:15, we were an hour and a half behind schedule. Not a great start.

Section 20

After a short stretch along the High Road we turned into a first meadow just after passing by St. Mary's Church and an old Tudor Looking building—formerly Ye Olde King's Head. After a few minutes we crossed another road and ended up in the country, with loads of fields. While walking along the edge of one, we saw a familiar "public footpath" sign, which pointed diagonally across a field. The path was however not really visible at all, and the sign at the other end was on the ground. Not more than 15 minutes later, a similar situation popped up when both the walking directions, map and a fallen over guidepost told us to cross a field, which was clearly just planted without any regard for the public right of way. After pondering about we decided to go around the field, although I think we really should have crossed it. The PROW blockage has been reported.

loop20-d36_9524.jpg

After a while, we passed the Chigwell Water Treatment Works and wandered into another bit of meadow. Right after we crossed a stile we saw a little worm scurrying away into the undergrowth. We think it was a slow worm.

We passed by another church and after crossing the busy Romford Road we had to push through a gate so small that I had to take off my backpack. Going through another gate got us into Hainault Forest where after a while we got to a lake full of "ducks" (where "ducks" means ducks, geese, swans and moor hens).

loop20-d36_9537.jpg

Walking around Fox Burrow Farm we could quite well see that autumn was near. Some of the trees started showing their amazing autumn colours. Hopefully, on the last two walks these colours will be more pronounced. At the top of the field we had a great view over London, with the Shard, Canary Wharf and the City's skyscrapers barely visible through the haze.

A while later we crossed a fairway of the Hainault Golf Club where I nearly got a golf ball on my head as it went the wrong way straight up into the trees.

loop20-d36_9551.jpg

We escaped the golf club through a stretch of wood, the Mile Plantation and ended up at a corn field. This time, there was a neat path through the field and Morag and I had great fun pushing through it. However, we did not pay enough attention and ended walking along the wrong side of a thorny hedge and ditch. Something we only found out when we got to the end of it. There wasn't really a way for us to cross the hedge and ditch, and as we didn't really want to walk all the way back we simply jumped a barbwire fence.

Soon after we came upon a field with horses in it. One was very interested in us and followed us all along the fence! Soon after, we climbed a little hill and sat on a bench admiring the view, while I removed a stone from my booth.

In the last stretch of section 20 we crossed into Havering Country Park, where we walked over Wellingtonia Avenue with its majestic Sequoia trees into Havering-atte-Bower. Here we stopped at The Royal Oak where the friendly landlady poured us a refreshing beer.

Section 21 (part 1)

With the beer gone, we continued the walk, now section 21. On our right we spotted The Round House. However we found the signage slightly lacking and after a few minutes trying to figure out where we had to go, we realized we had to go through a gate which had horses just behind it trying to "escape". In our speed to open and close the gate, Morag let out quite a scream after she inadvertently touched the electrified fence.

I didn't escape damage either. With the forecast being so nice I went with shorts. In the end, that wasn't the cleverest idea as we had to go through quite a lot of brambles and stingy nettles. With as result my legs got all scratched and itchy. When we neared the top of another (small) hill we startled a covey of grouse and a nide(?) of pheasants. There were quite a lot and some kept hidden in the undergrowth even when we were nearly on top of them. The view from the summit was great, but there were more horses following us. Nobody got electrocuted this time though.

loop21-d36_9592.jpg

We hit more brambles and stingy nettles, and walked around a corn field that we apparently should have gone through. We passed by some woods, but then also missed a turn through a well hidden gap in the hedge and had to double back a little again. But we were not half way our second stage, and at a little to four it was already darker than we would have liked. So we decided to abort section 21 near a half way point. We still had a few more steps to make though, and we encountered a gate onto footpath 16. However, there was not a path behind the gate, but a vast jungle. We didn't spot a tiger.

By this time, we neared the pub The Bear on Noak Hill Road, where we took the bus into Harold Wood to take the train back into London. This leaves us with half of section 21, and all of section 22 to do on our next walk.


The weather was cloudier than expected and it wasn't very warm, at about 16°C. We took 3¾ hours for the 16km that the walk took.

The photos that I took on this section, as well as the photos of the other sections of the LOOP, are available as a Flickr set.

Shortlink

This article has a short URL available: http://drck.me/loop2021-b3u

Comments

No comments yet

Life Line