Install & Compatibility
Where this runs
tested against v0.7.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
py 3.10
✕ build_error
✓ 6.35s
py 3.11
✕ build_error
✓ 5.85s
py 3.12
✕ build_error
✓ 5.9s
py 3.13
✕ build_error
✓ 5.8s
323MB installed
● package 323MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
SceneManager
✓ from scenedetect import SceneManager
✗ from scenedetect import VideoManager
ContentDetector
✓ from scenedetect import ContentDetector
AdaptiveDetector
✓ from scenedetect import AdaptiveDetector
This quickstart demonstrates how to initialize PySceneDetect, add a ContentDetector (the most common type), process a video, and save the detected scenes to a CSV file. Remember to replace 'path/to/your/video.mp4' with a valid video file path. For full functionality and broader video format support, it's recommended to install with optional backends like OpenCV and PyAV (`pip install scenedetect[opencv,pyav]`).
import os
from scenedetect import VideoManager
from scenedetect import SceneManager
from scenedetect.detectors import ContentDetector
from scenedetect.stats_manager import StatsManager
from scenedetect.scene_manager import save_csv
# IMPORTANT: Replace 'path/to/your/video.mp4' with an actual video file.
# For local testing without providing a video, this will create a dummy file,
# but actual scene detection requires a valid video.
VIDEO_PATH = os.environ.get('SCENEDETECT_TEST_VIDEO', 'dummy_video.mp4')
OUTPUT_DIR = '.' # Current directory for output CSV
# Create a dummy file if the video path doesn't exist, to make code runnable
# without a real video for initial syntax checks.
# A real video is required for meaningful scene detection.
if not os.path.exists(VIDEO_PATH) or not os.path.getsize(VIDEO_PATH) > 0:
print(f"Warning: Video file '{VIDEO_PATH}' not found or empty. Creating a dummy file.")
print("For actual scene detection, set SCENEDETECT_TEST_VIDEO or provide a real video.")
with open(VIDEO_PATH, 'w') as f:
f.write("This is a dummy file. Replace with a real video for scene detection.")
video_manager = VideoManager([VIDEO_PATH])
stats_manager = StatsManager()
scene_manager = SceneManager(stats_manager)
# Add ContentDetector (default detector)
scene_manager.add_detector(ContentDetector())
try:
# Set downscale factor for faster processing (e.g., 1/2 resolution)
video_manager.set_downscale_factor()
# Start video processing (loads frames or prepares for frame-by-frame)
video_manager.start()
# Perform scene detection
scene_manager.detect_scenes(frame_source=video_manager)
# Obtain list of scenes
scene_list = scene_manager.get_scene_list()
print(f'Detected {len(scene_list)} scenes.')
# Example: Save detected scenes to a CSV file
output_csv_path = os.path.join(OUTPUT_DIR, 'scenes.csv')
save_csv(output_csv_path, scene_list, output_dir=OUTPUT_DIR) # output_dir argument added for clarity
print(f'Scene list saved to {output_csv_path}')
except Exception as e:
print(f"An error occurred during scene detection: {e}")
finally:
video_manager.release()
scenedetect --version
Upgrade
Version history
0.7.1latest on PyPI · released Jul 22, 2026
Audit
Dependencies
pythonrequiredRequires Python 3.7 or newer. Older versions will cause installation errors.