Processing Gopro 9 videos with CLI: only first part of multi-part video gets processed correctly

I’m recording videos with a Gopro 9 on my bike, then extracting images with the CLI tools and using the GPS track from my phone (a lot more accurate than the internal Gopro GPS).

Gopro creates a new .MP4 file every 4GB, so a long video is split up into (after my renaming):
20220415_01_01.MP4
20220415_01_02.MP4
20220415_01_03.MP4

Aim:
Extract images of all the video segments in one go while also detecting duplicates from GPS (standing at a red light with a bike, see this thread about duplicates).

First Method tried:

mapillary_tools --verbose video_process "path_to_folder_containing_videos" \
--geotag_source "gpx" \
--geotag_source_path "path_to_gpx_file" \
--interpolation_use_gpx_start_time \
--video_sample_interval 0.5 \
--overwrite_all_EXIF_tags \
--duplicate_distance 3 \
--duplicate_angle 359

Result:

  • the second video segment is mapped onto the same GPS coordinates as the first video
  • duplicates are identified correctly though and not chosen for upload when put into the Mapillary desktop uploader

Second method tried:

  1. Concatenate all the segments into one long video, using ffmpeg, then process as above.
    Problem: I get MapillaryVideoError: Failed to find video creation_time in [video_path].
    As a workaround:
  2. Specify --video_start_time manually instead of --interpolation_use_gpx_start_time but that takes some tries because it seems the Gopro internal time (even though set to the same time as my phone) shifts a bit over time, so it’s not the same for videos taken on different days.
  3. MapillaryOutsideGPXTrackError comes up, so I used exiftool to add the GPS info:
exiftool -geotag "path_to_gpx_file" path_to_video_file

Result:

  • GPS info in the image metadata is correct (if video_start_time is accurate)
  • for duplicate detection though, I’d have to process again since the images only have GPS info now

In a nutshell, I’m missing something in method 1, and method 2 looks to get messy/cumbersome.

Any hints for making either work are very much appreciated!
I’m sitting on some 600km of footage that I want to process and upload…

Thanks,
Paul

1 Like

(I don’t have a solution for your problem. But just curious: why don’t you use it in timelapse photo mode?)

I remember that the BlackVue had some kind of multi file duplication problem at one stage. The simple way out at the time was to process one mp4 file at a time. A simple wrapper script would take care of that with method one.

If one sequence per movie is not acceptable then a “sample video” per video (defining sample interval) will create all the images and add the Date/Time EXIF tag. Then the whole directory of (multi video) images can have “process” run against it (and the gpx file) with your duplicate/exif settings.

Long winded but once set up it should be a goer… That will also take care of any time “gaps” between a video stop/start.

I am wondering though whether the camera isn’t writing date/time info correctly for every mp4. Try a ffprobe or just run ffmpeg against a few files to see if the date/time is advancing.

I’d be very careful concatenating videos. There will be a quality loss to contend with. The easy way to sync the start time is to point the camera at an accurate clock. No use for your current set though.

Oh and at 2FPS it may be worth checking that I frames are dominant. They will be of higher quality.

Also verify that (if using) exiftool handles sub-second intervals. I know gpscorrelate doesn’t. That can be checked by looking at the EXIF date/time and associated lat/lon between two adjacent images.

Is the GOPRO internal time not synced to the GPS signal? If it is “changing” that may be from a time gap between videos…