Video Backends (CLI)¶
PySceneDetect supports modular video input backends. You can configure backend options in a config file. Run scenedetect version to see which backends are installed.
The scenedetect command generates outputs after scene detection finishes. Most output commands require an input that you can replay, and preferably seek. Some backends support network streams and other input types, but live streams require the Python API.
OpenCV¶
See also
Python API: VideoStreamCv2 | Config File: [backend-opencv]
[Default]
The OpenCV backend (usually opencv-python) uses OpenCV’s VideoCapture to decode video. Select it with -b opencv on the command line, or set backend = opencv under [global] in your config file.
OpenCV is fast and reliable for most files, though it can occasionally fail on videos with multiple audio tracks or minor frame corruption. You can use opencv-python, opencv-python-headless, or a custom cv2 build.
The OpenCV backend also supports image sequences (for example, frame%03d.jpg to load frame001.jpg, frame002.jpg, frame003.jpg, and so on). Set the frame rate manually with -f / --frame-rate so timecodes are accurate.
Variable frame rate (VFR) video is supported. Scene detection uses PTS-derived timestamps from CAP_PROP_POS_MSEC for accurate timecodes. Seeking compensates for OpenCV’s average-fps seek approximation so output timecodes stay accurate across the full video.
PyAV¶
See also
Python API: VideoStreamAv | Config File: [backend-pyav]
The PyAV backend (av package) handles multiple audio tracks and frame decode errors more reliably than OpenCV.
Variable frame rate (VFR) video is fully supported. PyAV reads native PTS timestamps directly from the video container, giving the most accurate timecodes for VFR content.
Select this backend with -b pyav on the command line, or set backend = pyav under [global] in your config file.
MoviePy¶
See also
Python API: VideoStreamMoviePy
MoviePy runs ffmpeg as a subprocess and supports many input types. Inputs that support seeking, such as image sequences or AviSynth scripts, work with most commands.
Warning
The MoviePy backend is experimental and is not included in the Windows installer. To use it, install PySceneDetect with pip (pip install "scenedetect[moviepy]").
Variable frame rate (VFR) video is not supported. MoviePy assumes a constant frame rate, so timecodes for VFR content will be inaccurate. Use the PyAV or OpenCV backend instead.
Select this backend with -b moviepy on the command line, or set backend = moviepy under [global] in your config file.