Accept ISO 8601 (with timezone) for --video_start_time#822
Open
ptpt wants to merge 1 commit into
Open
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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