Skip to content

Latest commit

 

History

History
124 lines (78 loc) · 7.5 KB

File metadata and controls

124 lines (78 loc) · 7.5 KB

scenedetect 🎬 Package

The scenedetect API is easy to integrate with most application workflows, while also being highly extensible. See the Getting Started section below for some common use cases and integrations. The scenedetect package contains several modules:

Most types/functions are also available directly from the scenedetect package to make imports simpler.

Warning

The PySceneDetect API is still under development. It is recommended that you pin the scenedetect version in your requirements to below the next major release:

scenedetect<0.7

Getting Started

PySceneDetect makes it very easy to find scene transitions in a video with the :func:`scenedetect.detect` function:

from scenedetect import detect, ContentDetector
path = "video.mp4"
scenes = detect(path, ContentDetector())
for (scene_start, scene_end) in scenes:
    print(f'{scene_start}-{scene_end}')

scenes now contains a list of :class:`FrameTimecode <scenedetect.frame_timecode.FrameTimecode>` pairs representing the start/end of each scene. Note that you can set show_progress=True when calling :func:`detect <scenedetect.detect>` to display a progress bar with estimated time remaining.

Here, we use :mod:`ContentDetector <scenedetect.detectors.content_detector>` to detect fast cuts. There are :ref:`many detector types <scenedetect-detectors>` which can be used to find fast cuts and fades in/out. PySceneDetect can also export scene data in various formats, and can :ref:`split the input video <scenedetect-video_splitter>` automatically if ffmpeg is available:

from scenedetect import detect, ContentDetector, split_video_ffmpeg
scene_list = detect("my_video.mp4", ContentDetector())
split_video_ffmpeg("my_video.mp4", scenes)

Recipes for common use cases can be found on Github including limiting detection time and storing per-frame metrics. For advanced workflows, start with the :ref:`SceneManager usage examples <scenedetect-scene_manager>`.

Functions

.. automodule:: scenedetect
    :members:

Module Reference

.. toctree::
    :maxdepth: 3
    :caption: PySceneDetect Module Documentation
    :name: fullapitoc

    api/detectors
    api/backends
    api/scene_manager
    api/video_splitter
    api/stats_manager
    api/frame_timecode
    api/scene_detector
    api/video_stream
    api/platform
    api/migration_guide


Logging

PySceneDetect outputs messages to a logger named pyscenedetect which does not have any default handlers. You can use :func:`scenedetect.init_logger <scenedetect.platform.init_logger>` with show_stdout=True or specify a log file (verbosity can also be specified) to attach some common handlers, or use logging.getLogger("pyscenedetect") and attach log handlers manually.

Migrating From 0.5

PySceneDetect 0.6 introduces several breaking changes which are incompatible with 0.5. See :ref:`Migration Guide <scenedetect-migration_guide>` for details on how to update your application. In addition, demonstrations of common use cases can be found in the tests/test_api.py file.