PySceneDetect v0.6 is a major breaking change including better performance, configuration file support, and a more ergonomic API. The new minimum Python version is now 3.6. See the Migration Guide for information on how to port existing applications to the new API. Most users will see performance improvements after updating, and changes to the command-line are not expected to break most workflows.
The main goals of v0.6 are reliability and performance. To achieve this required several breaking changes. The video input API was refactored, and many technical debt items were addressed. This should help the eventual transition to the first planned stable release (v1.0) where the goal is an improved scene detection API.
Both the Windows installer and portable distributions now include signed executables. Many thanks to SignPath, AppVeyor, and AdvancedInstaller for their support.
Overview:
- Major performance improvements on multicore systems
- Configuration file support via command line option or user settings folder
- Support for multiple video backends, PyAV is now supported in addition to OpenCV
- Breaking API changes to
VideoManager(replaced withVideoStream),StatsManager, andsave_images()- See the Migration Guide for details on how to update from v0.5.x
- A backwards compatibility layer has been added to prevent most applications from breaking, will be removed in a future release
- Support for Python 2.7 has been dropped, minimum supported Python version is 3.6
- Support for OpenCV 2.x has been dropped, minimum OpenCV version is 3.x
- Windows binaries are now signed, thanks SignPath.io (certificate by SignPath Foundation)
Command-Line Changes:
- Configuration files are now supported, see documentation for details
- Can specify config file path with
-c/--config, or create ascenedetect.cfgfile in your user config folder
- Can specify config file path with
- Frame numbers are now 1-based, aligning with most other tools (e.g.
ffmpeg) and video editors (#265) - Start/end frame numbers of adjacent scenes no longer overlap (#264)
- End/duration timecodes still include the frame's presentation time
- Add
--merge-last-sceneoption to merge last scene if shorter than--min-scene-len - Add
-b/--backendoption to use a specific video decoding backend- Supported backends are
opencvandpyav - Run
scenedetect helpto see a list of backends available on the current system - Both backends are included with Windows builds
- Supported backends are
split-videocommand:detect-adaptivecommand:--drop-short-scenesnow works properly withdetect-adaptive
detect-contentcommand:- Default threshold
-t/--thresholdlowered to 27 to be more sensitive to shot changes (#246) - Add override for global
-m/--min-scene-lenoption
- Default threshold
detect-thresholdcommand:- Remove
-p/--min-percentand-b/--block-sizeoptions - Add override for global
-m/--min-scene-lenoption
- Remove
save-imagescommand now works when-i/--inputis an image sequences- Default backend (OpenCV) is more robust to video decoder failures
-i/--inputmay no longer be specified multiple times, if required use an external tool (e.g.ffmpeg,mkvmerge) to perform concatenation before processing-s/--statsno longer loads existing statistics and will overwrite any existing files-l/--logfilenow respects-o/--output-v/--verbositynow takes precedence over-q/--quiet
API Changes:
- New
detect()function performs scene detection on a video path, see example here - New
open_video()function to handle video input, see example here split_video_ffmpeg()andsplit_video_mkvmerge()now take a single path as inputsave_images()no longer acceptsdownscale_factor- Use
scaleorheight/widtharguments to resize images
- Use
- New
VideoStreamreplacesVideoManager(#213)- Supports both OpenCV (
VideoStreamCv2) and PyAV (VideoStreamAv) - Improves video seeking invariants, especially around defining what frames 0 and 1 mean for different time properties (
frame_numberis 1-based whereaspositionis 0-based to align with PTS) - See
test_time_invariantsintests/test_video_stream.pyas a reference of specific behaviours
- Supports both OpenCV (
- Changes to
SceneManager:detect_scenes()now performs video decoding in a background thread, improving performance on most systemsSceneManageris now responsible for frame downscaling via thedownscale/auto_downscalepropertiesdetect_scenes()no longer shows a progress bar by default, setshow_progress=Trueto restore the previous behaviourclear()now clears detectors, as they may be statefulget_scene_list()now returns an empty list if there are no detected cuts, specifystart_in_scene=Truefor previous behavior (one scene spanning the entire input)
- Changes to
StatsManager:save_to_csv()now accepts a path or an open file handlebase_timecodeargument has been removed fromsave_to_csv()load_from_csv()is now deprecated and will be removed in v1.0
- Changes to
FrameTimecode:- Use rounding instead of truncation when calculating frame numbers to fix incorrect round-trip conversions and improve accuracy (#268)
- Fix
previous_frame()generating negative frame numbers in some cases FrameTimecodeobjects can now perform arithmetic with formatted strings, e.g.'HH:MM:SS.nnn'
- Merged constants
MAX_FPS_DELTAandMINIMUM_FRAMES_PER_SECOND_DELTA_FLOATinscenedetect.frame_timecodeinto newMAX_FPS_DELTAconstant video_managerparameter has been removed from theAdaptiveDetectorconstructorsplit_video_ffmpegandsplit_video_mkvmergefunction arguments have been renamed and defaults updated:suppress_outputis nowshow_output, default isFalsehide_progressis nowshow_progress, default isFalse
block_sizeargument has been removed from theThresholdDetectorconstructorcalculate_frame_scoremethod ofContentDetectorhas been renamed to_calculate_frame_score, use new module-level function of the same name insteadget_aspect_ratiohas been removed fromscenedetect.platform(use theaspect_ratioproperty of aVideoStreaminstead)- Backwards compatibility with v0.5 to avoid breaking most applications on release while still allowing performance improvements
- v0.6.0.3 - Fix missing package description
- v0.6.0.2 - Improve error messaging when OpenCV is not installed
- v0.6.0.1 - Fix original v0.6 release requiring
avto run thescenedetectcommand
- URL inputs are not supported by the
save-imagesorsplit-videocommands - Variable framerate videos (VFR) are not fully supported, and will yield incorrect timestamps (#168)
- The
detect-thresholdoption-l/--add-last-scenecannot be disabled - Due to a switch from EXE to MSI for the Windows installer, you may have to uninstall older versions first before installing v0.6
- Fix crash when using
detect-contentordetect-adaptivewith latest version of OpenCV (thanks @bilde2910)
- New detection algorithm:
detect-adaptivewhich works similar todetect-content, but with reduced false negatives during fast camera movement (thanks @scarwire and @wjs018) - Images generated by
save-imagescan now be resized via the command line - Statsfiles now work properly with
detect-threshold - Removed the
-p/--min-percentoption fromdetect-threshold - Add new option
-l/--luma-onlytodetect-content/detect-adaptiveto only consider brightness channel (useful for greyscale videos)
- [feature] New adaptive content detector algorithm
detect-adaptive(#153, thanks @scarwire and @wjs018) - [feature] Images generated with the
save-imagescommand (scene_manager.save_images()function in the Python API) can now be scaled or resized (#160 and PR #203, thanks @wjs018)- Images can be resized by a constant scaling factory using
-s/--scale(e.g.--scale 0.5shrinks the height/width by half) - Images can be resized to a specified height (
-h/--height) and/or width (-w/--width), in pixels; if only one is specified, the aspect ratio of the original video is kept
- Images can be resized by a constant scaling factory using
- [api] Calling
seek()on aVideoManagerwill now respect the end time if set - [api] The
split_video_functions now return the exit code of invokingffmpegormkvmerge(#209, thanks @AdrienLF) - [api] Removed the
min_percentargument fromThresholdDetectoras was not providing any performance benefit for the majority of use cases (#178) - [bugfix] The
detect-thresholdcommand now works properly with a statsfile (#211, thanks @jeremymeyers) - [bugfix] Fixed crash due to unhandled
TypeErrorexception when using non-PyPI OpenCV packages from certain Linux distributions (#220) - [bugfix] A warning is now displayed for videos which may not be decoded correctly, esp. VP9 (#86, thanks @wjs018)
- [api] A named logger is now used for both API and CLI logging instead of the root logger (#205)
- Variable framerate videos (VFR) are not fully supported, and will yield incorrect timestamps (#168)
- The
-l/--add-last-sceneoption indetect-thresholdcannot be disabled - Image sequences or URL inputs are not supported by the
save-imagesorsplit-videocommands (in v0.6save-imagesworks with image sequences) - Due to the use of truncation for frame number calculation, FrameTimecode objects may be off-by-one when constructed using a float value (#268, fixed in v0.6)
- One of the last major updates before transitioning to the new v0.6.x API
- The
--min-scene-len/-moption is now global rather than per-detector - There is a new global option
--drop-short-scenesto go along with-m - Removed first row from statsfiles so it is a valid CSV file
- The progress bar now correctly resizes when the terminal is resized
- Image sequences and URLs are now supported for input via the CLI/API
- Images exported using the
save-imagescommand are now resized to match the display aspect ratio - A new flag
-s/--skip-cutshas been added to thelist-scenescommand to allow standardized processing - The functionality of
save-imagesis now accessible via the Python API through thesave_images()function inscenedetect.scene_manager - Under the
save-imagescommand, renamed--image-frame-marginto--frame-margin, added short option-m, and increased the default value from 0 to 1 due to instances of the last frame of a video being occasionally missed (set-m 0to restore original behaviour)
- [bugfix] Allow image sequences and URLs to be used as inputs (#152 and #188)
- [bugfix] Pixel aspect ratio is now applied when using
save-images(#195) - [cli] Renamed
--image-frame-marginto--frame-margininsave-imagescommand, added short option-mas alias - [bugfix] Fix
save-imagescommand not saving the last frame by modifying seeking, as well as increasing default of--frame-marginfrom 0 to 1 - [cli] Make
--min-scene-lena global option rather than per-detector (#131, thanks @tonycpsu) - [feature] Added
--drop-short-scenesoption to remove all scenes smaller than--min-scene-len, instead of merging them - [cli] Add
-s/--skip-cutsoption tolist-scenescommand to allow outputting a scene list CSV file as compliant with RFC 4180 (#136) - [enhancement] Removed first row from statsfile to comply with RFC 4180, includes backwards compatibility so existing statsfiles can still be loaded (#136)
- [api] Add argument
include_cut_listtowrite_scene_listmethod inSceneManagerto support #136 - [api] Removed unused argument base_timecode from
StatsManager.load_from_csv()method - [api] Make the
base_timecodeargument optional on theSceneManagermethodsget_scene_list(),get_cut_list(), andget_event_list()(#173) - [api] Support for live video stream callbacks by adding new
callbackargument to thedetect_scenes()method ofSceneManager(#5, thanks @mhashim6) - [bugfix] Fix unhandled exception causing improper error message when a video fails to load on non-Windows platforms (#192)
- [enhancement] Enabled dynamic resizing for progress bar (#193)
- [enhancement] Always ouptut version number via logger to assist with debugging (#171)
- [bugfix] Resolve RuntimeWarning when running as module (#181)
- [api] Add
save_images()function toscenedetect.scene_managermodule which exposes the same functionality as the CLIsave-imagescommand (#88) - [api] Removed
close_captures()andrelease_captures()functions fromscenedetect.video_managermodule
- Certain non-PyPI OpenCV packages may cause a crash with the message
TypeError: isinstance() arg 2 must be a type or tuple of types- as a workaround, install the Python OpenCV package by runningpip install scenedetect[opencv](#220) - Image sequences or URL inputs are not supported by the
save-imagesorsplit-videocommands - Variable framerate videos (VFR) are not fully supported, and will yield incorrect timestamps (#168)
- Improved performance when using
timeandsave-imagescommands - Improved performance of
detect-thresholdwhen using a small minimum percent - Fix crash when using
detect-thresholdwith a statsfile - Fix crash when using
save-imagescommand under Python 2.7 - Support for Python 3.3 and 3.4 has been deprecated (see below)
- [bugfix] fix
detect-thresholdcrash when using statsfile (#122) - [bugfix] fix
save-imagescommand under Python 2.7 (#174, thanks @santiagodemierre) - [bugfix] gracefully exit and show link to FAQ when number of scenes is too large to split with mkvmerge on Windows (see [#164](Breakthrough#164, thanks @alexboydray)
- [enhancement] Improved seeking performance, greatly improves performance of the
timeandsave-imagescommands (#98 and PR #163 - thanks @obroomhall) - [enhancement] improve
detect-thresholdperformance when min-percent is less than 50% - [bugfix] Fixed issue where video loading would fail silently due to multiple audio tracks (#179)
- [general] Made
tqdma regular requirement and not an extra (#180) - [general] Support for Python 3.3 and 3.4 has been deprecated. Newer builds may still work on these Python versions, but future releases are not tested against these versions. This decision was made as part of #180
- Variable framerate videos are not supported properly currently (#168), a warning may be added in the next release to indicate when a VFR video is detected, until this can be properly resolved (#168)
- Resolved long-standing bug where
split-videocommand would duplicate certain frames at the beginning/end of the output (#93) - This was determined to be caused by copying (instead of re-encoding) the audio track, causing extra frames to be brought in when the audio samples did not line up on a frame boundary (thank you @joshcoales for your assistance)
- Default behavior is to now re-encode audio tracks using the
aaccodec when usingsplit-video(it can be overriden in both the command line and Python interface) - Improved timestamp accuracy when using
split-videocommand to further reduce instances of duplicated or off-by-one frame issues - Fixed application crash when using the
-l/--logfileargument
- [bugfix] Changed default audio codec from 'copy' to 'aac' when splitting scenes with
ffmpegto reduce frequency of frames from next scene showing up at the end of the current one when split usingffmpeg(see #93, #159, and PR #166 - thank you everyone for your assistance, especially joshcoales, amvscenes, jelias, and typoman). If this still occurs, please provide any information you can by filing a new issue on Github. - [enhancement]
video_splittermodule now has completed documentation - [bugfix] improve timestamp accuracy using the
split-videocommand due to timecode formatting - [bugfix] fix crash when supplying
-l/--logfileargument (see #169, thanks @typoman)
- Seeking through long videos is inefficient, causing the
timeandsave-imagescommand to take a long time to run. This will be resolved in the next release (see #98) - The
save-imagescommand causes PySceneDetect to crash under Python 2.7 (see #174) - Using
detect-thresholdwith a statsfile causes PySceneDetect to crash (see #122) - Variable framerate videos are not supported properly currently (#168), a warning may be added in the next release to indicate when a VFR video is detected, until this can be properly resolved (#168)
- Videos with multiple audio tracks may not work correctly, see this comment on #179 for a workaround using
ffmpegormkvmerge
- [enhancement]
--min-durationnow accepts a timecode in addition to frame number (#128, thanks @tonycpsu) - [feature] Add
--image-frame-marginoption tosave-imagescommand to ignore a number of frames at the start/end of a scene (#129, thanks @tonycpsu) - [bugfix]
--min-scene-lenoption was not respected by first scene (#105, thanks @charlesvestal) - [bugfix] Splitting videos with an analyzed duration only splits within analyzed area (#106, thanks @charlesvestal)
- [bugfix] Improper start timecode applied to the
split-videocommand when usingffmpeg(#93, thanks @typoman) - [bugfix] Added links and filename sanitation to html output (#139 and #140, thanks @wjs018)
- [bugfix] UnboundLocalError in
detect_sceneswhenframe_skipis larger than 0 (#126, thanks @twostarxx)
- minor re-release of v0.5.1 which updates the setup.py file to return OpenCV as an optional dependency
- to install from pip now with all dependencies:
pip install scenedetect[opencv,progress_bar] - to install only PySceneDetect:
pip install scenedetect(separate OpenCV installation required) - the release notes of v0.5.1 have been modified to include the prior command
- no change to PySceneDetect program version
- [feature] add
get_durationmethod to VideoManager (#109, thanks @arianaa30)
- [feature] Add new
export-htmlcommand to the CLI (thanks @wjs018) - [bugfix] VideoManager read function failed on multiple videos (thanks @ivan23kor)
- [bugfix] Fix crash when no scenes are detected (#79, thanks @raj6996)
- [bugfix] Fixed OpenCV not getting installed due to missing dependency (#73)
- [enhance] When no scenes are detected, the whole video is now returned instead of nothing (thanks @piercus)
- Removed Windows installer due to binary packages now being available, and to streamline the release process (see #102 for more information). When you type
pip install scenedetect[opencv,progress_bar], all dependencies will be installed.
- major release, includes stable Python API with examples and updated documentation
- numerous changes to command-line interface with addition of sub-commands (see the new manual for updated usage information)
- [feature] videos are now split using
ffmpegby default, resulting in frame-perfect cuts (can still usemkvmergeby specifying the-c/--copyargument to thesplit-videocommand) - [enhance] image filename numbers are now consistent with those of split video scenes (PR #39, thanks @e271828-)
- [enhance] 5-10% improvement in processing performance due to reduced memory copy operations (PR #40, thanks @elcombato)
- [enhance] updated exception handling to raise proper standard exceptions (PR #37, thanks @talkain)
- several fixes to the documentation, including improper dates and outdated CLI arguments (PR #26 and #, thanks @elcombato, and @colelawrence)
- numerous other PRs and issues/bug reports that have been fixed - there are too many to list individually here, so I want to extend a big thank you to everyone who contributed to making this release better
- [enhance] add Sphinx-generated API documentation (available at: http://manual.scenedetect.com)
- [project] move from BSD 2-clause to 3-clause license
- major release, includes integrated scene splitting via mkvmerge, changes meaning of
-o/--outputoption - [feature] specifying
-o OUTPUT_FILE.mkvwill now automatically split the input video, generating a new video clip for each detected scene in sequence, starting withOUTPUT_FILE-001.mkv - [enhance] CSV file output is now specified with the
-co/--csv-outputoption (note, used to be-oin versions of PySceneDetect < 0.4)
- [enhance] performance improvement when using
--frameskipoption (thanks @marcelluzs) - [internal] moved application state and shared objects to a consistent interface (the
SceneManagerobject) to greatly reduce the number of required arguments for certain API functions - [enhance] added installer for Windows builds (64-bit only currently)
- [enhance] initial release of portable build for Windows (64-bit only), including all dependencies
- [bugfix] fix unrelated exception thrown when video could not be loaded (thanks @marcelluzs)
- [internal] fix variable name typo in API documentation
- [enhance] add scene length, in seconds, to output file (
-o) for easier integration withffmpeg/libav - [enhance] improved performance of content detection mode by caching intermediate HSV frames in memory (approx. 2x faster)
- [enhance] show timecode values in terminal when using extended output (
-l) - [feature] add fade bias option (
-fb/--fade-bias) to command line (threshold mode only)
- [bugfix] output scenes are now correctly written to specified output file when using -o flag (fixes #11)
- [bugfix] fix indexing exception when using multiple scene detectors and outputting statistics
- [internal] distribute package on PyPI, version move from beta to stable
- [internal] add function to convert frame number to formatted timecode
- [internal] move file and statistic output to Python
csvmodule
- [feature] added
-si/--save-imagesflag to enable saving the first and last frames of each detected scene as an image, saved in the current working directory with the original video filename as the output prefix - [feature] added command line options for setting start and end times for processing (
-stand-et) - [feature] added command line option to specify maximum duration to process (
-dt, overrides-et)
- [feature] added downscaling/subsampling option (
-df/--downscale-factor) to improve performance on higher resolution videos - [feature] added frameskip option (
-fs/--frame-skip) to improve performance on high framerate videos, at expense of frame accuracy and possible inaccurate scene cut prediction - [enhance] added setup.py to allow for one-line installation (just run
python setup.py installafter downloading and extracting PySceneDetect) - [internal] additional API functions to remove requirement on passing OpenCV video objects, and allow just a file path instead
- major release, includes improved detection algorithms and complete internal code refactor
- [feature] content-aware scene detection using HSV-colourspace based algorithm (use
-d content) - [enhance] added CLI flags to allow user changes to more algorithm properties
- [internal] re-implemented threshold-based scene detection algorithm under new interface
- [internal] major code refactor including standard detection algorithm interface and API
- [internal] remove statistics mode until update to new detection mode interface
- [bugfix] updated OpenCV compatibility with self-reported version on some Linux distributions
- [bugfix] updated PySceneDetect to work with latest OpenCV module (ver > 3.0)
- [bugfix] added compatibility/legacy code for older versions of OpenCV
- [feature] statsfile generation includes expanded frame metrics
- [feature] added statistics mode for generating frame-by-frame analysis (-s / --statsfile flag)
- [bugfix] fixed improper timecode conversion
- [enhance] proper timecode format (HH:MM:SS.nnnnn)
- [enhance] one-line of CSV timecodes added for easy splitting with external tool
- [enhance] now provides discrete scene list (in addition to fades)
- [feature] ability to output to file (-o / --output flag)
- first public release
- [feature] threshold-based fade in/out detection