diff --git a/mapillary_tools/sample_video.py b/mapillary_tools/sample_video.py index 47e37a3fe..e3c026676 100644 --- a/mapillary_tools/sample_video.py +++ b/mapillary_tools/sample_video.py @@ -27,7 +27,7 @@ def sample_video( video_list = utils.find_videos( [video_import_path], skip_subfolders=skip_subfolders ) - video_dir = video_import_path + video_dir = video_import_path.resolve() LOG.debug(f"Found %d videos in %s", len(video_list), video_dir) elif video_import_path.is_file(): video_list = [video_import_path] @@ -36,6 +36,7 @@ def sample_video( raise exceptions.MapillaryFileNotFoundError( f"Video file or directory not found: {video_import_path}" ) + assert video_dir.is_absolute(), f"video_dir must be absolute here: {str(video_dir)}" video_start_time_dt: T.Optional[datetime.datetime] = None if video_start_time is not None: diff --git a/tests/integration/test_process.py b/tests/integration/test_process.py index 0c2982a1c..842ba19dd 100644 --- a/tests/integration/test_process.py +++ b/tests/integration/test_process.py @@ -2,6 +2,7 @@ import json import os import subprocess +import tempfile import zipfile from pathlib import Path @@ -647,6 +648,30 @@ def ffmpeg_installed(): is_ffmpeg_installed = ffmpeg_installed() +def test_sample_video_relpath(): + if not is_ffmpeg_installed: + pytest.skip("skip because ffmpeg not installed") + + with tempfile.TemporaryDirectory() as dir: + x = subprocess.run( + f"{EXECUTABLE} sample_video --rerun tests/integration/mapillary_tools_process_images_provider/gopro_data/hero8.mp4 {dir}", + shell=True, + ) + assert x.returncode == 0, x.stderr + + +def test_sample_video_relpath_dir(): + if not is_ffmpeg_installed: + pytest.skip("skip because ffmpeg not installed") + + with tempfile.TemporaryDirectory() as dir: + x = subprocess.run( + f"{EXECUTABLE} sample_video --rerun --video_start_time 2021_10_10_10_10_10_123 tests/integration {dir}", + shell=True, + ) + assert x.returncode == 0, x.stderr + + def test_sample_video(setup_data: py.path.local): if not is_ffmpeg_installed: pytest.skip("skip because ffmpeg not installed") @@ -699,10 +724,10 @@ def test_video_process(setup_data: py.path.local): with gpx_file.open("w") as fp: fp.write(GPX_CONTENT) x = subprocess.run( - f"{EXECUTABLE} video_process {PROCESS_FLAGS} --video_start_time 2018_06_08_13_23_34_123 --geotag_source gpx --geotag_source_path {gpx_file} {setup_data} {setup_data.join('my_samples')}", + f"{EXECUTABLE} video_process {PROCESS_FLAGS} --skip_process_errors --video_start_time 2018_06_08_13_23_34_123 --geotag_source gpx --geotag_source_path {gpx_file} {setup_data} {setup_data.join('my_samples')}", shell=True, ) - assert x.returncode != 0, x.stderr + assert x.returncode == 0, x.stderr with open(desc_path) as fp: descs = json.load(fp) assert 1 == len(find_desc_errors(descs))