About six weeks ago we received an email from a user in Brazil asking if we could support imports of data from a CSV file. We often get requests to support a new device or app, and typically it’s pretty quick to do. This time it was a little different, however.
First of all, we were being asked to support a CSV file that this user had generated from his GoPro Hero5, which has built-in GPS. Secondly, the data didn’t include any lap-specific data, it was just a series of GPS coordinates with timestamps and speed in meters per second.
He created this by downloading some code from Github, and running a tool manually on the command line, so this was a pretty technically savvy user, and he was following an involved process that we couldn’t really expect regular users to replicate. But the idea of being able to support imports of data from GoPro cameras was very attractive. Lots of people have them, they’re great on the track, and it would open up Serious-Racing to a whole new audience. So Lisette and I sat down and tried to think about how we could do this, and what the user experience should look like.
The user experience
The main thing we were looking for at this point was how to make it as easy as possible for users to get their data to us. So we said to ourselves, “what if a user could just select their GoPro Hero5 video file directly from our upload page and we pulled the GPS data out of it?” The developer in me started to panic. How on earth would I do this? Is this even possible? It was time to start researching…
The developer in me started to panic. How on earth would I do this? Is this even possible?
The current process followed by our user in Brazil was to run an ffmpeg command to extract the GoPro Metadata from the video as a binary file. He then used some Go code to turn this binary file into a CSV file. So the first step was taking this CSV file and importing the data into Serious-Racing. While mostly straightforward, we’re used to getting laps and lap times from data imports, but that wasn’t the case here, so we needed a way to ask users a few questions about their upload to process it correctly:
- Which track is it on? We can usually guess correctly based on the GPS coordinates.
- If it’s a new track, where is the start/finish line?
- Is the track circular, and if not, where’s the finish line?
Processing binary data
Next it was a case of trying to generate the CSV ourselves from the binary data that ffmpeg extracts from the GoPro video file. To do this, I was translating the Go code into Python that could be used by Serious-Racing, and only parsing the data types we care about.
We already process binary data from RaceChrono and some other devices, so the overall approach was pretty familiar. Working with binary data tends to be a series of frustrations followed by an epiphany, and this was no exception. Usually it’s because you’ve mixed up big-endian and little-endian, or bitwise "and"/"or" operators.
Working with binary data tends to be a series of frustrations followed by an epiphany
Having users all around the world is great because of the great variety of test data at our fingertips. At one point during the process after some initial imports were working fine we noticed a problem with some other imports. Inexplicably, the GPS coordinates that should have been in at Silverstone were showing up in the middle of Azerbaijan. After a bit of digging, it turned out I was using unsigned 32-bit integers when I should have been using signed 32-bit integers, so all negative numbers were incorrectly parsed. Any data north of the equator and east of the Greenwich meridian was fine, but Silverstone is west of the Greenwich meridian, so has a negative longitude. The fix was a five character change from “>IIIII” to “>iiiii”.
Another problem (shown in the image above) came from one user we were testing with because some GPS traces showed points that were completely out of alignment. In some cases they were a few hundred meters from the points either side of them in the data stream. In one case, they were about 80 miles away. Luckily, GoPro has open-sourced their data format, and has specifications available which show GPS fix and GPS accuracy, but more importantly give you guidelines for what values can be used to consider the GPS data correct or not. After applying these rules to the incoming data, we were able to strip out the bad data, and were left with a clean GPS trace.
Once again, user testing was crucial. It exposed another issue which wasn’t obvious to me as I was developing the feature. This was that the way I was doing things meant that the browser was using as much RAM as the size of the file it was parsing, which could be 3-4GB. My development laptop has so much RAM that I didn’t notice this, but it became obvious using Firefox’s development tools once I knew to look for it.
At this point it is already a very slick experience: just select the video on your laptop to let Serious-Racing extract the data right in your browser and process it on our servers, magically turning your GPS trace into laps which can then be compared with friends and dissected with all our other detailed data analysis features. Other things we would love to do:
- Test on all GoPro models with GPS.
- Give users the option to upload their video to Youtube and automagically add it to their laps.
No rest for the wicked.. Anyway, here's another shout-out to our awesome and very patient users: we wouldn’t even have tried this without the initial suggestion from one of our users in Brazil, and it wouldn’t be working without testing by users around the world. Thanks again for inspiring us every day to keep on making Serious-Racing better.
Although our articles are completely independent, some contain affiliate links. This means that, if the linked website has a product for sale and you buy that product, we get a referral fee from the seller. This doesn’t make the price of the product any higher for you as a buyer. Doing this allows us to offset some of the costs we have running Serious-Racing. As an Amazon Associate we earn from qualifying purchases.
Sign up for free
What are you waiting for?
- Create a page for your car, bike, or kart
- Explore tracks
- Compare and analyse your laps
- Add video
- Share with friends
- Get faster