Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

only run pyav backend tests for VideoReader if av is available #7641

Merged
merged 2 commits into from
May 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions test/test_videoapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@
GroundTruth = collections.namedtuple("GroundTruth", " ".join(CheckerConfig))


def backends():
backends_ = ["video_reader"]
if av is not None:
backends_.append("pyav")
return backends_


def fate(name, path="."):
"""Download and return a path to a sample from the FFmpeg test suite.
See the `FFmpeg Automated Test Environment <https://www.ffmpeg.org/fate.html>`_
Expand Down Expand Up @@ -53,7 +60,7 @@ def fate(name, path="."):
class TestVideoApi:
@pytest.mark.skipif(av is None, reason="PyAV unavailable")
@pytest.mark.parametrize("test_video", test_videos.keys())
@pytest.mark.parametrize("backend", ["video_reader", "pyav"])
@pytest.mark.parametrize("backend", backends())
def test_frame_reading(self, test_video, backend):
torchvision.set_video_backend(backend)
full_path = os.path.join(VIDEO_DIR, test_video)
Expand Down Expand Up @@ -119,7 +126,7 @@ def test_frame_reading(self, test_video, backend):

@pytest.mark.parametrize("stream", ["video", "audio"])
@pytest.mark.parametrize("test_video", test_videos.keys())
@pytest.mark.parametrize("backend", ["video_reader", "pyav"])
@pytest.mark.parametrize("backend", backends())
def test_frame_reading_mem_vs_file(self, test_video, stream, backend):
torchvision.set_video_backend(backend)
full_path = os.path.join(VIDEO_DIR, test_video)
Expand Down Expand Up @@ -166,7 +173,7 @@ def test_frame_reading_mem_vs_file(self, test_video, stream, backend):
del reader, reader_md

@pytest.mark.parametrize("test_video,config", test_videos.items())
@pytest.mark.parametrize("backend", ["video_reader", "pyav"])
@pytest.mark.parametrize("backend", backends())
def test_metadata(self, test_video, config, backend):
"""
Test that the metadata returned via pyav corresponds to the one returned
Expand All @@ -180,7 +187,7 @@ def test_metadata(self, test_video, config, backend):
assert config.duration == approx(reader_md["video"]["duration"][0], abs=0.5)

@pytest.mark.parametrize("test_video", test_videos.keys())
@pytest.mark.parametrize("backend", ["video_reader", "pyav"])
@pytest.mark.parametrize("backend", backends())
def test_seek_start(self, test_video, backend):
torchvision.set_video_backend(backend)
full_path = os.path.join(VIDEO_DIR, test_video)
Expand Down Expand Up @@ -249,7 +256,7 @@ def test_fate_suite(self):

@pytest.mark.skipif(av is None, reason="PyAV unavailable")
@pytest.mark.parametrize("test_video,config", test_videos.items())
@pytest.mark.parametrize("backend", ["pyav", "video_reader"])
@pytest.mark.parametrize("backend", backends())
def test_keyframe_reading(self, test_video, config, backend):
torchvision.set_video_backend(backend)
full_path = os.path.join(VIDEO_DIR, test_video)
Expand Down