Skip to content

Commit b430f2c

Browse files
committed
[tests] Debug release test failures on MacOS hardware
1 parent f50839f commit b430f2c

4 files changed

Lines changed: 55 additions & 4 deletions

File tree

.github/workflows/release-test.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,15 @@ jobs:
7676
pip install .[opencv,pyav,moviepy]
7777
pip install opentimelineio pillow psutil pytest
7878
- name: Run release tests
79-
run: pytest -m release -vv --ignore=tests/release/test_long_video_stress.py --ignore=tests/release/test_install_matrix.py
79+
env:
80+
SCENEDETECT_DEBUG_LOG: scenedetect-debug-${{ matrix.os }}-${{ matrix.python-version }}.log
81+
run: pytest -m release -vv -k "Histogram or Adaptive" --ignore=tests/release/test_long_video_stress.py --ignore=tests/release/test_install_matrix.py
82+
- name: Upload detector debug log
83+
if: always()
84+
uses: actions/upload-artifact@v4
85+
with:
86+
name: scenedetect-debug-${{ matrix.os }}-${{ matrix.python-version }}
87+
path: scenedetect-debug-${{ matrix.os }}-${{ matrix.python-version }}.log
8088

8189
long-stress:
8290
needs: static

scenedetect/detectors/adaptive_detector.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,19 @@ def process_frame(self, timecode: FrameTimecode, frame_img: np.ndarray) -> list[
137137
adaptive_ratio >= self.adaptive_threshold and target_score >= self.min_content_val
138138
)
139139
min_length_met: bool = (timecode - self._last_cut) >= self.min_scene_len
140+
logger.debug(
141+
"[AdaptiveDetector] target_frame=%d adaptive_ratio=%.10f adaptive_threshold=%.10f "
142+
"target_score=%.10f min_content_val=%.10f avg_window=%.10f threshold_met=%s "
143+
"min_length_met=%s",
144+
target_timecode.frame_num,
145+
adaptive_ratio,
146+
self.adaptive_threshold,
147+
target_score,
148+
self.min_content_val,
149+
average_window_score,
150+
threshold_met,
151+
min_length_met,
152+
)
140153
if threshold_met and min_length_met:
141154
self._last_cut = target_timecode
142155
return [target_timecode]

scenedetect/detectors/histogram_detector.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,16 @@
1616
"""
1717

1818
import typing as ty
19+
from logging import getLogger
1920

2021
import cv2
2122
import numpy
2223

2324
from scenedetect.common import FrameTimecode
2425
from scenedetect.detector import SceneDetector
2526

27+
logger = getLogger("pyscenedetect")
28+
2629

2730
class HistogramDetector(SceneDetector):
2831
"""Compares the difference in the Y channel of YUV histograms for adjacent frames. When the
@@ -104,9 +107,18 @@ def process_frame(self, timecode: FrameTimecode, frame_img: numpy.ndarray) -> li
104107
# Example: If `_threshold` is set to 0.8, it implies that only changes resulting in a
105108
# correlation less than 0.8 between histograms will be considered significant enough to
106109
# denote a scene change.
107-
if hist_diff <= self._threshold and (
108-
(timecode - self._last_cut) >= self._min_scene_len
109-
):
110+
cut_threshold_met = hist_diff <= self._threshold
111+
min_len_met = (timecode - self._last_cut) >= self._min_scene_len
112+
logger.debug(
113+
"[HistogramDetector] frame=%d hist_diff=%.10f threshold=%.10f "
114+
"threshold_met=%s min_len_met=%s",
115+
timecode.frame_num,
116+
hist_diff,
117+
self._threshold,
118+
cut_threshold_met,
119+
min_len_met,
120+
)
121+
if cut_threshold_met and min_len_met:
110122
cut_list.append(timecode)
111123
self._last_cut = timecode
112124

tests/release/conftest.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#
1212
"""Fixtures for the release test suite."""
1313

14+
import logging
1415
import os
1516

1617
import pytest
@@ -22,6 +23,23 @@
2223
generate_vfr_swing,
2324
)
2425

26+
27+
def pytest_configure(config):
28+
# Force scenedetect import so init_logger() runs (it wipes logger handlers
29+
# at module load); without this our handler gets removed at first import.
30+
import scenedetect as _scenedetect
31+
32+
_ = _scenedetect
33+
34+
pyscenedetect_logger = logging.getLogger("pyscenedetect")
35+
pyscenedetect_logger.setLevel(logging.DEBUG)
36+
log_path = os.path.abspath(os.environ.get("SCENEDETECT_DEBUG_LOG", "scenedetect-debug.log"))
37+
handler = logging.FileHandler(log_path, mode="w")
38+
handler.setLevel(logging.DEBUG)
39+
handler.setFormatter(logging.Formatter("%(levelname)s %(message)s"))
40+
pyscenedetect_logger.addHandler(handler)
41+
42+
2543
REPO_ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
2644

2745

0 commit comments

Comments
 (0)