Accept ISO 8601 (with timezone) for --video_start_time#822
Conversation
The --video_start_time option only accepted the proprietary YYYY_MM_DD_HH_MM_SS_sss format, which is always interpreted as UTC. This left no clean way to correct timestamps for cameras whose RTC has no timezone and records local time (e.g. GoPro MAX), as reported in #819. Add a _parse_video_start_time() helper that also accepts ISO 8601: - an explicit UTC offset (or Z) is honored, and - a naive value is interpreted in the system local timezone. The legacy format is unchanged and still treated as UTC. Documented via doctests and updated the CLI help text.
|
The bug persists. Although mapillary_tools sample_video --video_sample_distance -1 --video_sample_interval 1 --video_start_time '2026-04-06T14:36:07.88+02:00' 'video.mp4'
⋮
exiv2 -pv 'video.mp4/video_v_000001.jpg'
File 1/1: video.mp4/video_v_000001.jpg
0x8769 Image ExifTag Long 1 38
0x9003 Photo DateTimeOriginal Ascii 20 2026:04:06 12:36:07
0x9011 Photo OffsetTimeOriginal Ascii 7 +00:00
0x9291 Photo SubSecTimeOriginal Ascii 7 880000
0x8825 Image GPSTag Long 1 110
0x0007 GPSInfo GPSTimeStamp Rational 3 12/1 36/1 197/25
0x001d GPSInfo GPSDateStamp Ascii 11 2026:04:06In other words, There are two subsequent issues here though.
|
Summary
Addresses part of #819 (GoPro MAX timestamping). The
--video_start_timeoption only accepted the proprietaryYYYY_MM_DD_HH_MM_SS_sssformat, which is always interpreted as UTC. This left no clean way to correct timestamps for cameras whose RTC has no timezone and therefore records local time (e.g. GoPro MAX).This PR makes
--video_start_timealso accept ISO 8601, which carries timezone information:2020_12_28_13_36_36_508(legacy)13:36:36Z2020-12-28T13:36:36.508Z13:36:36Z2020-12-28T13:36:36.508+01:0012:36:36Z2020-12-28T13:36:36.508(naive)Z) is honored.Implementation
A new
_parse_video_start_time()helper insample_video.pytries the legacy format first, then falls back todatetime.fromisoformat(with aZ→+00:00shim for Python 3.9/3.10 compatibility) and normalizes to UTC viaastimezone. The CLI help text is updated accordingly.Notes
Test plan
pytest --doctest-modules mapillary_tools/sample_video.py), including underTZ=US/Pacificmypyandruffclean