Skip to content

Commit 92b5349

Browse files
committed
[build] Enable Moviepy tests for builds
1 parent 0e1df2b commit 92b5349

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

.github/workflows/build.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ jobs:
6262
pip install av opencv-python-headless --only-binary :all:
6363
pip install -r requirements_headless.txt
6464
65+
- name: Install MoviePy
66+
# TODO: We can only run MoviePy tests on systems that have ffmpeg.
67+
if: ${{ runner.arch == 'X64' }}
68+
run: |
69+
pip install moviepy
70+
6571
- name: Checkout test resources
6672
run: |
6773
git fetch --depth=1 https://github.com/Breakthrough/PySceneDetect.git refs/heads/resources:refs/remotes/origin/resources

scenedetect/_cli/controller.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,10 @@ def run_scenedetect(context: CliContext):
4242
return
4343

4444
# Suppress warnings when reading past EOF in MoviePy.
45-
is_debug = context.config.get_value("global", "verbosity") != "debug"
46-
if isinstance(context.video_stream, VideoStreamMoviePy) and not is_debug:
47-
warnings.filterwarnings("ignore", module="moviepy")
45+
if VideoStreamMoviePy and isinstance(context.video_stream, VideoStreamMoviePy):
46+
is_debug = context.config.get_value("global", "verbosity") != "debug"
47+
if not is_debug:
48+
warnings.filterwarnings("ignore", module="moviepy")
4849

4950
if context.load_scenes_input:
5051
# Skip detection if load-scenes was used.

tests/test_video_stream.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
from dataclasses import dataclass
2121
from typing import List, Type
2222

23-
import moviepy
2423
import numpy
2524
import pytest
2625

@@ -42,7 +41,11 @@
4241
# The warning occurs when reading the last frame, which VideoStreamMoviePy handles gracefully.
4342
MOVIEPY_WARNING_FILTER = "ignore:.*Using the last valid frame instead.:UserWarning"
4443

45-
MOVIEPY_MAJOR_VERSION = int(moviepy.__version__.split(".")[0])
44+
45+
def get_moviepy_major_version() -> int:
46+
import moviepy
47+
48+
return int(moviepy.__version__.split(".")[0])
4649

4750

4851
def calculate_frame_delta(frame_a, frame_b, roi=None) -> float:
@@ -357,7 +360,7 @@ def test_corrupt_video(vs_type: Type[VideoStream], corrupt_video_file: str):
357360
"""Test that backend handles video with corrupt frame gracefully with defaults."""
358361
if vs_type == VideoManager:
359362
pytest.skip(reason="VideoManager does not support handling corrupt videos.")
360-
if vs_type == VideoStreamMoviePy and MOVIEPY_MAJOR_VERSION >= 2:
363+
if vs_type == VideoStreamMoviePy and get_moviepy_major_version() >= 2:
361364
# Due to changes in MoviePy 2.0, loading this file causes an exception to be thrown.
362365
# See https://github.com/Zulko/moviepy/pull/2253 for a PR that attempts to more gracefully
363366
# handle this case, however even once that is fixed, we will be unable to run this test

0 commit comments

Comments
 (0)