|
| 1 | +import math |
| 2 | +import os |
| 3 | + |
| 4 | +import pytest |
| 5 | +import torch |
| 6 | +from torchvision.io import _HAS_VIDEO_DECODER, _HAS_VIDEO_OPT, VideoReader |
| 7 | + |
| 8 | +try: |
| 9 | + import av |
| 10 | +except ImportError: |
| 11 | + av = None |
| 12 | + |
| 13 | +VIDEO_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), "assets", "videos") |
| 14 | + |
| 15 | + |
| 16 | +@pytest.mark.skipif(av is None, reason="PyAV unavailable") |
| 17 | +class TestVideoDatasetUtils: |
| 18 | + # TODO: atm we separate backends in order to allow for testing on different systems; |
| 19 | + # once we have things packaged we should add this as test parametrisation |
| 20 | + # (this also applies for GPU decoding as well) |
| 21 | + |
| 22 | + @pytest.mark.parametrize( |
| 23 | + "video_file", |
| 24 | + [ |
| 25 | + "RATRACE_wave_f_nm_np1_fr_goo_37.avi", |
| 26 | + "TrumanShow_wave_f_nm_np1_fr_med_26.avi", |
| 27 | + "v_SoccerJuggling_g23_c01.avi", |
| 28 | + "v_SoccerJuggling_g24_c01.avi", |
| 29 | + "R6llTwEh07w.mp4", |
| 30 | + "SOX5yA1l24A.mp4", |
| 31 | + "WUzgd7C1pWA.mp4", |
| 32 | + ], |
| 33 | + ) |
| 34 | + def test_random_decoder_av(self, video_file): |
| 35 | + """Read a sequence of random frames from a video |
| 36 | + Checks that files are valid video frames and no error is thrown during decoding. |
| 37 | + """ |
| 38 | + pass |
| 39 | + |
| 40 | + def test_random_decoder_cpu(self, video_file): |
| 41 | + """Read a sequence of random frames from a video using CPU backend |
| 42 | + Checks that files are valid video frames and no error is thrown during decoding, |
| 43 | + and compares them to `pyav` output. |
| 44 | + """ |
| 45 | + pass |
| 46 | + |
| 47 | + def test_random_decoder_GPU(self, video_file): |
| 48 | + """Read a sequence of random frames from a video using GPU backend |
| 49 | + Checks that files are valid video frames and no error is thrown during decoding, |
| 50 | + and compares them to `pyav` output. |
| 51 | + """ |
| 52 | + pass |
| 53 | + |
| 54 | + def test_keyframe_decoder_av(self, video_file): |
| 55 | + """Read all keyframes from a video; |
| 56 | + Compare the output to naive keyframe reading with `pyav` |
| 57 | + """ |
| 58 | + pass |
| 59 | + |
| 60 | + def test_keyframe_decoder_cpu(self, video_file): |
| 61 | + """Read all keyframes from a video using CPU backend; |
| 62 | + ATM should raise a warning and default to `pyav` |
| 63 | + TODO: should we fail or default to a working backend |
| 64 | + """ |
| 65 | + pass |
| 66 | + |
| 67 | + def test_keyframe_decoder_GPU(self, video_file): |
| 68 | + """Read all keyframes from a video using CPU backend; |
| 69 | + ATM should raise a warning and default to `pyav` |
| 70 | + TODO: should we fail or default to a working backend |
| 71 | + """ |
| 72 | + pass |
| 73 | + |
| 74 | + def test_clip_decoder(self, video_file): |
| 75 | + """ATM very crude test: |
| 76 | + check only if fails, or if the clip sampling is correct, |
| 77 | + don't bother with the content just yet. |
| 78 | + """ |
| 79 | + pass |
| 80 | + |
| 81 | + |
| 82 | +if __name__ == "__main__": |
| 83 | + pytest.main([__file__]) |
0 commit comments