Skip to main content

A lightweight python package that analyzes shot lengths for video.

Project description

DetectVideoShotLength

DetectVideoShotLength is a Python package for detecting scene cuts in videos using advanced histogram and structural similarity (SSIM) analysis. This tool identifies frames where abrupt scene changes (or "cuts") occur, saves cut frames, and provides insights into shot durations, distribution, and visual frequency.

It is ideal for projects requiring video analysis, such as filmmaking, video editing, or computer vision research.

Key Features

  • Cut Detection: Detects scene cuts based on RGB histogram changes and verifies cuts using SSIM thresholds.
  • Scene Duration Analysis: Calculates the duration of each scene and provides insights into average shot lengths.
  • Scene Length Visualization: Plots scene lengths over time, showing the pacing and rhythm of a video.
  • Scene Frequency Distribution: Visualizes the distribution of scene lengths in a logarithmic frequency chart.
  • Sorted Scene Listing: Lists scenes sorted by duration, with start and end timestamps for detailed scene timing.

Implementation

Change threshold_hist from 0 to 1, the default threshold would be 0.15 and threshold_ssim from 0.75 to 0.95, default would be 0.85

Usually, the parameters give different results with day scenes and night scenes.

If the video is large, a segment could be analyzed.

import DetectVideoShotLength

video_path = r"D:\___Research\average shot\test_video.mp4"
output_dir = r"D:\___Research\average shot\video"

results = DetectVideoShotLength.detect_cuts(video_path, output_dir, threshold_hist=0.20, threshold_ssim=0.80, min_minutes=5, max_minutes=7)

DetectVideoShotLength.plot_scene_lengths(results)
DetectVideoShotLength.list_scenes_sorted_by_length(results)
DetectVideoShotLength.plot_scene_length_frequencies(results)

Project details


Release history Release notifications | RSS feed

This version

0.12

Download files

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

Source Distribution

detectvideoshotlength-0.12.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

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

DetectVideoShotLength-0.12-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file detectvideoshotlength-0.12.tar.gz.

File metadata

  • Download URL: detectvideoshotlength-0.12.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.2

File hashes

Hashes for detectvideoshotlength-0.12.tar.gz
Algorithm Hash digest
SHA256 087a000256369e85848d2bac7052211ff2c1c0583f7f5b3ecae0097755273b94
MD5 7d2eb36dd2472a59c0e1676687126f42
BLAKE2b-256 5b2c3583fc340e0708804a348cb17677b271f71bfc38bb83de30d40e68da673d

See more details on using hashes here.

File details

Details for the file DetectVideoShotLength-0.12-py3-none-any.whl.

File metadata

File hashes

Hashes for DetectVideoShotLength-0.12-py3-none-any.whl
Algorithm Hash digest
SHA256 35b80be6a80b31e3a3749e37b84014dfe821171a96da03d36bf4b80519b4a63e
MD5 235da15c9667087c96cd4e6af4169e5f
BLAKE2b-256 219fa7bdb13fcc35e6df0cf9d0eba95ff94c84c1e63f53ab717978efdc46c6af

See more details on using hashes here.

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