Skip to content

Commit

Permalink
fix: skip invalid mp4 files when extracting points (#558)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tao Peng authored Oct 4, 2022
1 parent 45aa8cb commit 0e7b1f6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
15 changes: 12 additions & 3 deletions mapillary_tools/geotag/camm_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,19 +235,28 @@ def extract_points(
start_offset = fp.tell()

if file_types is None or utils.FileType.CAMM in file_types:
points = camm_parser.extract_points(fp)
try:
points = camm_parser.extract_points(fp)
except (parser.BoxNotFoundError, parser.RangeError):
points = []
if points:
return utils.FileType.CAMM, points

if file_types is None or utils.FileType.GOPRO in file_types:
fp.seek(start_offset)
points_with_fix = gpmf_parser.extract_points(fp)
try:
points_with_fix = gpmf_parser.extract_points(fp)
except (parser.BoxNotFoundError, parser.RangeError):
points = []
if points_with_fix:
return utils.FileType.GOPRO, T.cast(T.List[geo.Point], points_with_fix)

if file_types is None or utils.FileType.BLACKVUE in file_types:
fp.seek(start_offset)
points = blackvue_parser.extract_points(fp)
try:
points = blackvue_parser.extract_points(fp)
except (parser.BoxNotFoundError, parser.RangeError):
points = []
if points:
return utils.FileType.BLACKVUE, points

Expand Down
3 changes: 1 addition & 2 deletions mapillary_tools/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -638,9 +638,8 @@ def _convert_and_upload_camm(
file_type, points = camm_builder.extract_points(src_fp, file_types)
if file_type is None:
LOG.warning(
f"Skipping %s due to: No GPS found in the video (file types: %s)",
f"Skipping %s due to: No GPS found in the video",
video_path.name,
file_types,
)
continue

Expand Down

0 comments on commit 0e7b1f6

Please sign in to comment.