Skip to content

Sync a GPX track to video time 0, not to the first video GPS point - #847

Merged
caglarpir merged 1 commit into
mapillary:mainfrom
caglarpir:fix-gpx-offset-video-time-0
Oct 20, 2026
Merged

caglarpir merged 1 commit into
mapillary:mainfrom
caglarpir:fix-gpx-offset-video-time-0

Conversation

@caglarpir

Copy link
Copy Markdown
Contributor

Split out of #842.

Problem

GPXVideoExtractor._gpx_offset() computes the GPX offset against the first GPS point of the video, and _rebase_times() then puts that instant at video time 0. When the video's GPS starts later than the video, the GPX track lands early by that point's time.

GoPro drops noisy fixes at the start of a recording, so the first point it keeps can be minutes into the video.

Change

Subtract the video time of that point, so that the offset is to video time 0.

Verification

  • A GoPro HERO7 capture whose first kept fix is 221.6 s into the video, geotagged from a GPX exported from the video's own GPS: main syncs it 222.8 s off, this branch within 2.0 s. The remainder is the drift between the GPS clock and video time over the recording, which captures whose GPS starts at video time 0 show too.
  • 21 other videos (GoPro, Labpano, BlackVue) whose GPS starts at video time 0 sync the same as on main.
  • The new test fails on main.
  • Unit: 705 passed, 18 skipped, 1 xfailed. Integration: 56 passed. Doctests pass. ruff check, ruff format --check, usort diff and mypy are clean.

This touches the same lines of _gpx_offset as #846. Whichever lands second needs a small rebase.

GPXVideoExtractor computed the GPX offset against the first GPS point of
the video, and _rebase_times() then put that instant at video time 0.
When the video's GPS starts later than the video, the GPX track landed
early by that point's time. GoPro drops noisy fixes at the start of a
recording, so the first point it keeps can be minutes into the video:
on a HERO7 capture whose first kept fix is 221.6 s in, a GPX exported
from the video's own GPS was synced 222.8 s off, and is now within 2 s.

Subtract the video time of that point, so the offset is to video time 0.
@meta-cla meta-cla Bot added the cla signed label Oct 19, 2026
@caglarpir
caglarpir merged commit 7519d96 into mapillary:main Oct 20, 2026
16 checks passed
caglarpir added a commit to caglarpir/mapillary_tools that referenced this pull request Oct 20, 2026
main reworked GPXVideoExtractor (mapillary#831, mapillary#847, mapillary#849): it syncs a GPX
through a VideoClock, with a rate for timelapses, falls back to the start
of the video when the video's GPS has no usable clock, and reports a GPX
it cannot parse. This branch changed the same method, so take main's and
re-apply this branch's changes to it:

- Drop GPX points timestamped before 1980, and sort the rest.
- Place the GPX by --video_start_time wherever the video has no clock to
  sync it with: no usable GPS, as before, and now also GPS without a
  clock, such as noise with a placeholder date, which main places at the
  start of the video.
- Apply --interpolation_offset_time after the sync. The offset is in GPS
  seconds, so with a timelapse clock the track moves by offset / rate
  seconds of video; by the whole offset, frames would be picked
  offset * (rate - 1) seconds of track away from where they are geotagged.

In factory.py, keep both main's EXTERNAL_GPS_SOURCES and this branch's
_ALL_VIDEO_TYPES. Tests cover the clockless placement and the timelapse
offset.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant