Skip to main content

Standalone Python shot boundary detection package for splitting videos into shots

Project description

Shot Detection Python

Standalone Python package for shot boundary detection.

It takes a video file, runs TransNetV2-style ONNX inference on low-resolution RGB frames, and returns shot ranges with millisecond timestamps.

Built by Seeknetic. If you want to make video shots searchable and enable more professional video understanding workflows, visit seeknetic.com.

What it does

  • Probes the input video with ffprobe
  • Extracts low-resolution frames with ffmpeg
  • Runs sliding-window ONNX inference
  • Finds shot boundaries
  • Converts them into {start_ms, end_ms} shot segments

Installation

pip install shot-detection

Import from shot_detection:

from shot_detection import ShotDetector

You also need:

  • ffmpeg
  • ffprobe

On first run, the package downloads the default model automatically:

  • URL: https://download.shotai.io/model/shot-detection/transnetv2_open_fp16.onnx
  • cache dir:
    • Linux/macOS: ~/.cache/shot-detection/models/
    • Windows: %LOCALAPPDATA%\\shot-detection\\models\\

You can override the cache root with SHOT_DETECTION_CACHE_DIR.

Usage

from shot_detection import ShotDetector

detector = ShotDetector()
shots = detector.detect("/path/to/video.mp4")

for shot in shots:
    print(shot.start_ms, shot.end_ms)

Advanced usage

from shot_detection import detect_shots

shots = detect_shots(
    video_path="/path/to/video.mp4",
    threshold=0.5,
    min_shot_duration_ms=500,
)

Custom model path

from shot_detection import ShotDetector

detector = ShotDetector(model_path="/path/to/custom-transnetv2.onnx")

Notes

  • The package expects the ONNX model input to accept 100-frame windows at 48x27 RGB.
  • ffmpeg decode is adaptive: it prefers system-native hardware decoding when available and falls back to software decoding automatically.
  • CUDA is intentionally not part of the default decode plan.

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

shot_detection-0.1.0.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

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

shot_detection-0.1.0-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for shot_detection-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5f322a3a2b5b1e1a9d6c6af0f58801bf022138e88affbf458d93a7b8a251d468
MD5 e6684e26523091725007767707900eed
BLAKE2b-256 8a7d4150b508d223c8d4840c57dd694f31d5b5e9cc059acd0f483f933c29f9e7

See more details on using hashes here.

Provenance

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

Publisher: publish-pypi.yml on Seeknetic/shot-detection-python

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

File details

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

File metadata

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

File hashes

Hashes for shot_detection-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fc62bfeccb2c8683e63b8a7b3fe51f3378a4df82aa6099c146e970942f9b328f
MD5 e161cf348ebf850f350642ac0786a4f6
BLAKE2b-256 8502899319da0b5a170da657950060914c98a3d742adf62b7c1a355d78b68478

See more details on using hashes here.

Provenance

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

Publisher: publish-pypi.yml on Seeknetic/shot-detection-python

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