OpenStreetMap

A few days ago I wrote about extracting GPX location data from the raw videos coming out of my A129 dashcam, and uploading to Mapillary. I was doing this one video at a time. A typical drive yields a lot of short videos, each 1, 5 or 10 minutes long depending on the settings. Some automation would be nice!

Mapper n76 suggested in the comments to my previous post to concatenate the short videos first and then process the resulting single video. I tried this following the instructions on the ffmpeg website, but I could not get exiftool to extract location data from the resulting longer video. So what I did instead was write a simple bash script that just loops over all MP4 files in the directory and does the GPX extraction and Mapillary processing / uploading for each file. Here’s the full script I used, which has the gpx.fmt file you need for exiftool baked in for convenience, but the loop itself is simply:

for f in *.MP4; do
    exiftool -m -p gpx.fmt -ee -ext mp4 -w %f.gpx $f
    mapillary_tools video_process_and_upload $f --geotag_source gpx --geotag_source_path ${f%%.*}.gpx --skip_process_errors
done

I found that I need --skip_process_errors because there’s usually one image extracted from the start or end of each video file that cannot be matched with a timestamp from the GPX file. I don’t care enough about one single image out of an entire sequence to try and figure out why, but I’m sure someone more determined than I could fix it :)

Location: 9th & 9th, Salt Lake City, Salt Lake County, Utah, 84102, United States

Discussion

Comment from DarkDays on 18 December 2022 at 10:02

Ahh, you’re tempting me to get a dash can and try it out. But I’d also have to get a car :p

Comment from bob3bob3 on 8 January 2023 at 00:09

Loosely related, the BlackVue dashcams NMEA stream is out of sync with the actual video by about 2 seconds. ie it is smart to extract all the streams, concatenate and uniq them, convert to GPX, then use as a single gpx input for each mp4. Perhaps the A29 has the same issue.

Server side Mapillary processing actually only creates 117 of a possible 120-121 images of a 2FPS stream 1 minute stream, since it processes on a file by file basis. I dont do local mp4>jpg processing myself as it results in 2x upload size (cost), so put up with the resultant gaps.

Cheers Bob

Log in to leave a comment