DIY Video overlay

I got myself a Garmin Virb Elite in the post Christmas sales, the plan was to use it while riding my bike and when snowboarding.

The camera will shoot in full 1080p HD and has a super wide angle lens to grab loads of what’s going on.

I finally managed to get out on my bike at the weekend and remembered to hook the camera up so it was hung under the handle bars. The raw video looks pretty good.

Having got some video I wanted to overlay some of the stats from my Garmin 810 cycling computer like location, speed, elevation, gradient and heart rate. Garmin provide some software called Virb Edit which will do all this, unfortunately it only runs on Windows or OSx. No problem I thought, I’ll just throw it in the same Windows 7 VM I use for Garmin Express, the app I use to upload my workouts. This was going well until I tried to view one of the videos I’d just imported and it complained about not having DirectX 10 support. This is the bit of Windows that handles all the multimedia stuff and for video tends to need access to a GPU to accelerate things. While it is possible to get things like this to work with a VM it is a lot of work and requires the machine your using to have 2 graphics cards1.

Since the standard software wasn’t going to work I thought I’d have a go at trying to build some scripts to do this with Linux. I decided to start with a simple map overlay. I’ve played with Google Map’s static maps API before so I ran up some simple NodeJS code to read a TCX file I generated from the FIT file created by the camera.

var tcx = require('tcx-js');
var http = require('https');
var fs = require('fs');

var parser = new tcx.Parser();

var tail = [];

parser.activity.trackpoints.every(function(element, index, array){
	var filename = index + '.png';
	var url = "" + + "," + element.lng + "&zoom=16&size=300x300";
	if (index != 0) {
		url = url + '&path=color:0x0000ff80|weight:2|' + tail.join('|');

	 	http.get(uri, function(res){
	 		//console.log("statusCode: ", res.statusCode);
 //  			//console.log("headers: ", res.headers);
	 		var data = '';
	 		res.on('data', function (chunk){
	 			data += chunk;

	 		res.on('end', function(){
	 			fs.writeFile(fn, data, 'binary', function(err) {
	 				if (err) {
	 })(url, filename);

	tail.push( + "," + element.lng);
	if (tail.length >= 25) {

	if (index != (array.length-1)) {
		var now = new Date(element.time);
		var then = new Date(array[index +1].time);

		var diff = Math.abs((then.getTime() - now.getTime() ) / 1000);
		//console.log('%d', diff);
		for (var i=0; i<diff; i++) {
			fs.appendFile('list.txt',filename + '\n',function(err){});

	return true;

This worked pretty well until I hit Google’s rate limit so only got the first 100 map titles.

I used the ImageMagick scripts to build a composite image of the map tile on transparent background.

Create an empty 1920×1800 image with a transparent background

$ convert -size 1920x1080 xc:transparent background.png

Overlay the map title in the bottom right hand corner

$ composite -geometry 300x300+1520+700 1.png background.png scaled/1.png

The script also generates a file called list.txt which contains a list of the filenames and how many times to repeat them at 1 frame per second to match up with the orginal video. Using this list with mencoder to generate the video like this.

$ mencoder mf://@list.txt -mf w=1920:h=1080:fps=1:type=png -ovc copy -oac copy -o output.avi

Finally I used OpenShot to generate the composite video.

I’m going to have a look at using OpenStreetmap instead of Google Maps to avoid the rate limiting and also trying to generate some gauges for speed, cadence, altitude and heading.

1 The laptop I’m doing this on does actually have 2 graphics cards, but I’m using the better one to actually run the OS and it’s a royal pain to switch them round.

Wiggle Portsmouth Olympic Triathlon 2013

After doing the Blenheim Triathlon earlier in the year I’ve been looking have a go at something a bit further, so last weekend I did the Wiggle Portsmouth Olympic Distance Triathlon.

Olympic Triathlons are basically double all the distances of the Sprint version, so 1500m swim, 40km cycle and a 10k run.

I got round Blenheim in 1:30:02 (if I’d known I was that close, I’d have managed to sprint a little harder) so I was aiming to get round this course in sub 3 hours.

Swim 1500m

The swim was in the sea from down by Southsea Castle to the Pier. It was first sea swim and I was a bit concerned about waves and basically having my face stuck in salt water for about 30mins. The weather was pretty good and with no wind the water was totally flat. What I hadn’t really thought too much about was the tide, it was great on the 3 sides of the rectangle, just having to adjust a little as I crossed the short ends, but on the way back it was a hard slog. I stormed the first 1k in about 15mins, but the last 500m took 25mins.

Again Strava seams to be showing a strange time for the swim.

Time: 0:41:56


I clocked this at 4:39 which includes the run up from the beach and I also didn’t hit the button until I’d been on the bike for about 200m so this was probably actually a bit quicker than Blenheim (4:25).

Cycle 40km

This was a really nice flat course with a long first lap up round the naval base followed by 4 laps round the sea front at Southsea. I pushed pretty hard on this leg and was pleased to average more than 30kph but was still getting passed by guys going a lot quicker on serious all carbon tri bikes.

Time: 1:16:12


2:08 this time, which is about the same as Blenhiem(2:05)

Run 10km

The run was 2 laps of a loop the other way up the sea front from the cycle leg, again nice and flat apart from a really short climb up over the old defensive wall. I probably set off a little bit too quick as I had aimed for a 50min 10k and was doing 4:30 to 4:40 k’s early on, but I ended up with a total average of 4:55.

Time: 0:46:47

Total time 2:51:47

I came 176th out of 313 (including relay teams) and 46th in my age group. I was well under my 3 hour goal and I think if there had been no tide I could have taken nearly 10 more mins out of that as I can cover a 1500m in the pool in under 30mins.

One of the new challenges for this distance was working out how to take on food while on the move, as the research shows you can go for about 90mins on the reserves and carb loading before an event. I had tried a couple of flavours of gels the week before (I should have sorted this out a lot earlier) and not been too impressed with the black cherry or the chocolate orange. In the end I plumped for a lemon & lime flavoured one, I took the first one as I was starting the second lap on the bike along with a hand full of jelly babies. I saved the second one for while I was running the first lap.

I think I’m up for doing some more Sprint and Olympic distances, but I’m not mad enough to try a 70.3 or a Iron Man yet. Targets for the next Sprint is 1:15:00 and Olympic has to be 2:40:00 with a stretch of closer to 2:30:00

Blenheim Triathlon 2013

Last weekend I took part in the 2013 Blenheim Sprint Triathlon, it was my first full distance sprint with an open water swim. I had done 2 previous sprints but they had both had 400m pool based swims with no wet suites.

The first thing I’ll say is that the setting was amazing, from racking for transition in the court yard,

Racking in the court yard

To the view of the lake

Dragging the wetsuit on

To the riding and running round the grounds.

Swim 705m

I knew going in that the ride and the run wouldn’t be a problem and I knew I could cover the distance for the swim in a pool, but the mass deep water start did concern me a little and also trying to swim in a straight line with no rows of titles to follow. I was lead to expect the start would be a total washing machine of arms and legs everywhere, but actually wasn’t that bad. There was the odd finding a foot when reaching out and when rolling my head out to breath finding somebody right there that I couldn’t see though the murky water.

Time for the Swim: 14mins 15seconds.
I’m happy with that but think I’ll be able to improve on it for next time.

(Strava seams to have messed up the swim time for some reason)


After the swim the 400m meter run up from the lake to transition was hard work while barefoot and trying to fight my way half out of the wetsuit. I wasted some time trying to get some socks on, but I needed them because my bike shoes are a just a bit too big to wear without them.

Time for T1: 4min 25seconds
They say transition is the 4th discipline and mine needs work.

Ride 20k

The cycle course was pretty good, it was made up of 3 laps with 2 decent climbs and lots of downhill. The only downside was because the foot bridge over the course had been hit by a bus on Friday night a compulsory dismount was added to each lap just before you got back to the palace. This messed with everybodies rhythm a bit and must have stuck a couple of mins on the time.

Time for Ride: 43mins 07seconds
I would have liked to have pushed this under 40mins


A lot less to do this time, just needed to re-rack the bike, dump the helmet and swap the shoes

Time for T2: 2mins 17seconds
Again this needs to be a bit quicker, maybe some elastic laces will help.

Run 5.5k

The run starts with a evil climb over a foot bridge over the bike route. With the post ride jelly legs this is no fun at all as it’s pretty steep. Once that’s over it’s about 1k of flat before a steep down hill to round the other end of the lake

Time for Run: 25mins 59seconds
I know I can run this distance a lot quicker than this without the other 2 parts so I would like to get this down by a couple of mins as well.

Total Time: 1:30:02

I had a lot of fun doing it and I think with a little bit more work I can take a few minutes off all the legs and get it down to closer to 1:20 next year, but I’ve already starting thinking about the Olympic distance tri at Dorney Lake in September.

Man vs Horse

Today I did something a little different, instead of going to the local park to run 5km at Parkrun I set off to the New Forest to take part in a little event that Helen Bowyer had put together. The plan was to run 15km across the New Forest broken up in to 3 5km between pubs in a race against Helen on her horse Muttley. There where 7 runners from the ETS team, Me, James, Luke, Graham, Joe, Dominic and Peter also Rob on his road bike.

The runners and the Helen would be taking the same route with the runners getting a 10min head start on each leg. Rob had a route that was about twice as long and set off at the same time as Helen.

Leg 1

From The Rock at Canada Common to The Lamb at Nomansland. We set off across Canada Common from the back gate of The Rock, reasonably early on myself, James and Luke hit the front. Luckily Luke had run the route for this leg before so we didn’t have to do any looking at the map and managed to make our way to the Dealze Wood easily enough. We could probably have cut the corner a bit at the end and shaved some more time off. We had about a 5 min lead on Rob and another 3 over Helen (though she did have to detour a little to point Peter in the right direction).

View Leg 1 in a larger map

Leg 2

From The Lamb to The Royal Oak at Fritham. This was the shortest leg, but after a short climb through Bramshaw Wood it was across the open plain. The good view meant that Helen could see us and helped by the soft ground meant Muttley could go faster and caught us up with about 800m to go. Rob arrived pretty much at the same time as well.

View Leg 2 in a larger map

Leg 3

From The Royal Oak to The High Corner Inn. Jame, Luke and me hit the front again setting off, but the fact I’ve not been doing much more than 5ks recently really started to bite. I managed to stick with them both for the first half until we crossed the stream then we started to spread out. The spread ended up big enough that I lost site of Luke and James was long gone. I had a small nav failure at the bottom of the last climb up to the High Corner Inn, I think it was just my subconscious not wanting to climb, as I went past by about 400m and had to turn round and come back. Rob was first back this time.

View Leg 3 in a larger map

After we’ve finished we all went back to The Royal Oak for some lunch. It was a really good day out and I’m really up for having another go next year and maybe even have a look at the full marathon version at some point.

Triathlon time

I’ve gone and signed up for the Blenheim Palace triathlon in June 2013. There are a couple of guys from work who’ve signed up as well so there should be room for some healthy competition.

The training has already started, with cycling into work as many days as I can in the week. I’ve started to see an improvement in fitness already taking a massive 45 seconds off my 5k running PB on Saturday at the Southampton Parkrun getting under 21 mins(20:48).

I’m trying to work up a list of events for next year to see how I’m progressing, this years times are in the brackets:

  1. Eastleigh 10k – (44:32)
  2. Needles XC Half Marathon – (1:57:21)
  3. Isle of White Randonnee

I’m going to try and find some more to add as the year goes on as well.

I need to work on my swimming as my crawl still isn’t really anywhere near where it will need to be if I’m to make it anywhere near my target of somewhere around 1 hour 15 mins for the whole thing.

Tracks2Miles 1.1.16

I pushed a new update to the market at the weekend.

It should hopefully fix a problem where Tracks2Miles would complain it could not access My Tracks data even when sharing was allowed. This looks to be down to a change in the My Tracks API with the My Tracks 1.1.15.

I’ve also tweaked the “Like” handling a little to only work for posts that are videos or pictures as this seams to be the only type of posts this works.

Recently a college has been having a look at the code to see if there are some things he wants to add. Hopefully I should have something from him soon.

Tracks2Miles 1.1.14

Finally got round to spending some more time on Tracks2Miles.

This release is an attempt to make use of a lot of what is left of the API.

New features:

  1. New Workout types:
    • – Commute
    • – Spinning
    • – Rowing
    • – Cross Training
  2. Support for multi-media posts, Uploaded Images and links to Youtube and Vimeo are now shown in your timeline
  3. Like your friends workouts
  4. See when you get Motivational comments
  5. Added pull to refresh support to the timeline
  6. Slightly improved look and feel, the white background looks better

All that plus a couple of bugs I spotted along the way.

There is a new introduction video with a walk through of all the features

As always you can get the very latest version from the Android Market here:

The next version should have better support for tablets and ICS devices that support Activity Fragments to make better use of large screens. I’ve also managed to arrange to borrow a Sony Ericsson X10 mini to see about trying to improve the UI for those of you with really small screen devices.

New My Tracks Patch

After my last My Tracks patch had to be pulled (to be honest it did break sharing routes by anything other than Tracks2Miles) a new (safe) patch was accepted a few days ago.

This patch passes just the My Tracks track id along with the URL for the exported file in the SHARE intent. The key for the extra reuses the same key that is used by the My Tracks library when sending Broadcasts on starting and stopping recording a new track. The track id can be recovered from the intent with the following code:

long track_id = 
    intent.getLongExtra(getString(R.string.track_id_broadcast_extra), -1);

Once you have the track id then looking up all the details of that track using the My Tracks Library project is trivial (Once you got the user to allow 3rd party apps access).

MyTracksProviderUtils utils = 
    new MyTracksProviderUtilsImpl(this.getContentResolver());
Track track = utils.getTrack(track_id);
TripStatistics stats = track.getStatistics();
double totalDistance = stats.getTotalDistance();
long movingTime = stats.getMovingTime();
String cat = track.getCategory();
String desc = track.getDescription();
long lastLocId = utils.getLastLocationId(track_id);
Location loc = utils.getLocation(lastLocId);

The latest version of Tracks2TitanXT has already been updated to use this method and Tracks2Miles will get an update for this as well as some better tablet support before the next version of My Tracks ships.

Zephyr HxM BT

A new toy arrived in the post this morning. Eric Morse from TitanXT very kindly arranged this for me as a thank you for building the Tracks2TitanXT Android application.


I’ve been after one of these for a little while after getting a look at one when a couple of colleges bought them to help with their training.

As well as heart rate information the unit contains an accelerometer which is used to generate cadence information, this means that it can be used to approximate distances where there is no GPS reception. The data to is passed to a mobile phone via Bluetooth and there are a number of applications that understand the data including My Tacks. There is also an opensource project called zephyropen on goolge code that has documented the protocol and created a desktop app to display the data.

Zephyr also do a smarter version of the HxM called the BioHarness, this version gathers skin temperature and respiration rates as well as all the data from the HxM.

My Tracks only collects data from the sensor while it’s recording a route and it’s not easy to see the data once the workout has finished so I’m tempted to write a little app to grab the data at any time and possible a tool to view the data stored in the My Tracks database. I’ll also look at adding average heart rate info to the workout summary Tracks2Miles can upload to dailymile.


The soft belt and pickups is a lot comfier than some of the previous HRMs I’ve used before.



From the logs it appears people are interested in where to buy these in the UK. Mine came from these guys,

Tonight I will mainly be falling off my bike

I got home this evening to find a box waiting by the door.

The box contained my first set of cycling shoes and cleat pedals.

Tonight I will mainly be falling off my bike

I wasn’t sure exactly what I wanted here so I basically picked the cheapest bits on, but a bit of a chat with a few folk (Karl Roche) suggested I’d not done too bad.

I’ve gone for a set of Wellgo WPD982 SPD Pedals. Welgo seam to make pedals for a some of the more well known names and sell them under their own name cheaper than the others. I went for a half and half flat and cleat pedal so I can still use my bike without the shoes.

As for the shoes I got some dhb M1 MTB. There was a road version of these for the same price, but as far as I can tell the only real difference is that the mountain bike version have extra rubber bits on the sole that mean the cleat doesn’t touch the ground, which seamed like a good idea for my first set.

A couple of laps round the local housing estate this evening and I think I’ve got the hang of clipping in and more importantly unclipping before falling over when stopping, but it’s going to take a bit more practice before I head out on roads with any real traffic.