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 to achieve a good balance between quality and file size. Future versions of this tool will allow you to specify your own encoding options.

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]
                   [-e OUTPUT_EXTENSION] [-p] [-v] [-O OUTPUT_FILE]
                   [--ffmpeg-path FFMPEG_PATH] input

scenecut_extractor v0.5.0

positional arguments:
  input                 input file

options:
  -h, --help            show this help message and exit
  -t THRESHOLD, --threshold THRESHOLD
                        threshold (between 0 and 1) (default: 0.3)
  -o {all,frames,seconds}, --output {all,frames,seconds}
                        output which information (default: all)
  -of {json,csv}, --output-format {json,csv}
                        output in which format (default: json)
  -x, --extract         extract the scene cuts (default: False)
  -d OUTPUT_DIRECTORY, --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)
  -e OUTPUT_EXTENSION, --output-extension OUTPUT_EXTENSION
                        Override the output file extension for extracted
                        scenes (e.g., '.mkv'). Default: same as input.
  -p, --progress        Show a progress bar on stderr (default: False)
  -v, --verbose         Print verbose info to stderr (default: False)
  -O OUTPUT_FILE, --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.9.2

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.9.2
File Size Uploaded Provenance Actions
scenecut_extractor-0.9.2.tar.gz 8.5 kB Without provenance Details for scenecut_extractor-0.9.2.tar.gz

Built distribution (wheel)

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

Total release size: 20.0 kB

Release files / scenecut_extractor-0.9.2.tar.gz

Download URL scenecut_extractor-0.9.2.tar.gz
Size 8.5 kB
Tags Source
SHA-256 checksum
How to use checksums
9c8d4abee2c4a09f543537e1348c426aadb0db44bf5d3b4c881e92964502cde0
BLAKE2b-256 checksum
How to use checksums
5a38169bb1d617d8c01c2a843656afcf58eb6afec2569084eada249b9004c3d0
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.9.2-py3-none-any.whl

Download URL scenecut_extractor-0.9.2-py3-none-any.whl
Size 11.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
530773f5f3873f88eb083b74c20b1efe0c9a26e960698dc1837a4bc3fac220c0
BLAKE2b-256 checksum
How to use checksums
714ebe58188c11ae6d431d3928e729b6ce420c178f870aa4c2cf9309fa29b248
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.9.2

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