Skip to content

A Python/OpenCV-based scene detection program, using threshold/content analysis on a given video.

License

Unknown and 2 other licenses found

Licenses found

Unknown
LICENSE
Unknown
LICENSE-NUMPY
Unknown
LICENSE-OPENCV
Notifications You must be signed in to change notification settings

jaags/PySceneDetect

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PySceneDetect

Video Scene Detection and Analysis Tool

PySceneDetect is a command-line tool, written in Python and using OpenCV, which analyzes a video, looking for scene changes or cuts. The output timecodes can then be used with another tool (e.g. mkvmerge, ffmpeg) to split the video into individual clips. A frame-by-frame analysis can also be generated for a video, to help with determining optimal threshold values or detecting patterns/other analysis methods for a particular video.

Note that PySceneDetect is currently in alpha; see Current Features & Roadmap below for details. For help or other issues, you can visit #pyscenedetect on Freenode, or contact me on my website. Feel free to submit any bugs or feature requests to the Issue Tracker here on Github. Development right now is a tad slow as I'm nearing the completion of my thesis, but should resume to a normal pace by fall of this year (September/October 2015).

Download & Requirements

The latest version of PySceneDetect (v0.2.2-alpha) can be downloaded here; to run it, you will need:

To ensure you have all the requirements, open a python interpreter, and ensure you can import numpy and import cv2 without any errors. You can download a test video and view the expected output from the resources branch (see the end of the Usage section below for details).

Usage

To run PySceneDetect, you can invoke python scenedetect.py or ./scenedetect.py directly. To display the help file, detailing usage parameters:

./scenedetect.py --help

To perform threshold-based analysis with the default parameters, on a video named myvideo.mp4, saving a list of scenes to myvideo_scenes.csv (they are also printed to the terminal):

./scenedetect.py --input myvideo.mp4 --output myvideo_scenes.csv

To perform threshold-based analysis, with a threshold intensity of 16, and a match percent of 90:

./scenedetect.py --input myvideo.mp4 --threshold 16 --minpercent 90

Detailed descriptions of the above parameters, as well as their default values, can be obtained by using the --help flag.

Below is a visual example of the parameters used in threshold mode (click for full-view):

parameters in threshold mode

You can download the file testvideo.mp4, as well as the expected output testvideo-results.txt, from the resources branch, for testing the operation of the program. Data for the above graph was obtained by running PySceneDetect on testvideo.mp4 in statistics mode (by specifying the -s argument).

Current Features & Roadmap

See CHANGELOG.md for a list of changes in each version, or visit the Releases page to download a specific version. Feel free to submit any bugs/issues or feature requests to the Issue Tracker.

Current Features

  • analyzes passed video file for changes in intensity/content (currently based on mean pixel value/brightness)
  • detects fade-in and fade-out based on user-defined threshold
  • exports list of scenes to .CSV file (both timecodes and frame numbers) (-o)
  • exports timecodes in mkvmerge format: HH:MM:SS.nnnnn, comma-separated
  • statistics/analysis mode to export frame-by-frame video metrics (-s)

In Progress

  • add output-suppression mode for better automation with external scripts/programs
  • content-aware scene detection based on changes in the HSV color space
  • adaptive or user-defined bias for fade in/out interpolation

Planned Features

  • export scenes in chapter/XML format
  • improve robustness of content-aware detection by combining with edge detection (similar to MATLAB-based scene change detector)
  • additional timecode formats
  • interactive/guided mode, eventually moving to a graphical interface

You can find additional information regarding PySceneDetect at the following URL: http://www.bcastell.com/projects/pyscenedetect/


Licensed under BSD 2-Clause (see the LICENSE file for details).

Copyright (C) 2013-2014 Brandon Castellano. All rights reserved.

About

A Python/OpenCV-based scene detection program, using threshold/content analysis on a given video.

Resources

License

Unknown and 2 other licenses found

Licenses found

Unknown
LICENSE
Unknown
LICENSE-NUMPY
Unknown
LICENSE-OPENCV

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%