Skip to content

Commit 355fe1a

Browse files
committed
[api] Add backwards compat. helpers to avoid breaking imports
1 parent 287b548 commit 355fe1a

File tree

8 files changed

+105
-11
lines changed

8 files changed

+105
-11
lines changed

scenedetect/frame_timecode.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#
2+
# PySceneDetect: Python-Based Video Scene Detector
3+
# -------------------------------------------------------------------
4+
# [ Site: https://scenedetect.com ]
5+
# [ Docs: https://scenedetect.com/docs/ ]
6+
# [ Github: https://github.com/Breakthrough/PySceneDetect/ ]
7+
#
8+
# Copyright (C) 2014-2025 Brandon Castellano <http://www.bcastell.com>.
9+
# PySceneDetect is licensed under the BSD 3-Clause License; see the
10+
# included LICENSE file, or visit one of the above pages for details.
11+
#
12+
"""DEPRECATED"""
13+
14+
import warnings
15+
16+
warnings.warn(
17+
"The `frame_timecode` submodule is deprecated, import from the base package instead.",
18+
DeprecationWarning,
19+
stacklevel=2,
20+
)
21+
22+
from scenedetect.common import * # noqa: E402, F403

scenedetect/scene_detector.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#
2+
# PySceneDetect: Python-Based Video Scene Detector
3+
# -------------------------------------------------------------------
4+
# [ Site: https://scenedetect.com ]
5+
# [ Docs: https://scenedetect.com/docs/ ]
6+
# [ Github: https://github.com/Breakthrough/PySceneDetect/ ]
7+
#
8+
# Copyright (C) 2014-2025 Brandon Castellano <http://www.bcastell.com>.
9+
# PySceneDetect is licensed under the BSD 3-Clause License; see the
10+
# included LICENSE file, or visit one of the above pages for details.
11+
#
12+
"""DEPRECATED"""
13+
14+
import warnings
15+
16+
warnings.warn(
17+
"The `scene_detector` submodule is deprecated, import from the base package instead.",
18+
DeprecationWarning,
19+
stacklevel=2,
20+
)
21+
22+
from scenedetect.detector import * # noqa: E402, F403

scenedetect/scene_manager.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ def on_new_scene(frame_img: numpy.ndarray, frame_num: int):
9595
SceneList,
9696
)
9797
from scenedetect.detector import SceneDetector
98+
99+
# TODO(v0.8): Remove the import * below, for backwards compatibility with v0.6 only.
100+
from scenedetect.output import * # noqa: F403
98101
from scenedetect.platform import tqdm
99102
from scenedetect.stats_manager import StatsManager
100103
from scenedetect.video_stream import VideoStream

scenedetect/video_splitter.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#
2+
# PySceneDetect: Python-Based Video Scene Detector
3+
# -------------------------------------------------------------------
4+
# [ Site: https://scenedetect.com ]
5+
# [ Docs: https://scenedetect.com/docs/ ]
6+
# [ Github: https://github.com/Breakthrough/PySceneDetect/ ]
7+
#
8+
# Copyright (C) 2014-2025 Brandon Castellano <http://www.bcastell.com>.
9+
# PySceneDetect is licensed under the BSD 3-Clause License; see the
10+
# included LICENSE file, or visit one of the above pages for details.
11+
#
12+
"""DEPRECATED"""
13+
14+
import warnings
15+
16+
warnings.warn(
17+
"The `video_splitter` submodule is deprecated, import from the base package instead.",
18+
DeprecationWarning,
19+
stacklevel=2,
20+
)
21+
22+
from scenedetect.output.video import * # noqa: E402, F403

tests/test_detectors.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,3 +224,12 @@ def test_detectors_with_stats(test_video_file):
224224
scene_manager.detect_scenes(video=video, end_time=end_time)
225225
scene_list = scene_manager.get_scene_list()
226226
assert len(scene_list) == initial_scene_len
227+
228+
229+
# TODO(v0.8): Remove this test during the removal of `scenedetect.scene_detector`.
230+
def test_deprecated_detector_module_emits_warning_on_import():
231+
SCENE_DETECTOR_WARNING = (
232+
"The `scene_detector` submodule is deprecated, import from the base package instead."
233+
)
234+
with pytest.warns(DeprecationWarning, match=SCENE_DETECTOR_WARNING):
235+
from scenedetect.scene_detector import SceneDetector as _

tests/test_output.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,3 +191,12 @@ def test_save_images_zero_width_scene(test_video_file, tmp_path: Path):
191191
total_images += 1
192192

193193
assert total_images == len([path for path in tmp_path.glob(image_name_glob)])
194+
195+
196+
# TODO(v0.8): Remove this test during the removal of `scenedetect.video_splitter`.
197+
def test_deprecated_output_modules_emits_warning_on_import():
198+
VIDEO_SPLITTER_WARNING = (
199+
"The `video_splitter` submodule is deprecated, import from the base package instead."
200+
)
201+
with pytest.warns(DeprecationWarning, match=VIDEO_SPLITTER_WARNING):
202+
from scenedetect.video_splitter import split_video_ffmpeg as _

tests/test_timecode.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,3 +300,12 @@ def test_precision():
300300
assert FrameTimecode(990, fps).get_timecode(precision=1, use_rounding=False) == "00:00:00.9"
301301
assert FrameTimecode(990, fps).get_timecode(precision=0, use_rounding=True) == "00:00:01"
302302
assert FrameTimecode(990, fps).get_timecode(precision=0, use_rounding=False) == "00:00:00"
303+
304+
305+
# TODO(v0.8): Remove this test during the removal of `scenedetect.scene_detector`.
306+
def test_deprecated_timecode_module_emits_warning_on_import():
307+
FRAME_TIMECODE_WARNING = (
308+
"The `frame_timecode` submodule is deprecated, import from the base package instead."
309+
)
310+
with pytest.warns(DeprecationWarning, match=FRAME_TIMECODE_WARNING):
311+
from scenedetect.frame_timecode import FrameTimecode as _

website/pages/changelog.md

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -685,30 +685,28 @@ Although there have been minimal changes to most API examples, there are several
685685

686686
#### Breaking
687687

688-
> Note: Imports that break when upgrading to 0.7 can usually be resolved by importing from `scenedetect` directly, rather than a submodule. The package structure has changed significantly in 0.7.
689-
690688
* Replace `frame_num` parameter (`int`) with `timecode` (`FrameTimecode`) in `SceneDetector` interface (#168)[https://github.com/Breakthrough/PySceneDetect/issues/168]:
691689
* The detector interface: `SceneDetector.process_frame()` and `SceneDetector.post_process()`
692690
* Statistics: `StatsManager.get_metrics()`, `StatsManager.set_metrics()`, and `StatsManager.metrics_exist()`
693691
* Move existing functionality to new submodules:
694-
* `scenedetect.scene_detector` moved to `scenedetect.detector`
695-
* `scenedetect.frame_timecode` moved to `scenedetect.common`
696-
* Output functionality from `scenedetect.scene_manager` moved to `scenedetect.output` [#463](https://github.com/Breakthrough/PySceneDetect/issues/463)
692+
* Detector interface in `scenedetect.scene_detector` moved to `scenedetect.detector`
693+
* Timecode types in `scenedetect.frame_timecode` moved to `scenedetect.common`
694+
* Image/HTML/CSV export in `scenedetect.scene_manager` moved to `scenedetect.output` [#463](https://github.com/Breakthrough/PySceneDetect/issues/463)
697695
* `scenedetect.video_splitter` moved to `scenedetect.output.video` [#463](https://github.com/Breakthrough/PySceneDetect/issues/463)
698696
* Remove deprecated module `scenedetect.video_manager`, use [the `scenedetect.open_video()` function](https://www.scenedetect.com/docs/head/api.html#scenedetect.open_video) instead
699697
* Remove deprecated parameter `base_timecode` from various functions, there is no need to provide it
700698
* Remove deprecated parameter `video_manager` from various functions, use `video` parameter instead
701699
* `FrameTimecode` fields `frame_num` and `framerate` are now read-only properties, construct a new `FrameTimecode` to change them
702700
* Remove `FrameTimecode.previous_frame()` method
703-
* Remove `SceneDetector.is_processing_required()` method, already had no effect in v0.6 as part of deprecation
701+
* Remove `SceneDetector.is_processing_required()` method
704702
* `SceneDetector` instances can now assume they always have frame data to process when `process_frame` is called
705703
* Remove deprecated `SparseSceneDetector` interface
706704
* Remove deprecated `SceneManager.get_event_list()` method
707-
* Remove deprecated `AdaptiveDetector.get_content_val()` method (the same information can be obtained using a `StatsManager`)
708-
* Remove deprecated `AdaptiveDetector` constructor argument `min_delta_hsv` (use `min_content_val` instead)
709-
* Remove `advance` parameter from `VideoStream.read()` (was always set to `True`, callers should handle caching frames now if required)
710-
* Remove `SceneDetector.stats_manager_required` property as it is no longer required
711-
* Remove `SceneDetector` is now a Python abstract class (`abc.ABC`) but all method names remain the same
705+
* Remove deprecated `AdaptiveDetector.get_content_val()` method (use `StatsManager` instead)
706+
* Remove deprecated `AdaptiveDetector` constructor arg `min_delta_hsv` (use `min_content_val` instead)
707+
* Remove `advance` parameter from `VideoStream.read()`
708+
* Remove `SceneDetector.stats_manager_required` property, no longer required
709+
* `SceneDetector` is now a [Python abstract class](https://docs.python.org/3/library/abc.html)
712710

713711
#### General
714712

0 commit comments

Comments
 (0)