### Install Headless PySceneDetect Source: https://github.com/breakthrough/pyscenedetect/blob/main/website/pages/faq.md Installation command for server environments lacking GUI libraries. ```bash pip install scenedetect-headless ``` -------------------------------- ### Install PySceneDetect Source: https://github.com/breakthrough/pyscenedetect/blob/main/README.md Install the package via pip. ```bash pip install scenedetect --upgrade ``` -------------------------------- ### Install optional Python packages Source: https://github.com/breakthrough/pyscenedetect/blob/main/website/pages/download.md Command to install optional packages for extended functionality. ```bash pip install av ``` -------------------------------- ### Example PySceneDetect Configuration Source: https://github.com/breakthrough/pyscenedetect/blob/main/docs/cli/config_file.rst An example scenedetect.cfg file showing various options for different detectors and processing steps. This can be used to customize PySceneDetect's behavior. ```ini [global] default-detector = detect-content min-scene-len = 0.8s [detect-content] threshold = 26 [split-video] # Use higher quality encoding preset = slow rate-factor = 17 filename = $VIDEO_NAME-Clip-$SCENE_NUMBER [save-images] format = jpeg quality = 80 num-images = 3 ``` -------------------------------- ### Time-based Video Processing Examples Source: https://github.com/breakthrough/pyscenedetect/blob/main/docs/cli.rst Examples of using the 'time' command to restrict video processing to specific segments using different time formats. ```bash scenedetect -i video.mp4 time --end 00:01:00 ``` ```bash scenedetect -i video.mp4 time --duration 60.0 ``` ```bash scenedetect -i video.mp4 time --start 0 --end 1000 ``` -------------------------------- ### Example configuration file Source: https://github.com/breakthrough/pyscenedetect/blob/main/website/pages/cli.md A sample configuration file demonstrating global settings and specific command options. ```ini [global] default-detector = detect-content min-scene-len = 0.8s [detect-content] threshold = 32 weights = 1.0 0.5 1.0 0.2 [split-video] preset = slow rate-factor = 17 # Don't need to use quotes even if filename contains spaces filename = $VIDEO_NAME-Clip-$SCENE_NUMBER [save-images] format = jpeg quality = 80 num-images = 3 ``` -------------------------------- ### Install Custom OpenCV Variant Source: https://github.com/breakthrough/pyscenedetect/blob/main/website/pages/faq.md Commands to install a specific OpenCV variant while maintaining version compatibility. ```bash pip install scenedetect pip install "opencv-contrib-python==$(pip show opencv-python | grep ^Version | cut -d' ' -f2)" ``` -------------------------------- ### Run detect-hash command Source: https://github.com/breakthrough/pyscenedetect/blob/main/docs/cli.rst Examples for using the perceptual hashing algorithm to detect fast cuts in a video. ```bash scenedetect -i video.mp4 detect-hash ``` ```bash scenedetect -i video.mp4 detect-hash --size 32 --lowpass 3 ``` -------------------------------- ### Configuration File Syntax Source: https://github.com/breakthrough/pyscenedetect/blob/main/docs/cli/config_file.rst Demonstrates the basic syntax for PySceneDetect configuration files, including sections, options, and comments. Lines starting with '#' are ignored. ```ini [command] option_a = value #comment option_b = 1 ``` -------------------------------- ### Run detect-threshold command Source: https://github.com/breakthrough/pyscenedetect/blob/main/docs/cli.rst Examples for using average pixel values to detect fade-in and fade-out events. ```bash scenedetect -i video.mp4 detect-threshold ``` ```bash scenedetect -i video.mp4 detect-threshold --threshold 15 ``` -------------------------------- ### Install Python package dependencies Source: https://github.com/breakthrough/pyscenedetect/blob/main/website/pages/download.md Commands to install the required Python packages for PySceneDetect. ```bash pip install opencv-python ``` ```bash pip install numpy ``` ```bash pip install click ``` ```bash pip install tqdm ``` ```bash pip install platformdirs ``` -------------------------------- ### Run detect-hist command Source: https://github.com/breakthrough/pyscenedetect/blob/main/docs/cli.rst Examples for using YUV histogram differencing to detect fast cuts in a video. ```bash scenedetect -i video.mp4 detect-hist ``` ```bash scenedetect -i video.mp4 detect-hist --threshold 0.1 --bins 240 ``` -------------------------------- ### Verify Python package installation Source: https://github.com/breakthrough/pyscenedetect/blob/main/website/pages/download.md Commands to verify that OpenCV and Numpy are correctly installed and accessible within a Python interpreter. ```python import numpy import cv2 ``` -------------------------------- ### Run via Docker Source: https://github.com/breakthrough/pyscenedetect/blob/main/README.md Execute PySceneDetect using the official Docker image without local installation. ```bash docker run --rm -v "$(pwd):/files" ghcr.io/breakthrough/pyscenedetect -i /files/video.mp4 split-video -o /files ``` -------------------------------- ### Full Configuration Template Source: https://github.com/breakthrough/pyscenedetect/blob/main/docs/cli/config_file.rst A comprehensive template for a scenedetect.cfg file, listing all possible configuration options and their default values. This can be used as a starting point for creating a custom configuration. ```ini [global] default-detector = detect-content min-scene-len = 0.8s [detect-content] threshold = 26 [split-video] # Use higher quality encoding preset = slow rate-factor = 17 filename = $VIDEO_NAME-Clip-$SCENE_NUMBER [save-images] format = jpeg quality = 80 num-images = 3 [detect-adaptive-binary] threshold = 30 prev-next-diff = 5 min-scene-len = 0.8s [detect-average-hash] threshold = 5 min-scene-len = 0.8s [detect-blur] threshold = 0.5 min-scene-len = 0.8s [detect-block-diff] threshold = 15 min-scene-len = 0.8s [detect-color] threshold = 0.01 min-scene-len = 0.8s [detect-frame-size] threshold = 10000 min-scene-len = 0.8s [detect-magic-number] threshold = 0.9 min-scene-len = 0.8s [detect-scene] threshold = 100 min-scene-len = 0.8s [detect-skip] threshold = 100 min-scene-len = 0.8s [detect-ssim] threshold = 0.95 min-scene-len = 0.8s [detect-threshold] threshold = 26 min-scene-len = 0.8s [detect-bitwise] threshold = 10 min-scene-len = 0.8s [split-video] filename = $VIDEO_NAME-Clip-$SCENE_NUMBER [save-images] format = jpeg quality = 80 num-images = 3 [cache] cache-dir = ~/.cache/pyscenedetect [progress-bar] width = 50 [stats] stats-dir = . [output] output-dir = . [log] log-dir = . [encoding] encoder = libx264 [ffmpeg] ffmpeg-path = [ffprobe] ffprobe-path = ``` -------------------------------- ### Iterate Over Detected Scenes Source: https://github.com/breakthrough/pyscenedetect/blob/main/README.md Print start and end timecodes for each detected scene. ```python from scenedetect import detect, ContentDetector scene_list = detect('my_video.mp4', ContentDetector()) for i, scene in enumerate(scene_list): print(' Scene %2d: Start %s / Frame %d, End %s / Frame %d' % ( i+1, scene[0].get_timecode(), scene[0].frame_num, scene[1].get_timecode(), scene[1].frame_num,)) ``` -------------------------------- ### Skip video duration Source: https://github.com/breakthrough/pyscenedetect/blob/main/website/pages/cli.md Starts processing the video after skipping the specified initial duration. ```bash scenedetect -i video.mp4 time -s 10s ``` -------------------------------- ### Process Video with Docker Source: https://github.com/breakthrough/pyscenedetect/blob/main/website/pages/download.md Mount a local directory to the container to process a video file and output the results. ```bash docker run --rm -v "$(pwd):/files" ghcr.io/breakthrough/pyscenedetect \ -i /files/video.mp4 detect-adaptive split-video -o /files ``` -------------------------------- ### Run CLI Commands Source: https://github.com/breakthrough/pyscenedetect/blob/main/README.md Perform common video analysis tasks using the command-line interface. ```bash scenedetect -i video.mp4 split-video ``` ```bash scenedetect -i video.mp4 save-images ``` ```bash scenedetect -i video.mp4 time -s 10s ``` -------------------------------- ### Update open_video keyword arguments Source: https://github.com/breakthrough/pyscenedetect/blob/main/docs/api/migration_guide.rst Migrate from the deprecated framerate argument to the new frame_rate argument. ```python # v0.6 - will still work but will be removed in a future version video = open_video("video.mp4", framerate=30.0) # v0.7 video = open_video("video.mp4", frame_rate=30.0) ``` -------------------------------- ### Split video using command line Source: https://github.com/breakthrough/pyscenedetect/blob/main/website/pages/index.md Use the scenedetect command to split a video file based on fast cuts. ```bash scenedetect -i video.mp4 split-video ``` -------------------------------- ### Pull and Verify Docker Image Source: https://github.com/breakthrough/pyscenedetect/blob/main/website/pages/download.md Download the official PySceneDetect container image and verify the version. ```bash docker pull ghcr.io/breakthrough/pyscenedetect docker run --rm ghcr.io/breakthrough/pyscenedetect version ``` -------------------------------- ### Verify Fraction-based framerate Source: https://github.com/breakthrough/pyscenedetect/blob/main/docs/api/migration_guide.rst VideoStream frame_rate now returns a Fraction, ensuring precision for common NTSC rates. ```python from fractions import Fraction video = open_video("video.mp4") assert isinstance(video.frame_rate, Fraction) # e.g. Fraction(24000, 1001) instead of 23.976023976... ``` -------------------------------- ### Generate stats file for threshold tuning Source: https://github.com/breakthrough/pyscenedetect/blob/main/website/pages/cli.md Use the --stats flag to output scene detection metrics to a CSV file for analysis. ```bash scenedetect --input goldeneye.mp4 --stats goldeneye.stats.csv detect-adaptive ``` -------------------------------- ### Perform adaptive scene detection Source: https://github.com/breakthrough/pyscenedetect/blob/main/website/pages/cli.md Runs adaptive scene detection on a video file, generating a CSV scene list and saving representative images. ```bash scenedetect --input goldeneye.mp4 detect-adaptive list-scenes save-images ``` -------------------------------- ### Download BBC Dataset Source: https://github.com/breakthrough/pyscenedetect/blob/main/benchmark/README.md Downloads and extracts annotations and video files for the BBC dataset. ```bash # annotations wget -O BBC/fixed.zip https://zenodo.org/records/14873790/files/fixed.zip unzip BBC/fixed.zip -d BBC rm -rf BBC/fixed.zip # videos wget -O BBC/videos.zip https://zenodo.org/records/14873790/files/videos.zip unzip BBC/videos.zip -d BBC rm -rf BBC/videos.zip ``` -------------------------------- ### Run single detector benchmark Source: https://github.com/breakthrough/pyscenedetect/blob/main/benchmark/README.md Executes a single detector against a specified dataset. ```bash python -m benchmark --detector detect-content --dataset BBC ``` -------------------------------- ### Run Benchmarks and Parameter Sweeps Source: https://github.com/breakthrough/pyscenedetect/blob/main/website/pages/benchmarks.md Execute performance tests on specific detectors or perform grid searches over parameter ranges. ```bash # Score one detector on one dataset: python -m benchmark --detector detect-content --dataset BBC # Grid sweep over detector parameters: python -m benchmark.sweep --detector detect-content --dataset BBC \ --params "threshold=15:35:1;min_scene_len=0.0:1.0:0.1" ``` -------------------------------- ### List Scenes CLI Commands Source: https://github.com/breakthrough/pyscenedetect/blob/main/docs/cli.rst Generate a CSV file containing scene cut information. Use --skip-cuts to produce an RFC 4180 compliant file. ```bash scenedetect -i video.mp4 list-scenes ``` ```bash scenedetect -i video.mp4 list-scenes --skip-cuts ``` -------------------------------- ### Split Video into Clips Source: https://github.com/breakthrough/pyscenedetect/blob/main/website/pages/cli.md Automatically split an input video file into clips using the default ffmpeg or mkvmerge backend. ```bash scenedetect -i goldeneye.mp4 split-video ``` -------------------------------- ### detect(video_path, detector, show_progress=False) Source: https://github.com/breakthrough/pyscenedetect/blob/main/docs/api.rst Performs scene detection on a video file using a specified detector. Returns a list of FrameTimecode pairs representing scene boundaries. ```APIDOC ## detect(video_path, detector, show_progress=False) ### Description Detects scenes in a video file. Returns a list of start/end timecode pairs. ### Parameters - **video_path** (str) - Required - Path to the input video file. - **detector** (Detector) - Required - The detector instance (e.g., ContentDetector) to use. - **show_progress** (bool) - Optional - If True, displays a progress bar with estimated time remaining. ``` -------------------------------- ### Update SceneManager.detect_scenes time arguments Source: https://github.com/breakthrough/pyscenedetect/blob/main/docs/api/migration_guide.rst Demonstrates the supported input types for duration and end_time arguments in detect_scenes, which now correctly type-check for seconds, frames, and timecode strings. ```python # All of these were always supported at runtime; now they type-check too: scene_manager.detect_scenes(video, end_time=15.0) # seconds scene_manager.detect_scenes(video, end_time=1500) # frames scene_manager.detect_scenes(video, end_time="00:01:00") # timecode ``` -------------------------------- ### Cite the AutoShot dataset Source: https://github.com/breakthrough/pyscenedetect/blob/main/benchmark/README.md BibTeX entry for the AutoShot dataset used in the benchmark. ```bibtex @InProceedings{autoshot_dataset, author = {Wentao Zhu and Yufang Huang and Xiufeng Xie and Wenxian Liu and Jincan Deng and Debing Zhang and Zhangyang Wang and Ji Liu}, title = {AutoShot: A Short Video Dataset and State-of-the-Art Shot Boundary Detection}, booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR) Workshops}, year = {2023}, } ``` -------------------------------- ### Advanced Scene Management Source: https://github.com/breakthrough/pyscenedetect/blob/main/README.md Implement custom scene detection and splitting using the SceneManager class. ```python from scenedetect import open_video, SceneManager, split_video_ffmpeg from scenedetect.detectors import ContentDetector from scenedetect.video_splitter import split_video_ffmpeg def split_video_into_scenes(video_path, threshold=27.0): # Open our video, create a scene manager, and add a detector. video = open_video(video_path) scene_manager = SceneManager() scene_manager.add_detector( ContentDetector(threshold=threshold)) scene_manager.detect_scenes(video, show_progress=True) scene_list = scene_manager.get_scene_list() split_video_ffmpeg(video_path, scene_list, show_progress=True) ``` -------------------------------- ### scenedetect.detect() Source: https://github.com/breakthrough/pyscenedetect/blob/main/docs/api.rst Analyzes a video file using a specified detection algorithm and returns a list of timecode pairs representing detected scenes. ```APIDOC ## scenedetect.detect(path, detector) ### Description Performs scene detection on a video file using the provided detector instance. ### Parameters - **path** (str) - Required - The file path to the video to be analyzed. - **detector** (SceneDetector) - Required - An instance of a detection algorithm (e.g., ContentDetector, AdaptiveDetector). ### Response - **scenes** (list) - A list of tuples containing (scene_start, scene_end) timecode pairs. ### Example ```python from scenedetect import detect, ContentDetector scenes = detect("video.mp4", ContentDetector()) for (start, end) in scenes: print(f"{start}-{end}") ``` ``` -------------------------------- ### ClipShots Directory Structure Source: https://github.com/breakthrough/pyscenedetect/blob/main/benchmark/README.md Expected on-disk layout for the ClipShots dataset. ```text ClipShots/ annotations/{train,test,only_gradual}.json video_lists/{train,test,only_gradual}.txt videos/*.mp4 ``` -------------------------------- ### Split a video using the Python API Source: https://github.com/breakthrough/pyscenedetect/blob/main/packaging/package-info.rst Uses the AdaptiveDetector to identify scenes and ffmpeg to split the video file. ```python from scenedetect import detect, AdaptiveDetector, split_video_ffmpeg scene_list = detect('my_video.mp4', AdaptiveDetector()) split_video_ffmpeg('my_video.mp4', scene_list) ``` -------------------------------- ### Specify video processing time segments Source: https://github.com/breakthrough/pyscenedetect/blob/main/website/pages/cli.md Equivalent commands to process a specific 90-second segment of a video using different timecode formats and duration settings. ```bash scenedetect -i my_video.mp4 time --start 00:05:00 --end 00:06:30 ``` ```bash scenedetect -i my_video.mp4 time --start 300s --end 390s ``` ```bash scenedetect -i my_video.mp4 time --start 300s --duration 90s ``` ```bash scenedetect -i my_video.mp4 time --start 300s --duration 2700 ``` -------------------------------- ### Detect Scenes and Split Video Source: https://github.com/breakthrough/pyscenedetect/blob/main/docs/api.rst Use the detect function with a ContentDetector to identify scene cuts, then pass the resulting scene list to split_video_ffmpeg to export segments. ```python from scenedetect import detect, ContentDetector, split_video_ffmpeg scene_list = detect("my_video.mp4", ContentDetector()) split_video_ffmpeg("my_video.mp4", scenes) ``` -------------------------------- ### split_video_ffmpeg(video_path, scenes) Source: https://github.com/breakthrough/pyscenedetect/blob/main/docs/api.rst Splits the input video into separate files based on the detected scene list using ffmpeg. ```APIDOC ## split_video_ffmpeg(video_path, scenes) ### Description Uses ffmpeg to split the input video into individual scene files based on the provided scene list. ### Parameters - **video_path** (str) - Required - Path to the input video file. - **scenes** (list) - Required - A list of FrameTimecode pairs representing the start/end of each scene. ``` -------------------------------- ### Cite the BBC dataset Source: https://github.com/breakthrough/pyscenedetect/blob/main/benchmark/README.md BibTeX entry for the BBC dataset used in the benchmark. ```bibtex @InProceedings{bbc_dataset, author = {Lorenzo Baraldi and Costantino Grana and Rita Cucchiara}, title = {A Deep Siamese Network for Scene Detection in Broadcast Videos}, booktitle = {Proceedings of the 23rd ACM International Conference on Multimedia}, year = {2015}, } ``` -------------------------------- ### Cite the ClipShots dataset Source: https://github.com/breakthrough/pyscenedetect/blob/main/benchmark/README.md BibTeX entry for the ClipShots dataset used in the benchmark. ```bibtex @InProceedings{clipshots_dataset, author = {Shitao Tang and Litong Feng and Zhanghui Kuang and Yimin Chen and Wei Zhang}, title = {Fast Video Shot Transition Localization with Deep Structured Models}, booktitle = {Asian Conference on Computer Vision (ACCV)}, year = {2018}, } ``` -------------------------------- ### Pinning PySceneDetect Version Source: https://github.com/breakthrough/pyscenedetect/blob/main/docs/api.rst Recommended version pinning for requirements files to ensure API stability. ```python scenedetect~=0.7 ``` -------------------------------- ### Run parameter sweep Source: https://github.com/breakthrough/pyscenedetect/blob/main/benchmark/README.md Runs a grid search over detector parameters and reports top results. ```bash python -m benchmark.sweep \ --detector detect-content --dataset BBC \ --params "threshold=15:35:1;min_scene_len=0.0:1.0:0.1" \ --tolerance 0,1 --workers 16 \ --out sweep-content-bbc.json ``` -------------------------------- ### Split Video via Python API Source: https://github.com/breakthrough/pyscenedetect/blob/main/README.md Split a video file into individual scenes using ffmpeg. ```python from scenedetect import detect, ContentDetector, split_video_ffmpeg scene_list = detect('my_video.mp4', ContentDetector()) split_video_ffmpeg('my_video.mp4', scene_list) ``` -------------------------------- ### Detecting Scenes with ContentDetector Source: https://github.com/breakthrough/pyscenedetect/blob/main/docs/api.rst Basic usage of the detect function to identify scene transitions in a video file. ```python 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}") ``` -------------------------------- ### Detect scenes with built-in detectors Source: https://github.com/breakthrough/pyscenedetect/blob/main/docs/api/migration_guide.rst Standard usage of the detect function remains compatible with v0.7. ```python # This still works in v0.7 from scenedetect import detect, ContentDetector scenes = detect("video.mp4", ContentDetector()) ``` -------------------------------- ### Load Scenes CLI Commands Source: https://github.com/breakthrough/pyscenedetect/blob/main/docs/cli.rst Load scene cut locations from a CSV file instead of performing detection. The --start-col-name option specifies which column contains the cut markers. ```bash scenedetect -i video.mp4 load-scenes -i scenes.csv ``` ```bash scenedetect -i video.mp4 load-scenes -i scenes.csv --start-col-name "Start Timecode" ``` -------------------------------- ### Threshold Detection Source: https://github.com/breakthrough/pyscenedetect/blob/main/website/pages/cli.md Perform scene detection based on frame intensity thresholds, optionally specifying a custom threshold value. ```bash scenedetect -i my_video.mp4 -s my_video.stats.mp4 detect-threshold ``` ```bash scenedetect -i my_video.mp4 -s my_video.stats.mp4 detect-threshold -t 20 ``` -------------------------------- ### Implement a Custom SceneDetector Source: https://github.com/breakthrough/pyscenedetect/blob/main/website/pages/api.md Subclass SceneDetector and implement process_frame to analyze individual frames and post_process for final cleanup or pending event handling. ```python import typing as ty import numpy as np from scenedetect import FrameTimecode, SceneDetector class CustomDetector(SceneDetector): """CustomDetector class to implement a scene detection algorithm.""" def process_frame( self, timecode: FrameTimecode, frame_im: np.ndarray, ) -> ty.List[FrameTimecode]: # Return a list of timecodes where we found cuts (either on this frame or previously). return [] def post_process(self, timecode: FrameTimecode) -> ty.List[FrameTimecode]: # Called after the last frame has been read to handle pending events. return [] ``` -------------------------------- ### Access FrameTimecode properties Source: https://github.com/breakthrough/pyscenedetect/blob/main/docs/api/migration_guide.rst Use properties instead of getter methods to access timecode data, which now returns exact Fraction values. ```python from fractions import Fraction tc = FrameTimecode(100, 29.97) tc.frame_num # 100 tc.frame_rate # Fraction(30000, 1001) (exact) tc.time_base # Fraction(1001, 30000) tc.seconds # ~3.337 ``` -------------------------------- ### Detect Scenes with Python API Source: https://github.com/breakthrough/pyscenedetect/blob/main/README.md Perform content-aware scene detection using the high-level detect function. ```python from scenedetect import detect, ContentDetector scene_list = detect('my_video.mp4', ContentDetector()) ``` -------------------------------- ### Extract AutoShot Dataset Source: https://github.com/breakthrough/pyscenedetect/blob/main/benchmark/README.md Extracts the AutoShot test dataset archive after manual download. ```bash tar -zxvf AutoShot_test.tar.gz rm AutoShot_test.tar.gz ``` -------------------------------- ### Update FrameTimecode instances Source: https://github.com/breakthrough/pyscenedetect/blob/main/docs/api/migration_guide.rst Construct new FrameTimecode objects instead of reassigning read-only properties. ```python tc = FrameTimecode(0, 24.0) # Can no longer reassign frame_num, must create a new FrameTimecode instead: #tc.frame_num = 100 tc = FrameTimecode(100, tc) ``` -------------------------------- ### detect-threshold Source: https://github.com/breakthrough/pyscenedetect/blob/main/docs/cli.rst Find fade in/out events using average pixel values. ```APIDOC ## detect-threshold ### Description Find fade in/out using averaging. Detects fade-in and fade-out events using average pixel values. ### Options - **-t, --threshold** (VAL) - Optional - Threshold (integer) that frame score must exceed to start a new scene. Default: 12.0. - **-f, --fade-bias** (PERCENT) - Optional - Percent (%) from -100 to 100 of timecode skew of cut placement. Default: 0. - **-l, --add-last-scene** (flag) - Optional - If set and video ends after a fade-out event, generate a final cut at the last fade-out position. Default: True. - **-m, --min-scene-len** (TIMECODE) - Optional - Minimum length of any scene. ``` -------------------------------- ### detect-hash Source: https://github.com/breakthrough/pyscenedetect/blob/main/docs/cli.rst Find fast cuts using perceptual hashing by comparing the hamming distance between adjacent frames. ```APIDOC ## detect-hash ### Description Find fast cuts using perceptual hashing. The perceptual hash is taken of adjacent frames, and used to calculate the hamming distance between them. ### Options - **-t, --threshold** (VAL) - Optional - Max distance between hash values (0.0 to 1.0) of adjacent frames. Default: 0.35. - **-s, --size** (SIZE) - Optional - Size of square of low frequency data to include from the discrete cosine transform. Default: 8. - **-l, --lowpass** (FRAC) - Optional - How much high frequency information to filter from the DCT. Default: 2. - **-m, --min-scene-len** (TIMECODE) - Optional - Minimum length of any scene. ``` -------------------------------- ### Redirect to GitHub Issues from 404 Page Source: https://github.com/breakthrough/pyscenedetect/blob/main/website/overrides/404.html This JavaScript code runs on the 404 page. It checks the current URL path and redirects the user to the corresponding GitHub issue if a match is found. It handles both exact issue paths and paths with issue numbers. ```javascript (function() { var path = window.location.pathname; var pageTitle = document.getElementById('404-title'); var pageBody = document.getElementById('404-body'); // The canonical form is "issues" but we allow "issue" as well. const TARGETS = [ '/issue', '/issues', '/issue/', '/issues/' ]; for (const target of TARGETS) { if (path === target) { pageTitle.innerText = 'Redirecting...'; const url = 'https://github.com/Breakthrough/PySceneDetect/issues/'; pageBody.innerHTML = 'Redirecting to GitHub issues...'; window.location.href = url; return; } } const PREFIXES = ['/issue/', '/issues/']; for (const prefix of PREFIXES) { if (path.startsWith(prefix)) { var issueNumber = path.substring(prefix.length); if (issueNumber) { pageTitle.innerText = 'Redirecting...'; var newUrl = 'https://github.com/Breakthrough/PySceneDetect/issues/' + issueNumber; pageBody.innerHTML = 'Redirecting to issue #' + issueNumber + ' on GitHub...'; window.location.href = newUrl; return; } } } })(); ``` -------------------------------- ### Perform arithmetic with Fraction values Source: https://github.com/breakthrough/pyscenedetect/blob/main/docs/api/migration_guide.rst Fractions support standard arithmetic and comparisons, but require explicit casting to float for specific formatting or type checks. ```python rate = tc.frame_rate # Fraction(30000, 1001) rate * 2 # Fraction(60000, 1001) rate > 24 # True rate * 0.5 # 14.985... (float, mixed arithmetic) f"{float(rate):.3f}" # '29.970' (explicit cast for format spec) ``` -------------------------------- ### Remove Audio Track from Video Source: https://github.com/breakthrough/pyscenedetect/blob/main/website/pages/faq.md Commands to strip audio tracks from video files using ffmpeg or mkvmerge as a workaround for frame reading errors. ```bash ffmpeg -i input.mp4 -c copy -an output.mp4 ``` ```bash mkvmerge -o output.mkv input.mp4 ``` -------------------------------- ### SceneManager Class Source: https://github.com/breakthrough/pyscenedetect/blob/main/docs/api/scene_manager.rst The SceneManager class is the central component for managing scene detection tasks. It allows users to register detection algorithms and process video streams. ```APIDOC ## SceneManager ### Description The SceneManager class acts as the main controller for scene detection. It maintains a list of detectors and manages the state of the detection process across video frames. ### Methods - **add_detector(detector)**: Adds a scene detector to the manager. - **process_frame(frame_num, frame_im)**: Processes a single video frame using all registered detectors. - **get_scene_list()**: Returns the list of detected scenes. - **clear()**: Resets the manager state. ``` -------------------------------- ### Save frames from cuts Source: https://github.com/breakthrough/pyscenedetect/blob/main/website/pages/cli.md Extracts and saves images from each detected scene cut. ```bash scenedetect -i video.mp4 save-images ``` -------------------------------- ### Update custom SceneDetector process_frame signature Source: https://github.com/breakthrough/pyscenedetect/blob/main/docs/api/migration_guide.rst The process_frame method now accepts a FrameTimecode object instead of an integer frame number. ```python # v0.6 class MyDetector(SceneDetector): def process_frame(self, frame_num: int, frame_img) -> List[int]: ... # v0.7 class MyDetector(SceneDetector): def process_frame(self, timecode: FrameTimecode, frame_img) -> List[FrameTimecode]: ... ``` -------------------------------- ### detect-hist Source: https://github.com/breakthrough/pyscenedetect/blob/main/docs/cli.rst Find fast cuts by differencing YUV histograms between adjacent frames. ```APIDOC ## detect-hist ### Description Find fast cuts by differencing YUV histograms. Uses Y channel after converting each frame to YUV to create a histogram of each frame. ### Options - **-t, --threshold** (VAL) - Optional - Max difference (0.0 to 1.0) between histograms of adjacent frames. Default: 0.2. - **-b, --bins** (NUM) - Optional - The number of bins to use for the histogram calculation. Default: 128. - **-m, --min-scene-len** (TIMECODE) - Optional - Minimum length of any scene. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.