From MP4 to Mapillary

Hello everyone,

I’m new to Mapillary and find the project very interesting.
I’ve been using a dashcam in my Nextbase 522GW car for about a year.
How much effort does it take to edit and upload these videos?
Automatic processing would be best.
So that the effort is kept within limits
I generate between. 6-9h video material, so an automatic process would be very helpful to me.
I myself use a Windows PC.
But I also have 2 Linux servers available. Which I can address via the console.
So I would be very grateful if someone could already go this way and help me.
Thank you for your feedback.

Greetings Peter

1 Like

Welcome to Mapillary.

I also took a video while driving in a car and uploaded it to mapillary.
First of all, you need a GPX format log that records your driving position.

Mapillary_tools, which runs on Python, allows you to process videos, add location information, and upload them.

https://github.com/mapillary/mapillary_tools

Extract a still image from the video with the following command. Set each variable appropriately.
python mapillary_tools sample_video --video_import_path $video_file --video_sample_interval $sample_interval --video_start_time $millisec_utc --advanced

Add location information etc. to the image with the following command. You will only be prompted for your mapillary ID and password the first time you run it.
python mapillary_tools process --import_path $video_directory --user_name $user_name --advanced --geotag_source gpx --geotag_source_path $gpxfile --rerun --sub_second_interval $sample_interval

Upload with the following command.
python mapillary_tools upload --import_path $video_directory

If you have multiple video files, you can automate them by writing a script.

1 Like

My current process with Blackvue camera is like this:
Take the SD card from camera and put into PC.
Upload all MP4-s to server and delete from card.
Set the server to process and upload the videos.
Put card back into camera.

In order to get the geodata from Nextbase as GPX, you probably need to use exiftool or something similar: This thread is probably relevant: https://exiftool.org/forum/index.php?topic=7127.0

It’s also possible to create geotagged JPEG images directly from video, but it’s not as trivial - related topic: Page not found

For processing I use Ubuntu 20.04 Server with no GUI installed. I just set the process to go on separate tmux terminal so it’s available after disconnecting.

Also.

Configure the dashcam to only take fixed framerate movies. (parking mode can mess that for example)

Also best to use the lowest frame rate and highest resolution with the least amount of compression. The idea here is to reduce compression artefacts that will be visible on the images extracted from the mp4’s. By default the Mapillary tools will extract at 5FPS, dropping anything in between.

Also consider using WiFi to transfer the movies so popping the SD card in and out daily doesnt fail the socket

I am using the GoPro Max, but when exporting from .360 to .mp4 GoPro Player changes the date and time so the GPMF data no longer matches the video. Does anyone here know a quick fix, so I can use Mapillary tools to automate my current workflow?

My current workflow is a mess. I useGoThru Street Builder to extract all the frames from the .mp4. It can also select frames with distance interval. I’ve set it to select a frame every 3 meters. Then I have to use a EXIF editing software called MetaImage to change the dateTimeOriginal of the .jpg frames to the original date of the .360 file. Lastly I use HoudahGeo to import a .gpx file extracted from the .360 file with GoPro Telemetry Extractor. That software can match photos with a .gpx track by comparing the date and time. When all these steps are done I use Apple Automator to add a Nadir to cover myself in the photos, since I am using a head mount for my GoPro while biking.

Quickest workaround IMO.

Assuming you still have access to a gpx file for the route, just specify the video start time as an argument in the tools command line.

1 Like

@bob3bob3 I’m a bit of a noob with the Mapillary command line tool. How would the syntax for such a command look like?

Looking at the README.md here GitHub - mapillary/mapillary_tools: Command line tools for processing and uploading Mapillary imagery

at video_process - slight change

mapillary_tools video_process --import_path “path/to/images”
–video_import_path “path/to/videos”
–user_name “mapillary_username” --advanced
–geotag_source “gpx”
–geotag_source_path “path/to/gpx”
–video_start_time xxxxxxx
–interpolate_directions
–video_sample_interval 0.2
–overwrite_EXIF_gps_tag

xxxxxxx is the date/time in epoch notation (seconds since midnight 1/1/1970). There are various online calculators around if needed. If you are having start date/time extraction problems, pointing the camera at an accurate (to seconds) clock at the start will give a reference for manual entry.

I suggest trying the process (only) step so you can ascertain it has all worked prior to upload. eg load various images into Viking to make sure they match OSM features positions.

Keep in mind that I do not know GoPro and/or its 360 format. There is a gopro option in the tools (README.md) that I would assume reads its own gps data. There may be multiple videos rather than one and they may not be seamless. I havent run this command myself since the older python version.

1 Like

The backslashes at the end of all but the last line was removed by the forum parser. Add back in!

good afternoon, yes, all well and good. But I don’t calculate the seconds and so on for every video. I want to take one step and not hundreds. it can’t be that there isn’t something ready and you have to tinker around yourself. All of this is really not worth the effort to me and it is a waste of my time. I’m looking for a tool or script that does everything automatically, I’m not a programmer or anything. And to be honest, I don’t want to spend my little free time with 12 hours of work days playing with rum and etc. I am looking for what is ready as a final solution. frame number cannot be set with nextbase, so it is omitted. is there no one who has a solution that works automatically?

@DickePeter
I have a fully automatic script that uploads mp4 videos to mapillary. Shown in this thread.

However, it is necessary to deal with the difference depending on the equipment. I’m shooting a video on my Android smartphone, and the recording start time is the file name.

e. g. VID_20210506_084414.mp4

It is necessary to rewrite the program according to the purpose, such as converting to UTC based on the JST time zone where I live.

So I’m getting this error when I try to use the command:

usage: see -h for available tools and corresponding arguments, add --advanced to see additional advanced tools and/or arguments and --version to see version.

Mapillary import tool: error: argument tool: invalid choice: ‘video_process’ (choose from ‘process’, ‘upload’, ‘process_and_upload’)

Doesn’t seem like mapillary has the “video_process” command anymore?
My command looks like this:

mapillary_tools video_process --import_path "images/" \ 
--video_import_path "2788_01_GS.mp4" \ 
--user_name "olajuulholm" --advanced \ 
--geotag_source "gopro_videos" \ 
--geotag_source_path "2788\ 01\ GS.360" \ 
–-video_start_time 1625256332 \ 
--interpolate_directions \ 
--video_sample_interval 0.5 \ 
--overwrite_EXIF_gps_tag

Update: I got the script to work after I installed some xcode package. Got a ffmpeg issue to solve, brb.

Update 2: solved the ffmpeg issue. Just uninstalled it and reinstalled it -duh, silly me. That fixed it. I made some adjustment to the code above, which did give me geotagged photos from my GoPro .mp4 file. One of the changes I made was removing --video_start_time. I couldn’t get it to work, so I went with --use_gps_start_time.

mapillary_tools video_process --import_path "images/" \
    --video_import_path "2788_01_GS.mp4" \
    --user_name "olajuulholm" \
    --advanced \
    --geotag_source "gpx" \
    --geotag_source_path "2788_01_GS.gpx" \
    --use_gps_start_time \
    --interpolate_directions \
    --video_sample_interval 0.5 \
    --overwrite_EXIF_gps_tag

My issue now is that Mapillary won’t accept the photos, since they are missing EXIF data about capture time and the GPS data is not stored correctly? I would have uploaded a screenshot, but that doesn’t seem to be possible in this forum.

When I run the code all the date gets packed into the EXIF tag imageDescription instead of their respective tags. Does anyone if I’m missing something in my code that would fix that?

{"MAPSettingsUsername": "my_username", "MAPSettingsUserKey": 
"some_random_number", "MAPLatitude": 59.8892343, "MAPLongitude": 10.7944154, 
"MAPCompassHeading": {"TrueHeading": 26.641703586513586, "MagneticHeading": 
26.641703586513586}, "MAPCaptureTime": "2021_07_02_20_05_32_765", 
"MAPAltitude": 194.712, "MAPSequenceUUID": "30567513-eb0e-484d-a6c5-
488ded93f4a5", "MAPOrientation": 1, "MAPDeviceMake": "none", "MAPDeviceModel": 
"none", "MAPMetaTags": {"strings": [{"key": "mapillary_tools_version", "value": "0.7.4"}]}, 
"MAPPhotoUUID": "1c0b9232-5d2d-4647-b703-6dc9ca19b305"}

with nextbase everything is contained in the mp4 file. therefore I am looking for a solution how to do that. Everyone has to reinvent the wheel and try their hand at rum. you can net be the first nextbase user.

and as I said before. am not a computer scientist who knows a lot about things. if Mapillary does not provide a ready-made solution. then there is simply no input.

If everything is in the MP4 file, it might be similar to (if not exactly same as) Blueskysea/Viofo I mentioned earlier. Can you share a video sample to verify it?

@kartmann As I vaguely remember “use_gps_start_time” is about using the gps data start in lieu of the filename being the date/time. That may introduce an error that can be hard over-ridden by “video_start_time”. I don’t have the code installed here so I cant check the syntax or help. Your post here though does look like the pre dashes are malformed so could be worth another try.

Yes the first processing step after ffmpeg extracting images is to write a time/date EXIF tag. I think it is “Data and Time (original)”. That tag is compared against the gpx/GPS data to determine the co-ordinates of the image. For debugging the first extracted image should have that time/date in UTC.

The custom Description tag is then filled with the co-ords, interpolated direction and user/server authentication. The other EXIF tags (Lat/Lon etc) are then (optionally) filled.

AFAIK from the past the Mapillary server only cares about its one custom EXIF tag. In my old process command too it was “tags” plural (–overwrite_all_EXIF_tags) That might be worth a try.

@DickePeter and all others,

I recommend contacting Dean Zwikel on Facebook Messenger. On my request he built a tool to convert Google Street View video footage from my Labpano Pilot cameras to geotagged jpg’s which I simply upload with the Mapillary Desktop Uploader. Since he has extended his tool range to support other cameras. If there he hasn’t already something that works for you, then he may be up to creating it for you. Note that a donation to ocontinue his work is appreciated. He is the specialist to turn to.

Cheers, Joscelin

2 Likes

@JoscTr I’ve seen his tool. It’s awesome! -but sadly it’s only for the Windows OS. I’m on a Mac, which is the only OS GoPro player supports rendering 360-videos with GPMF date embedded in the video files.

@JoscTr Where can you find this tool, since I don’t have Facebook. I can’t write to him there either.

of course I can upload something for you.
You can find it under the following link there are many 3 minute videos, here you can also recognize the file names best.

Link: