This page details how to transition a program written using PySceneDetect v0.5 to the new v0.6 API. It is recommended to review the new Quickstart and Example sections first, as they should cover the majority of use cases. Also see 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.
This page covers commonly used APIs which require updates to work with v0.6. Note that this page is not an exhaustive set of changes. For a complete list of breaking API changes, see the changelog.
In some places, a backwards compatibility layer has been added to avoid breaking most applications upon release. This should not be relied upon, and will be removed in the future. You can call
scenedetect.platform.init_logger(show_stdout=True) or attach a custom log handler to the
'pyscenedetect' logger to help find these cases.
from scenedetect import open_video video = open_video(video.mp4')
from scenedetect import open_video, SceneManager, ContentDetector video = open_video('video.mp4') scene_manager = SceneManager() scene_manager.add_detector(ContentDetector(threshold=threshold)) scene_manager.detect_scenes(video) print(scene_manager.get_scene_list())
scenedetect.backends for examples of how to create specific backends. Where previously a list of paths was accepted, now only a single string should be provided.
Seeking and Start/End Times¶
Instead of setting the duration or end time via the VideoManager, now set the duration or end_time parameters when calling
from scenedetect import open_video, SceneManager, ContentDetector video = open_video('video.mp4') # Can be seconds (float), frame # (int), or FrameTimecode start_time, end_time = 2.5, 5.0 scene_manager = SceneManager() scene_manager.add_detector(ContentDetector(threshold=threshold)) video.seek(start_time) # Note there is also a `duration` parameter that can also be set. # If neither `duration` nor `end_time` is provided, the video will # be processed from its current position until the end. scene_manager.detect_scenes(video, end_time=end_time) print(scene_manager.get_scene_list())
The downscale_factor parameter has been removed from
save_images (use the scale parameter instead). To achieve the same result as the previous version, set scale to 1.0 / downscale_factor.
suppress_output is now show_output, default is False
hide_progress is now show_progress, default is False
This makes the API consistent with that of
The base_timecode argument has been removed from
save_to_csv. It is no longer required.
The video_manager parameter has been removed and is no longer required when constructing an
The block_size argument has been removed from the
ThresholdDetector constructor. It is no longer required.