Skip to content

Commit 8b4efe6

Browse files
committed
[docs] Fix some migration guide errors
1 parent a02f4be commit 8b4efe6

4 files changed

Lines changed: 22 additions & 22 deletions

File tree

docs/api/migration_guide.rst

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ The ``frame_num`` parameter (``int``) has been replaced with ``timecode`` (:clas
8080
def process_frame(self, timecode: FrameTimecode, frame_img) -> List[FrameTimecode]:
8181
...
8282
83-
The same change applies to ``post_process()``. If you need the frame number, use ``timecode.frame_num``.
83+
The same change applies to ``post_process()``. Using units of time instead of frame numbers is critical for temporal accuracy. If you need the frame number, use ``timecode.frame_num`` to the timecode to an integer.
8484

8585
``SceneDetector`` is Now Abstract
8686
-----------------------------------------------------------------------
@@ -104,20 +104,19 @@ The following have been removed from the ``SceneDetector`` interface:
104104
Read-Only Properties
105105
-----------------------------------------------------------------------
106106

107-
``frame_num`` and ``framerate`` are now read-only properties. To change them, construct a new ``FrameTimecode``:
107+
:attr:`~scenedetect.common.FrameTimecode.frame_num` and :attr:`~scenedetect.common.FrameTimecode.framerate` are now read-only properties. To change them, construct a new ``FrameTimecode``:
108108

109109
.. code:: python
110110
111-
# v0.6 - direct assignment
112-
tc.frame_num = 100 # No longer works
113-
114-
# v0.7 - construct new instance
115-
tc = FrameTimecode(100, tc.framerate)
111+
tc = FrameTimecode(0, 24.0)
112+
# Can no longer reassign frame_num, must create a new FrameTimecode instead:
113+
#tc.frame_num = 100
114+
tc = FrameTimecode(100, tc)
116115
117116
New Properties
118117
-----------------------------------------------------------------------
119118

120-
Access ``frame_num``, ``framerate``, and ``seconds`` as properties instead of getter methods:
119+
Access :attr:`~scenedetect.common.FrameTimecode.frame_num`, :attr:`~scenedetect.common.FrameTimecode.framerate`, and :attr:`~scenedetect.common.FrameTimecode.seconds` as properties instead of getter methods:
121120

122121
.. code:: python
123122
@@ -139,7 +138,7 @@ Framerate and Timestamp Changes
139138
Rational Framerates
140139
-----------------------------------------------------------------------
141140

142-
``VideoStream.frame_rate`` now returns a ``Fraction`` instead of ``float``. Common NTSC rates (23.976, 29.97, 59.94) are automatically detected from float values:
141+
:attr:`~scenedetect.video_stream.VideoStream.frame_rate` now returns a ``Fraction`` instead of ``float``. Common NTSC rates (23.976, 29.97, 59.94) are automatically detected from float values:
143142

144143
.. code:: python
145144
@@ -151,16 +150,16 @@ Rational Framerates
151150
PTS-Backed Timestamps
152151
-----------------------------------------------------------------------
153152

154-
All backends now return presentation timestamp (PTS) backed values from ``VideoStream.position``. This enables correct handling of VFR videos.
153+
All backends now return presentation timestamp (PTS) backed values from :attr:`~scenedetect.video_stream.VideoStream.position`. This enables correct handling of VFR videos.
155154

156-
``FrameTimecode`` has new ``time_base`` and ``pts`` properties for accessing the underlying timing information. For VFR videos, ``frame_num`` is now an approximation based on PTS-derived time rather than a sequential count.
155+
``FrameTimecode`` has new :attr:`~scenedetect.common.FrameTimecode.time_base` and :attr:`~scenedetect.common.FrameTimecode.pts` properties for accessing the underlying timing information. For VFR videos, :attr:`~scenedetect.common.FrameTimecode.frame_num` is now an approximation based on PTS-derived time rather than a sequential count.
157156

158157

159158
=======================================================================
160159
``StatsManager`` Changes
161160
=======================================================================
162161

163-
The ``StatsManager`` methods ``get_metrics()``, ``set_metrics()``, and ``metrics_exist()`` now formally accept either a ``FrameTimecode`` or a plain ``int`` frame number for the timecode argument. Passing a ``FrameTimecode`` is preferred and matches the detector interface; the ``int`` form is retained for compatibility with the deprecated ``load_from_csv()`` path, which keys metrics by integer frame number.
162+
The ``StatsManager`` methods :meth:`~scenedetect.stats_manager.StatsManager.get_metrics`, :meth:`~scenedetect.stats_manager.StatsManager.set_metrics`, and :meth:`~scenedetect.stats_manager.StatsManager.metrics_exist` now formally accept either a ``FrameTimecode`` or a plain ``int`` frame number for the timecode argument. Passing a ``FrameTimecode`` is preferred and matches the detector interface; the ``int`` form is retained for compatibility with the deprecated ``load_from_csv()`` path, which keys metrics by integer frame number.
164163

165164
``StatsManager.load_from_csv()`` also accepts ``os.PathLike`` (e.g. ``pathlib.Path``) in addition to ``str`` / ``bytes`` / file handles.
166165

@@ -169,21 +168,21 @@ The ``StatsManager`` methods ``get_metrics()``, ``set_metrics()``, and ``metrics
169168
``SceneDetector`` Annotation Fixes
170169
=======================================================================
171170

172-
``SceneDetector.post_process()`` now declares its parameter as ``timecode: FrameTimecode`` (previously typed as ``int``). The method already received a ``FrameTimecode`` at runtime and concrete detectors (e.g. ``ThresholdDetector``, ``ContentDetector``) already used the ``FrameTimecode`` type - only the abstract-base-class annotation was inconsistent. No call-site changes are needed; this just brings the signature into agreement with the documented and actual behavior.
171+
:meth:`~scenedetect.detector.SceneDetector.post_process` now declares its parameter as ``timecode: FrameTimecode`` (previously typed as ``int``). The method already received a ``FrameTimecode`` at runtime and concrete detectors (e.g. ``ThresholdDetector``, ``ContentDetector``) already used the ``FrameTimecode`` type - only the abstract-base-class annotation was inconsistent. No call-site changes are needed; this just brings the signature into agreement with the documented and actual behavior.
173172

174173

175174
=======================================================================
176175
``SceneManager.detect_scenes()`` Time Arguments
177176
=======================================================================
178177

179-
The ``duration`` and ``end_time`` arguments now formally accept ``int`` (frames), ``float`` (seconds), ``str`` (timecode string, e.g. ``"00:00:05.000"``), or ``FrameTimecode``. The internal code already validated these forms; the annotation was previously narrower than the documented behavior.
178+
The ``duration`` and ``end_time`` arguments of :meth:`~scenedetect.scene_manager.SceneManager.detect_scenes` now formally accept ``int`` (frames), ``float`` (seconds), ``str`` (timecode string, e.g. ``"00:00:05.000"``), or ``FrameTimecode``. The internal code already validated these forms; the annotation was previously narrower than the documented behavior.
180179

181180
.. code:: python
182181
183182
# All of these were always supported at runtime; now they type-check too:
184-
scene_manager.detect_scenes(video=video, end_time=15.0) # seconds
185-
scene_manager.detect_scenes(video=video, end_time=1500) # frames
186-
scene_manager.detect_scenes(video=video, end_time="00:01:00") # timecode
183+
scene_manager.detect_scenes(video, end_time=15.0) # seconds
184+
scene_manager.detect_scenes(video, end_time=1500) # frames
185+
scene_manager.detect_scenes(video, end_time="00:01:00") # timecode
187186
188187
189188
=======================================================================
@@ -212,7 +211,7 @@ The following deprecated APIs have been fully removed in v0.7:
212211
* - ``video_manager`` parameter (various functions)
213212
- Use ``video`` parameter instead
214213
* - ``SceneManager.get_event_list()``
215-
- Use ``SceneManager.get_cut_list()`` or ``SceneManager.get_scene_list()``
214+
- Use :meth:`~scenedetect.scene_manager.SceneManager.get_cut_list` or :meth:`~scenedetect.scene_manager.SceneManager.get_scene_list`
216215
* - ``AdaptiveDetector.get_content_val()``
217216
- Use ``StatsManager`` to query metrics
218217
* - ``AdaptiveDetector(min_delta_hsv=...)``

docs/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
extensions = [
3838
"sphinx.ext.napoleon",
3939
"sphinx.ext.autodoc",
40+
"sphinx_copybutton",
4041
]
4142

4243
autoclass_content = "both"

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ dependencies = [
5252
pyav = ["av>=9.2"]
5353
moviepy = ["moviepy"]
5454
dev = ["av>=9.2", "moviepy", "pytest>=7.0"]
55-
docs = ["Sphinx==7.0.1"]
55+
docs = ["Sphinx==7.0.1", "sphinx-copybutton==0.5.2"]
5656
website = ["mkdocs==1.5.2", "jinja2>=3.1.6"]
5757

5858
[project.urls]

website/pages/changelog.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -669,16 +669,16 @@ Development
669669

670670
### Release Notes
671671

672-
PySceneDetect is a major breaking release which overhauls how timestamps are handled throughout the API. This allows PySceneDetect to properly process variable framerate (VFR) videos. A significant amount of technical debt has been addressed, including removal of deprecated or overly complicated APIs.
672+
PySceneDetect 0.7 is a **major breaking release** which overhauls how timestamps are handled. This allows PySceneDetect to properly process variable framerate (VFR) videos. A significant amount of technical debt has been addressed, including removal of deprecated or overly complicated APIs.
673673

674674
Care was taken to minimize changes for most common API uses, however more advanced use cases may run into breaking changes. Please review [the Migration Guide](https://www.scenedetect.com/docs/0.7/api/migration_guide.html) when updating from v0.6. Minimum supported Python version is now **Python 3.10**.
675675

676676
### CLI Changes
677677

678678
- [feature] VFR videos are handled correctly by the OpenCV and PyAV backends, and should work correctly with default parameters
679+
- [feature] All CLI options which used to accept frame numbers only now accept seconds (e.g. `0.6s`) and timecodes (e.g. `00:00:00.600`) [#531](https://github.com/Breakthrough/PySceneDetect/issues/531)
679680
- [feature] New `save-fcp` command allows exporting in Final Cut Pro format (FCP7/FCPX) [#156](https://github.com/Breakthrough/PySceneDetect/issues/156)
680-
- [feature] `--min-scene-len`/`-m` and `save-images --frame-margin`/`-m` now accept seconds (e.g. `0.6s`) and timecodes (e.g. `00:00:00.600`) in addition to a frame count [#531](https://github.com/Breakthrough/PySceneDetect/issues/531)
681-
- [feature] `save-edl` accepts a new `--start-timecode`/`-s` flag (SMPTE `HH:MM:SS:FF` or 8-digit `HHMMSSFF`) to stamp every event with a custom start timecode so generated EDLs align with the source media's on-screen timecode [#515](https://github.com/Breakthrough/PySceneDetect/issues/515)
681+
- [feature] Add `save-edl` option `--start-timecode`/`-s` to providde a custom start timecode for generated EDLs, supports SMPTE `HH:MM:SS:FF` or 8-digit `HHMMSSFF` input [#515](https://github.com/Breakthrough/PySceneDetect/issues/515)
682682
- [bugfix] Fix floating-point precision error in `save-otio` output where frame values near integer boundaries (e.g. `90.00000000000001`) were serialized with spurious precision
683683
- [bugfix] Add mitigation for transient `OSError` in the MoviePy backend as it is susceptible to subprocess pipe races on slow or heavily loaded systems [#496](https://github.com/Breakthrough/PySceneDetect/issues/496)
684684
- [bugfix] `detect-threshold` cut frame numbers are now backend-deterministic; previously the cut could differ by 1 frame between PyAV and OpenCV when the fade midpoint landed on a `.5` rounding boundary (PyAV uses sub-microsecond PTS, OpenCV uses millisecond-truncated `CAP_PROP_POS_MSEC`)

0 commit comments

Comments
 (0)