Skip to content

Commit

Permalink
[docs] Update outdated documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
Breakthrough committed Sep 16, 2024
1 parent bfed4bd commit b3b5660
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 32 deletions.
33 changes: 2 additions & 31 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,38 +79,9 @@ Now that we know where each scene is, we can also :ref:`split the input video <s
scene_list = detect("my_video.mp4", ContentDetector())
split_video_ffmpeg("my_video.mp4", scene_list)
For more customizable scene cut/shot detection pipelines, start with :ref:`the SceneManager examples`. Recipes for common use cases can be :ref:`found on Github <tests/test_api.py <https://github.com/Breakthrough/PySceneDetect/blob/v0.6.4-release/tests/test_api.py>`_.


.. _scenedetect-detailed_example:

=======================================================================
Example
=======================================================================

In this example, we create a function ``find_scenes()`` which will load a video, detect the scenes, and return a list of tuples containing the (start, end) timecodes of each detected scene. Note that you can modify the `threshold` argument to modify the sensitivity of the :class:`ContentDetector <scenedetect.detectors.content_detector.ContentDetector>`, or use other detection algorithms (e.g. :class:`ThresholdDetector <scenedetect.detectors.threshold_detector.ThresholdDetector>`, :class:`AdaptiveDetector <scenedetect.detectors.adaptive_detector.AdaptiveDetector>`).

.. code:: python
from scenedetect import SceneManager, open_video, ContentDetector
def find_scenes(video_path, threshold=27.0):
video = open_video(video_path)
scene_manager = SceneManager()
scene_manager.add_detector(
ContentDetector(threshold=threshold))
# Detect all scenes in video from current position to end.
scene_manager.detect_scenes(video)
# `get_scene_list` returns a list of start/end timecode pairs
# for each scene that was found.
return scene_manager.get_scene_list()
Using a :class:`SceneManager <scenedetect.scene_manager.SceneManager>` directly allows tweaking the Parameters passed to :meth:`detect_scenes <scenedetect.scene_manager.SceneManager.detect_scenes>` including setting a limit to the number of frames to process, which is useful for live streams/camera devices. You can also combine detection algorithms or create new ones from scratch.

For a more advanced example of using the PySceneDetect API to with a stats file (to save per-frame metrics to disk and/or speed up multiple passes of the same video), take a look at the :ref:`example in the SceneManager reference<scenedetect-scene_manager>`.

In addition to module-level examples, demonstrations of some common use cases can be found in the `tests/test_api.py <https://github.com/Breakthrough/PySceneDetect/blob/v0.6.4-release/tests/test_api.py>`_ file.
example of using the PySceneDetect API to with a stats file (to save per-frame metrics to disk and/or speed up multiple passes of the same video), take a look at the :ref:`example in the SceneManager
Recipes for common use cases can be :ref:`found on Github <https://github.com/Breakthrough/PySceneDetect/blob/v0.6.4-release/tests/test_api.py>`_ including limiting detection time and storing per-frame metrics. For advanced workflows, start with the :ref:`examples in the SceneManager reference <scenedetect-scene_manager>`.

=======================================================================
Functions
Expand Down
2 changes: 1 addition & 1 deletion docs/api/migration_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Migration Guide
---------------------------------------------------------------

This page details how to transition a program written using PySceneDetect 0.5 to the new 0.6 API. It is recommended to review the new :ref:`Quickstart <scenedetect-quickstart>` and :ref:`Example <scenedetect-detailed_example>` sections first, as they should cover the majority of use cases. Also see `tests/test_api.py <https://github.com/Breakthrough/PySceneDetect/blob/v0.6.4-release/tests/test_api.py>`_ for a set of demonstrations covering many high level use cases.
This page details how to transition a program written using PySceneDetect 0.5 to the new 0.6 API. It is recommended to review the new :ref:`Example <scenedetect-example>` section first, as it covers the majority of use cases. Also see `tests/test_api.py <https://github.com/Breakthrough/PySceneDetect/blob/v0.6.4-release/tests/test_api.py>`_ for a set of demonstrations covering many high level use cases.

PySceneDetect v0.6 is a major step towards a more stable and simplified API. The biggest change to existing workflows is how video input is handled, and that Python 3.6 or above is now required.

Expand Down

0 comments on commit b3b5660

Please sign in to comment.