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:
ffmpegffprobe
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\\
- Linux/macOS:
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
48x27RGB. ffmpegdecode 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.
Integration with Seeknetic SDK
If you want to run shot-level embedding or tagging jobs after boundary detection, you can combine this package with the Seeknetic Python SDK.
For the full workflow, see docs/seeknetic-sdk-integration.md.
Install the SDK separately:
pip install seeknetic
Set SEEKNETIC_API_KEY before calling the SDK:
export SEEKNETIC_API_KEY="your_api_key"
A paid Seeknetic account and API access are required. You can get an API key from accounts.seeknetic.com.
Quick example
import os
import uuid
from seeknetic import Seeknetic
from shot_detection import ShotDetector
video_path = "/path/to/video.mp4"
shots = ShotDetector().detect(video_path)
client = Seeknetic(api_key=os.environ["SEEKNETIC_API_KEY"])
submitted_requests = {}
for shot in shots:
request_id = str(uuid.uuid4())
submitted_requests[shot.index] = {
"request_id": request_id,
"start_ms": shot.start_ms,
"end_ms": shot.end_ms,
}
upload = client.preprocess_and_upload(
video_path=video_path,
service="embedding",
request_id=request_id,
start_ms=shot.start_ms,
end_ms=shot.end_ms,
)
client.video_embedding.encode_video.submit_async(
tensor={
"video_input_key": upload.r2_keys["video_input"],
"audio_input_key": upload.r2_keys["audio_input"],
},
request_id=upload.request_id,
)
print(submitted_requests)
For tagging, switch service="embedding" to service="tagging" and use client.video_tagging.submit_async_job(...).
Metadata
Release files for shot-detection 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| shot_detection-0.1.1.tar.gz | 11.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| shot_detection-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.8 kB
Release files / shot_detection-0.1.1.tar.gz
| Download URL | shot_detection-0.1.1.tar.gz |
|---|---|
| Size | 11.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
adc9e9763189c84f9712702ee5b2eea94d912bb4c3451732c3ed9dc8d78f0101
|
|
BLAKE2b-256 checksum How to use checksums |
f3fbb4f2f08e92ca20d119edca4ef2884f63a5dc75a7954cc81663d9cd9c1464
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 17, 2026.
Transparency logRelease files / shot_detection-0.1.1-py3-none-any.whl
| Download URL | shot_detection-0.1.1-py3-none-any.whl |
|---|---|
| Size | 10.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7c740ad95f76c6a8d38c6cdc7e2e8eef672c9b3474c885298c40c9b599526500
|
|
BLAKE2b-256 checksum How to use checksums |
0e8be5ab11d5b99e4e4e3c7a5048de1144856950c6887de669c78df2399dd304
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 17, 2026.
Transparency log