Desktop Uploader or Mapillary Tools - Easy way to trim videos

For privacy reasons and such (videos of parking the car are not interesting on Mapillary) I want to cut out beginnings and endings of Dashcam videos.

I have a Vantrue E1 Pro and I tried using FFMpeg, but this removes the GPS stream.

Is there an easy way to trim such videos? Would be nice to have this included in the desktop uploader and/or mapillary tools.

The mobile app features “privacy locations” where it does not record - would be cool if such a triming could be GPS aware and just ignore certain zones from the video.

1 Like

Indeed we have “blocked addresses” on mobile, and it sounds like a reasonable feature request for DU/MT.
cc @nikola and @boris


BR,Yaro

1 Like

It should be easy to do for images (you can already select and delete images before upload with the new editing tools) but not for videos as I don’t think there’s a tool to do that without losing GPS data.

Hi @alexaddismap - this is a good feature request and something we have on our backlog, however I’m not certain we’ll be able to get to it in the near future. For now you can trim video and gpx either manually or by using a tool like KVRouite (GoPro Hero 12 external GPS track workflow)

Give that a shot, cc: @ridewithoutstomach

Thanks, the tool sounds cool but I was not able to run it properly. Showed some strange window artifacts on Wayland.

Also I am looking for an automated workflow:

  • Define geofences which should be excluded
  • Cut the video accordingly after extracting the GPS positiongs, and preserve the GPS data (I was not able to to this with ffmpeg, stream always was lost)
  • Upload

Right, I agree with your automated workflow (the way I’m imaging it is you’ll set the geofence, and we’ll automatically discard anything that is within that geofence, so you won’t have to cut the video on your end at all). However that functionality only exists for the the mobile apps for now (on our backlog for desktop uploader/mapillary_tools uploads)

Okay, you used FFmpeg - with what parameters?

-map 0

-map_metadata 0

-c copy

?

map_metadata not before. tried it now

ffmpeg -i 20260210_164926_00019_N_A.MP4 -ss 00:00:00 -to 00:01:00 -map 0 -map_metadata 0 -c copy -copy_unknown 20260210_164926_00019_N_A-cut.MP4

The cut one does not have GPS as per mapillary desktop uploader

Try to specify both streams at the same time explicitly. The video stream with -map 0:0 and the metadata stream with -map 0:x, where x is the metadata stream number. Keep in mind that the order of -map options passed is relevant. You should be able to lookup the metadata stream number ahead of time with ffprobe.

However, there is a chance that ffmpeg does not know how to demux and thus also cut an arbitrary (meta)data stream. In this case exporting the entire original metadata stream separately and then importing it also entirely uncut into the cut video file may be an option. The backend can then possibly handle that overlong GPS metadata stream like an overlong GPX track and everything should fall into place. Though, I am guessing that for this to work completely flawlessly the cut video is also going to need a correctly cut (or adjusted) timecode stream and/or correctly adjusted creation_time metadata tag timestamp value because the backend always needs a reference timestamp for the start of the video. If I am not mistaken, ffmpeg should be able to automatically adjust timecode streams, so long as you specify the timecode stream to be processed explicitly with an appropriate -map option.

Note that -map_metadata applies to the container video file’s metadata only, not a metadata stream.

1 Like

I believe I don’t have a separate GPS stream … not sure…

ffprobe 20260210_164926_00019_N_A.MP4 2>&1|grep -i gps

prints nothing … the interesting part is that the Mapillary Tools can read it. So it would be best to do the editing there.

If anyone want to try I might be able to post some demo video.

It does not work this way. Post ffprobe’s complete read out here.

$ ffprobe 20260210_164926_00019_N_A.MP4 
ffprobe version 6.1.1-3ubuntu5 Copyright (c) 2007-2023 the FFmpeg developers
  built with gcc 13 (Ubuntu 13.2.0-23ubuntu3)
  configuration: --prefix=/usr --extra-version=3ubuntu5 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --disable-omx --enable-gnutls --enable-libaom --enable-libass --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libglslang --enable-libgme --enable-libgsm --enable-libharfbuzz --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-openal --enable-opencl --enable-opengl --disable-sndio --enable-libvpl --disable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-ladspa --enable-libbluray --enable-libjack --enable-libpulse --enable-librabbitmq --enable-librist --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libx264 --enable-libzmq --enable-libzvbi --enable-lv2 --enable-sdl2 --enable-libplacebo --enable-librav1e --enable-pocketsphinx --enable-librsvg --enable-libjxl --enable-shared
  libavutil      58. 29.100 / 58. 29.100
  libavcodec     60. 31.102 / 60. 31.102
  libavformat    60. 16.100 / 60. 16.100
  libavdevice    60.  3.100 / 60.  3.100
  libavfilter     9. 12.100 /  9. 12.100
  libswscale      7.  5.100 /  7.  5.100
  libswresample   4. 12.100 /  4. 12.100
  libpostproc    57.  3.100 / 57.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '20260210_164926_00019_N_A.MP4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isomavc1mp42
  Duration: 00:15:00.00, start: 0.000000, bitrate: 32230 kb/s
  Stream #0:0[0x1](eng): Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc, bt709, progressive), 3840x2160, 31948 kb/s, 30 fps, 30 tbr, 92400 tbn (default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
      encoder         : h264
  Stream #0:1[0x2](eng): Audio: aac (LC) (mp4a / 0x6134706D), 16000 Hz, mono, fltp, 64 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
      vendor_id       : [0][0][0][0]

:thinking: Are you sure this is the complete read out? Because I can hardly imagine that the h264 stream itself would have GPS data interwoven. I guess that in your camera’s case the GPS metadata is written as part of the MOV/MP4 container in a proprietary atom. ffmpeg drops atoms it is not aware of from the original file when it copies streams because it de facto creates a new MOV/MP4 container on every write. Unfortunately, the -map_metadata option applies to standard atoms and the mdta atom only.

Perhaps all that mapillary_tools (or rather exiftool in the background) needs is just the moov atom to be at the beginning of the file? You can pass the -movflags +faststart option to move the moov atom to the beginning of the file. Usually, the GPS and other (proprietary) metadata atoms are members of the moov atom. See also other -movflags option flags. Potentially, omit_tfhd_offset or default_base_moof may help. Generally speaking, whenever a MOV/MP4 video stream is cut it requires the creation of new (atom) fragments, which may or may not be referenced by the proprietary GPS metadata. Fragments may get resized, reorganized, or reordered, so that the original GPS metadata may become useless at this point.

Alternatively, you can try to pass -err_detect ignore_err to potentially preserve all original atoms, although I doubt that this option is going to do just that.

Your safest bet is probably going to be to extract the proprietary GPS metadata with exiftool (because it can read MOV atoms selectively) and then convert it to a standard GPX file, which you can then pass to mapillary_tools or the DU together with the cut video file.

It all comes down to the fact that GPS metadata has not been standardized for MP4 containers. :slightly_frowning_face: Hence, cutting and processing such video files is always going to be tricky. The easiest and probably sanest solution to this is GoPro’s approach with a time indexed dedicated stream because then it is obvious that one can cut or splice it anywhere, just like a video stream.

2 Likes