Repository navigation
Sample a symlinked video into a folder named after the link - #934
Merged
caglarpir merged 2 commits intoOct 27, 2026
Merged
Conversation
A GPX file was decoded in the encoding of the locale, as v0.14.7 did
with open("r"): cp1252 on Western Windows, cp936 on Chinese Windows.
GPX files are almost always UTF-8. There, a UTF-8 GPX with "Á", "Í",
"Ð", "Ý" or most CJK characters in its names failed with
UnicodeDecodeError, as their bytes are undefined in cp1252, and the
user was told that it is not a valid GPX file; other accented letters
only came out garbled. On Linux and macOS, a GPX in another encoding,
such as ISO-8859-1 with "Café" in a name, failed the same way.
Decode it as UTF-8 with errors="replace", as NMEA logs are, so that a
byte that is not UTF-8 only turns a letter of a name into U+FFFD:
positions and times are ASCII. gpxpy still reads the file opened in
text mode itself, and a byte order mark is still ignored. A UTF-16 GPX
still fails as not a valid GPX file.
video_process DIR OUT, with a symbolic link in DIR to a video outside it, crashed with "ValueError: '<target>' is not in the subpath of '<DIR>'": the folder of the samples was named after the path of the video relative to DIR, both with their links resolved, and the video resolved to outside DIR. video_process_and_upload and sample_video crashed the same way. Given the link itself, the video was sampled into a folder named after the file it links to, while the samples were named after the link (OUT/video.mp4/link_0_000001.jpg), so that geotagging them by their videos found none of them, as their names do not start with the name of the folder. Make the paths absolute without resolving their links, with os.path.abspath(), where the folder of the samples is named, and where samples are matched to their videos: the samples of DIR/link.mp4 are OUT/link.mp4/link_0_000001.jpg, whether DIR or the link is given. Two links to one video are still sampled once, as the videos found are still told apart by their resolved paths. os.path.abspath() makes a path that does not exist absolute on Windows too, which Path.resolve() did not with Python 3.9 and 3.10, so the helper for that goes.
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.
Stacked on #933; review the last commit.
video_process DIR OUT, with a symbolic link in DIR to a video outside it, crashed withValueError: '<target>' is not in the subpath of '<DIR>': the folder of the samples was named after the path of the video relative to DIR, both with their links resolved, and the video resolved to outside DIR.video_process_and_uploadandsample_videocrashed the same way. Given the link itself, the video was sampled into a folder named after the file it links to, while the samples were named after the link (OUT/video.mp4/link_0_000001.jpg), so that geotagging them by their videos (process OUT --geotag_source blackvue_videos --geotag_source_path DIR) found none of them and failed them all withMapillaryGeoTaggingError, as their names do not start with the name of the folder.Make the paths absolute without resolving their links, with
os.path.abspath(), where the folder of the samples is named (_normalize_path,_sample_dir) and where samples are matched to their videos (find_image_samples): the samples ofDIR/link.mp4areOUT/link.mp4/link_0_000001.jpg, whether DIR or the link is given. Two links to one video are still sampled once, asdeduplicate_paths()still tells the videos found apart by their resolved paths.os.path.abspath()makes a path that does not exist absolute on Windows too, whichPath.resolve()did not with Python 3.9 and 3.10, so_absolute(), the helper for that, goes.With a link in DIR to a BlackVue video:
video_process DIR OUT --video_sample_distance 50: 6 frames inOUT/link.mp4/, 6 ready (main: the traceback above, exit 1). The same with DIR relative, or given with..in it;sample_videoandvideo_process_and_upload --dry_runtoo.process OUT --geotag_source blackvue_videos --geotag_source_path DIR: 30 ready.video_process DIR/link.mp4 OUT:OUT/link.mp4/link_0_000001.jpg, and geotagging them by the videos in DIR: 6 ready (main: 6MapillaryGeoTaggingError).Compared with main on
process,video_processandprocess_and_upload --dry_run, on images and videos of many cameras with the default and other sources, the outputs and exit codes are the same.Unit and integration tests, doctests,
mypy --python-version 3.9,ruff check,ruff format --checkandusort diffare clean.