OpenStreetMap

Viofo A129 Dashcam Video ➡ Mapillary

Posted by mvexel on 13 December 2022 in English.

I purchased a dashcam a while ago because (1) people drive like absolute idiots where I live (seriously, watch that video) and (2) who knows what you might capture? It’s a Viofo A129 Pro Duo, it has a 4k front-facing camera and an additional HD rear-facing camera. It also has built-in GPS.

sample dashcam image

Because it’s always on, I figure it would be nice to use the footage for mapping purposes as well! The process is not completely straightforward, hence this blog post.

Let’s look at what the camera produces:

screenshot of folder

Just movie files, no separate GPX files. That means the location information must be embedded in the video stream somehow. Great..

Some internet sleuthing reveals that the fantastic image / video metadata swiss army knife exiftool (tagline: Metadata R Us 🤣) picked up support for extracting location metadata from video files a few years ago! The command to use is

exiftool -p gpx.fmt -ee -ext mp4 -w %f.gpx ~/tmp/*.MP4

You can read the exiftool documentation to learn more about the various parameters. What’s important is that you need the gpx.fmt file that is basically the template that exitfool uses to write out the raw location data to the familiar GPX format. You can grab it from here.

In the above form, exiftool will iterate over an entire directory of .MP4 files and write one GPX file for each. For this demo, I just copied one movie file from the SD card, so the result is one GPX file with the same name as the movie file but with the .gpx extension.

Now that we have the companion GPX file, we can use mapillary_tools to extract individual images, add location information and upload everything in one step:

mapillary_tools video_process_and_upload 
    ~/tmp/ 
    --skip_process_errors 
    --geotag_source gpx 
    --geotag_source_path ~/tmp/20221209_130755_00330F.gpx

Because the Mapillary CLI tools can only take a single GPX file as the location metadata input, a little scripting to process an entire folder of images would be really nice. I will follow up in another blog with more on that.

I am also experimenting with the camera’s time lapse mode. The video feed for the front camera alone is more than 2GB per 5 minutes, meaning on longer trips you run out of storage and the camera overwrites older files. I will post more on this in the near future as well.

My conclusion is that this definitely could be easier, but it’s also very doable if you’re not afraid of the command line.

Finally, some links for reference:

Location: Central City, Salt Lake City, Salt Lake County, Utah, 84111, United States

Discussion

Comment from n76 on 13 December 2022 at 05:49

Good to see there is another way to do this than what I found. I will give your method a try some time.

I extract the GPX data from my Viofo A119 dash cams using a script called nvtk_mp42gpx.py

It might also work on the A129 series if they use a similar Novatek processor.

In my case I sometimes use the GPX to make movie animations using GPX Animator but mostly use it along with a home brew set of scripts to create sequences of geo-referenced photos for use in JOSM.

Comment from n76 on 13 December 2022 at 05:58

A postscript on my previous comment: It is possible to script the catenation of your video files with ffmpeg and you can create a single GPX file from multiple files using gpsbabel. That might be a way for you to make your Mapillary uploads easier.

I did a little video experiment using this type of scripting a while back and documented it on my non-OSM blog.

Comment from mvexel on 14 December 2022 at 00:23

Concat’ing the video files and then extracting the GPX may indeed make more sense. as long as the concat doesn’t mangle the location data stream, but no reason to assume that would be the case. Thanks for the comments!

Comment from SimonPoole on 14 December 2022 at 22:37

Unluckily it probably has to be said: check your local legislation before using a dash cam in general and specifically for mapillary.

Comment from n76 on 14 December 2022 at 23:14

From a world wide point of view there may be legal issues.

But mvexel and I are both in the United States. If I understand the situation correctly, every state in the United States has decided that still and video photography in public spaces (public roads are public spaces) is okay. And no state has restricted dash cams or dash cam videos.

A number of states have laws about recording conversations. If the dash cam is set to record audio, even if only inside your own car, then you better check out your state laws.

Comment from mvexel on 14 December 2022 at 23:50

There used to be some states where having anything attached to your windshield that would obstruct a clear view for the driver was prohibited, which could include dashcams. I don’t know if that’s still the case. Regardless, I prefer to have it recording in case I need it to prove that I am not at fault if some idiot gets me into a situation. The Mapillary / Kartaview uploads are a bonus.

Comment from SimonPoole on 15 December 2022 at 00:07

From a world wide point of view there may be legal issues.

Guess what mvexels audience here is.

Comment from mvexel on 15 December 2022 at 23:07

Follow up post about automation here

Comment from edc22 on 16 December 2022 at 00:47

If you use nvtk_mp42gpx.py script you can also try my upgraded version of this script for Viofo dashcam from: https://github.com/edc22osm/viofo2jpg

Comment from UrSuS on 21 December 2022 at 06:03

Thanks for the tutorial! Here is the link to your Mapillary sequence https://www.mapillary.com/app/user/mvexel?lat=40.730766935220004&lng=-111.86531575521002&z=17&pKey=533265518817876&focus=photo

I have also rear cam, but with lower quality. Interesting if I can merge both? :)

Comment from mvexel on 17 January 2023 at 20:53

I have a rear camera also (not currently installed..) and it would be interesting to process both videos at the same time.

Log in to leave a comment