Skip to content

Read the time of Ricoh Theta GPS tracks from the GPS fix in their maker note - #814

Open
caglarpir wants to merge 1 commit into
mainfrom
extract-rmkn-gps-timestamps
Open

caglarpir wants to merge 1 commit into
mainfrom
extract-rmkn-gps-timestamps

Conversation

@caglarpir

@caglarpir caglarpir commented Feb 25, 2026 •

Copy link
Copy Markdown
Contributor

Ricoh Theta X videos carry a CAMM track of type 5 samples: positions without timestamps. So they have no GPS clock, and their capture times come from the camera's clock. The RMKN box that the camera writes into udta is an EXIF block with a GPS fix: date, time and position. That fix is the first GPS sample of the video. This reads the fix and stamps the samples with its time, plus each sample's time in the video after the first sample. That gives these videos a GPS clock, which frame sampling, GPX alignment and uploads already use, as for every video with GPS timestamps.

Changes

  • camm_parser: CAMMInfo.rmkn_gps_fix (time and position), read from the RMKN box with the existing ExifReadFromEXIF. None when there is no GPS time or position, when GPSStatus is V (no fix), or when the date is not a valid capture time.
  • CAMMVideoExtractor: when a track has only type 5 samples, and the first sample is within 1 m of the fix (the EXIF block rounds the position to 0.01 arc seconds, about 0.3 m), stamps the samples as CAMMGPSPoint, built the way the description file decodes timestamped points, so a video reads the same from either.

Behaviour

  • Positions don't change.
  • Capture times move by however far the camera's clock is off.
  • A GPX track is now placed by the GPS clock, so a GPX stamped by the camera's clock no longer lines up; mapillary_tools warns that the track covers only part of the video.
  • A video without an RMKN GPS time (a camera without a fix when the recording starts writes none, and its track begins later), with GPSStatus V, whose first sample is not at the fix, or with type 6 samples reads as before.
  • As before, no frames are sampled from the part of a video before its first GPS sample.

Verification

  • On 8 Theta X videos, the position of the RMKN fix equals that of the first GPS sample (0.0 mm apart, same altitude), while the second sample is 0.3 to 1 m away. A video without a fix when recording starts (its track starts 63 s in) has no RMKN GPS time.
  • main vs this branch on those videos (process, video_process by interval and by distance, with and without a GPX): positions identical; the first sample is stamped with the RMKN time; capture times about 23.6 s later (the camera's clock was behind); the video without an RMKN GPS time unchanged.
  • Unit tests for the RMKN reading (fix, no fix, no GPS time, no position, not EXIF, no RMKN box) and for the extractor end to end (stamps type 5 samples from the first one, leaves them alone when the first sample is elsewhere or without RMKN, keeps type 6 timestamps).
  • Full test suite on Python 3.9; ruff, usort, mypy on 3.9 and 3.13.

Limitations

  • The GPS time is taken as UTC, as EXIF defines GPSTimeStamp.
  • The video is assumed to be recorded in real time. A Theta time-lapse video, if the camera writes one with a CAMM track, would get a clock running at 1x, which overrides --video_duration_ratio. Nothing in the RMKN box marks a time-lapse.

Since the first version

Rebased onto 0.15.0 and rewritten: it reads the RMKN box with the existing EXIF reader instead of a hand-written TIFF parser, stamps the samples only when the first one is at the position of the fix, and skips a fix whose status is V.

@meta-cla meta-cla Bot added the cla signed label Feb 25, 2026
@caglarpir
caglarpir force-pushed the extract-rmkn-gps-timestamps branch 2 times, most recently from 1ac8cff to b45aca4 Compare February 25, 2026 08:43
@caglarpir caglarpir changed the title Extract GPS epoch timestamps from RMKN maker note in Ricoh Theta videos Read the start of Ricoh Theta videos from the GPS fix in their maker note Nov 11, 2026
@caglarpir
caglarpir force-pushed the extract-rmkn-gps-timestamps branch from b45aca4 to bb6d05b Compare November 11, 2026 09:56
…er note

Ricoh Theta X videos carry a CAMM track of type 5 samples: positions
without timestamps. So they have no GPS clock, and their capture times come
from the camera's clock, by the creation time, which marks the end of the
recording. The RMKN box that the camera writes into udta is an EXIF block
with a GPS fix: GPSDateStamp, GPSTimeStamp and a position. On a set of
Theta X videos, that position is exactly that of the first type 5 sample,
while the next sample is 0.3 to 1 m away: the fix is the first sample, and
its time is the time of that sample.

The CAMM parser reads the fix with ExifReadFromEXIF, and the CAMM video
extractor stamps the type 5 samples with its time plus each sample's time
in the video after the first sample, as the CAMMGPSPoint that the
description file decodes timestamped points into. That gives these videos a
GPS clock, which sampling, GPX alignment and uploads already use, as they
do for every video with GPS timestamps.

The samples are stamped only if the first of them is within 1 m of the fix
(the EXIF block rounds the position to 0.01 arc seconds, about 0.3 m). A
camera without a fix when the recording starts writes no GPS time, and its
track begins later in the video. Such a video, or one whose GPSStatus is V
(no fix), or whose track has type 6 samples, reads as before.

Positions are unchanged. Capture times move by however far the camera's
clock is off, and a GPX is now placed by the GPS clock, so one stamped by
the camera's clock no longer lines up.
@caglarpir
caglarpir force-pushed the extract-rmkn-gps-timestamps branch from bb6d05b to 84eb425 Compare November 11, 2026 12:34
@caglarpir caglarpir changed the title Read the start of Ricoh Theta videos from the GPS fix in their maker note Read the time of Ricoh Theta GPS tracks from the GPS fix in their maker note Nov 11, 2026
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