Skip to main content

Shot boundary segment extraction for video files.

Project description

shotsplit

Shot segment range extraction for video files.

The PyPI distribution name and Python import package are both shotsplit. shotsplit currently uses AutoShot as its default shot-boundary detection model.

Install

python -m pip install shotsplit

Or with uv:

uv pip install shotsplit

This installs the package and its runtime dependencies, including PyTorch. ShotSplitter() runs on CPU by default.

Install With A Specific PyTorch Build

PyPI package metadata cannot encode alternate PyTorch wheel indexes for CPU and CUDA builds. To force a specific PyTorch build, install PyTorch first, then install shotsplit.

CPU-only PyTorch:

uv pip install torch --index-url https://download.pytorch.org/whl/cpu
uv pip install shotsplit

CUDA 12.8 PyTorch:

uv pip install torch --index-url https://download.pytorch.org/whl/cu128
uv pip install shotsplit

The same sequence works with python -m pip install ... if you do not use uv.

Usage

from shotsplit import ShotSplitter, __version__

print(__version__)

with ShotSplitter() as splitter:
    clips = splitter.split("example.mp4", threshold=0.2)

print(clips)

ShotSplitter() uses CPU by default. To use CUDA, install a CUDA-enabled PyTorch build and pass device="cuda" explicitly:

with ShotSplitter(device="cuda") as splitter:
    clips = splitter.split("example.mp4", threshold=0.2)

The result is a list of half-open frame ranges:

[{"start_frame": 0, "end_frame": 100}, {"start_frame": 100, "end_frame": 150}]

start_frame and end_frame are frame indexes. end_frame is exclusive. By default, transition frames are included in the adjacent segments so the returned segments cover every decoded frame.

To exclude transition frames from the returned segments, pass include_transition_frames=False:

with ShotSplitter() as splitter:
    clips = splitter.split(
        "example.mp4",
        threshold=0.2,
        include_transition_frames=False,
    )

For boundary metadata and optional per-frame scores, use analyze():

with ShotSplitter() as splitter:
    result = splitter.analyze(
        "example.mp4",
        threshold=0.2,
        include_transition_frames=False,
        include_scores=True,
    )

print(result["segments"])
print(result["boundaries"])

boundaries contains thresholded AutoShot score runs:

[
    {
        "split_frame": 100,
        "run_start_frame": 98,
        "run_end_frame": 102,
        "peak_frame": 101,
        "peak_score": 0.91,
    }
]

run_start_frame and run_end_frame are inclusive. When include_transition_frames=False, these transition run frames are omitted from segments. If include_scores=True, frame_scores contains one score per decoded frame.

The default AutoShot weights are included in the package. To use a different checkpoint, pass weights_path.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

shotsplit-0.1.0.tar.gz (53.1 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

shotsplit-0.1.0-py3-none-any.whl (53.1 MB view details)

Uploaded Python 3

File details

Details for the file shotsplit-0.1.0.tar.gz.

File metadata

  • Download URL: shotsplit-0.1.0.tar.gz
  • Upload date:
  • Size: 53.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for shotsplit-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c35babce82dd0e3f760ddd17fccff954347e1c42391a62f45bc9e9078ab4f777
MD5 c063c1d689a32ccf5426a6dddec98653
BLAKE2b-256 d0ff6c84a751f4f7ff4c853e1aad594da60f99da92baa435c0a205c926f4e704

See more details on using hashes here.

Provenance

The following attestation bundles were made for shotsplit-0.1.0.tar.gz:

Publisher: pypi.yml on RonyK/shotsplit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file shotsplit-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: shotsplit-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 53.1 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for shotsplit-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b8e7b7eb817425b15df866efd8d6adf3bce0717fd7a78e7ed4948036ec11c484
MD5 8c24e73dc4ab78b8ac974b03890d0e40
BLAKE2b-256 a87530685c32878eed72586fe0c1cae3cf1ef3a41026dfc566d7b73e3741f3e1

See more details on using hashes here.

Provenance

The following attestation bundles were made for shotsplit-0.1.0-py3-none-any.whl:

Publisher: pypi.yml on RonyK/shotsplit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page