Skip to main content

Scenecut Extractor

Scenecut Extractor logo

All Contributors

PyPI version

Python package

Extract scenecuts from video files using ffmpeg.

This tool uses the select filter from ffmpeg to determine the scene cut probability of adjacent frames, and allows users to determine which frames (or at which timestamps) the scene cuts happen.

Note: Previous versions installed a scenecut_extractor executable. To harmonize it with other tools, now the executable is called scenecut-extractor. Please ensure you remove the old executable (e.g. run which scenecut_extractor and remove the file).

Author: Werner Robitza werner.robitza@gmail.com

Contents:

Requirements

  • Python 3.10 or higher
  • FFmpeg:
    • download a static build from their website)
    • put the ffmpeg executable in your $PATH

Installation

Using uv:

uvx scenecut-extractor

Using pipx:

pipx install scenecut-extractor

Or, using pip:

pip3 install --user scenecut-extractor

Usage

Run:

scenecut-extractor <input-file>

This might take a while depending on the length of your input file, and then output a list of scene cuts in JSON format:

[
  {
    "frame": 114,
    "pts": 114.0,
    "pts_time": 3.8,
    "score": 0.445904
  },
  {
    "frame": 159,
    "pts": 159.0,
    "pts_time": 5.3,
    "score": 0.440126
  }
]

To extract the scene cuts, use the -x flag and optionally specify an output directory with -d:

scenecut-extractor <input-file> -x -d output-directory

This will create a directory called output-directory and put the extracted scenes in there. The filenames will be the same as the input file, but with the scene times appended to them.

Note: Cutting may not be frame-accurate. To be precise, you have to re-encode the video. Use the --no-copy flag to do this. The output will use libx264 encoding with CRF 23 and the medium preset by default, which gives a good balance between quality and file size. Use --crf (0–51, lower means higher quality) and --preset to change this, for example:

scenecut-extractor <input-file> -x --no-copy --crf 18 --preset slow

Extended Usage

The command supports the following arguments and options, see scenecut-extractor -h:

usage: scenecut-extractor [-h] [-t THRESHOLD] [-o {all,frames,seconds}]
                          [-of {json,csv}] [-x] [-d OUTPUT_DIRECTORY]
                          [--no-copy] [--crf CRF]
                          [--preset {ultrafast,superfast,veryfast,faster,fast,medium,slow,slower,veryslow,placebo}]
                          [-e OUTPUT_EXTENSION] [-p] [-v] [-O OUTPUT_FILE]
                          [--ffmpeg-path FFMPEG_PATH]
                          input

scenecut_extractor v0.9.2

positional arguments:
  input                 input file

options:
  -h, --help            show this help message and exit
  -t, --threshold THRESHOLD
                        threshold (between 0 and 1) (default: 0.3)
  -o, --output {all,frames,seconds}
                        output which information (default: all)
  -of, --output-format {json,csv}
                        output in which format (default: json)
  -x, --extract         extract the scene cuts (default: False)
  -d, --output-directory OUTPUT_DIRECTORY
                        Set the output directory. Default is the current
                        working directory. (default: None)
  --no-copy             Don't stream-copy, but re-encode the video. (default:
                        False)
  --crf CRF             CRF value (0-51) for libx264. Only used when re-
                        encoding (--no-copy). (default: 23)
  --preset {ultrafast,superfast,veryfast,faster,fast,medium,slow,slower,veryslow,placebo}
                        libx264 preset. Only used when re-encoding (--no-
                        copy). (default: medium)
  -e, --output-extension OUTPUT_EXTENSION
                        Override the output file extension for extracted
                        scenes (e.g., '.mkv'). Default: same as input.
                        (default: None)
  -p, --progress        Show a progress bar on stderr (default: False)
  -v, --verbose         Print verbose info to stderr (default: False)
  -O, --output-file OUTPUT_FILE
                        Write output to a file instead of stdout (default:
                        None)
  --ffmpeg-path FFMPEG_PATH
                        Path to ffmpeg executable (default: ffmpeg)

You can use the -t parameter to set the threshold that ffmpeg internally uses (between 0 and 1) – if you set it to 0, all frames will be printed with their probabilities.

API

This program has a simple API that can be used to integrate it into other Python programs.

For more information see the API documentation.

For extended scene detection features such as automatic splitting or perceptual hashing, you may want to check out PySceneDetect.

If you are interested in generating chapters automatically from various media files, have a look at chaptertool (which also uses this library).

Contributors

xqrdot
xqrdot

🤔

License

scenecut_extractor, Copyright (c) 2018–2026 Werner Robitza

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Metadata

Release files for scenecut-extractor 0.10.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for scenecut-extractor 0.10.0
File Size Uploaded Provenance Actions
scenecut_extractor-0.10.0.tar.gz 9.6 kB Without provenance Details for scenecut_extractor-0.10.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for scenecut-extractor 0.10.0
File Interpreter ABI Platform Actions
scenecut_extractor-0.10.0-py3-none-any.whl Python 3 none any Details for scenecut_extractor-0.10.0-py3-none-any.whl

Total release size: 22.3 kB

Release files / scenecut_extractor-0.10.0.tar.gz

Download URL scenecut_extractor-0.10.0.tar.gz
Size 9.6 kB
Tags Source
SHA-256 checksum
How to use checksums
6baafe439bd19808a8da18420c7eb0d0a123994895ef80e7bb1caa8bc1bf992c
BLAKE2b-256 checksum
How to use checksums
351777ab9f32e5380dbe93c4083e3dae2bb77dabac297f1d46ba345433d993d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release files / scenecut_extractor-0.10.0-py3-none-any.whl

Download URL scenecut_extractor-0.10.0-py3-none-any.whl
Size 12.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a869b9a10bc1bcea284f169336b8b6d412b3a8365831b7bdf3778c933fc10c38
BLAKE2b-256 checksum
How to use checksums
f724d4378aa7e5dddd0db39e387db98198430a0b46997a97260b017a0618b8c6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Security for scenecut-extractor 0.10.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page