Python and OpenCV-based scene cut/transition detection program & library.

Overview

PySceneDetect

Video Scene Cut Detection and Analysis Tool

Build Status PyPI Status PyPI Version PyPI License

Latest Release: v0.5.6.1 (October 11, 2021)

Main Webpage: py.scenedetect.com

Documentation: manual.scenedetect.com

Discord: https://discord.gg/H83HbJngk7


Quick Install: To install PySceneDetect via pip with all dependencies:

pip install scenedetect[opencv]

For servers, you can use the headless (non-GUI) version of OpenCV by installing scenedetect[opencv-headless]. To enable video splitting support, you will also need to have mkvmerge or ffmpeg installed - see the documentation on Video Splitting Support for details.

Requires Python modules click, numpy, OpenCV cv2, and (optional) tqdm for displaying progress. For details, see the dependencies on the downloads page.


Quick Start (Command Line):

Split the input video wherever a new scene is detected:

scenedetect -i video.mp4 detect-content split-video

Skip the first 10 seconds of the input video, and output a list of scenes to the terminal:

scenedetect -i video.mp4 time -s 10s detect-content list-scenes

To show a summary of all other options and commands:

scenedetect help

You can find more examples on the website or in the manual.

Quick Start (Python API):

In the code example below, we create a function find_scenes() which will load a video, detect the scenes, and return a list of tuples containing the (start, end) timecodes of each detected scene. Note that you can modify the threshold argument to modify the sensitivity of the scene detection.

# Standard PySceneDetect imports:
from scenedetect import VideoManager
from scenedetect import SceneManager

# For content-aware scene detection:
from scenedetect.detectors import ContentDetector

def find_scenes(video_path, threshold=30.0):
    # Create our video & scene managers, then add the detector.
    video_manager = VideoManager([video_path])
    scene_manager = SceneManager()
    scene_manager.add_detector(
        ContentDetector(threshold=threshold))

    # Improve processing speed by downscaling before processing.
    video_manager.set_downscale_factor()

    # Start the video manager and perform the scene detection.
    video_manager.start()
    scene_manager.detect_scenes(frame_source=video_manager)

    # Each returned scene is a tuple of the (start, end) timecode.
    return scene_manager.get_scene_list()

To get started, try printing the result from calling find_scenes on a small video clip:

    scenes = find_scenes('video.mp4')
    print(scenes)

See the manual for the full PySceneDetect API documentation.


PySceneDetect is a command-line tool and Python library, which uses OpenCV to analyze a video to find each shot change (or "cut"/"scene"). If ffmpeg or mkvmerge is installed, the video can also be split into scenes automatically. 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. See the Usage documentation for details.

There are two main detection methods PySceneDetect uses: detect-threshold (comparing each frame to a set black level, useful for detecting cuts and fades to/from black), and detect-content (compares each frame sequentially looking for changes in content, useful for detecting fast cuts between video scenes, although slower to process). Each mode has slightly different parameters, and is described in detail below.

In general, use detect-threshold mode if you want to detect scene boundaries using fades/cuts in/out to black. If the video uses a lot of fast cuts between content, and has no well-defined scene boundaries, you should use the detect-content mode. Once you know what detection mode to use, you can try the parameters recommended below, or generate a statistics file (using the -s / --statsfile flag) in order to determine the correct paramters - specifically, the proper threshold value.

Note that PySceneDetect is currently in beta; see Current Features & Roadmap below for details. For help or other issues, you can join the official PySceneDetect Discord Server, submit an issue/bug report here on Github, or contact me via my website.

Usage

Current Features & Roadmap

You can view the latest features and version roadmap on Readthedocs. See docs/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.

Additional features being planned or in development can be found here (tagged as feature) in the issue tracker. You can also find additional information about PySceneDetect at http://www.bcastell.com/projects/PySceneDetect/.


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

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

Comments
  • Extra frames sometimes appear at the end of split videos

    Extra frames sometimes appear at the end of split videos

    First of all thank you for such a great tool! It seems that the precise flag (-p or --precise) has been changed to preset and does not work anymore although it's still written in the readme of the repo. I used the content detect option but still the cuts are not precise and there are some frames that overlap with the previous scene. Is there any way to cut the scenes more precisely?

    bug status: completed 
    opened by typoman 37
  • Extra frames show up when using `split-video` with ffmpeg

    Extra frames show up when using `split-video` with ffmpeg

    As the title: i don't get good cuts. But often the scenes start or end with the previous or next scene.

    I'm using a standard: detect-content split-video.

    It's happening with different sources.

    python source: https://www.python.org/ftp/python/3.8.2/python-3.8.2.exe pyscenedetect source: pip install scenedetect[opencv,progress_bar] ffmpeg source: https://ffmpeg.zeranoe.com/builds/win64/static/ffmpeg-20200415-51db0a4-win64-static.zip

    Here the debug command output: debug.txt

    bug status: completed 
    opened by ghost 30
  • Scenedetect fails on mp4 video with multiple audio tracks

    Scenedetect fails on mp4 video with multiple audio tracks

    Bug/Issue Description: I get fatal errors using scenedetect with a multiaudio stream mp4. When I used ffmpeg to copy to an mkv with the same streams, or when I copy to an mp4 with only one audio stream, it works. It will not work with multiple streams in an mp4.

    Required Information: Provide the following information to assist with reporting the bug:

    1. Provide a full copy of the command line options you are using, for example:
    scenedetect --input /Volumes/sources/sources/video/movie/chapter_5/landscape.mp4  --output /Volumes/sources/sources/movie/movie/chapter_5/scene_detect  --stats stats.csv detect-content list-scenes save-images            
    
    

    attach the generated BUG_REPORT.txt file.

    INFO: __init__.scenedetect_cli(): Version: v0.5.3
    INFO: __init__.scenedetect_cli(): Info Level: debug
    INFO: __init__.scenedetect_cli(): Output directory set:
      /Volumes/sources/sources/video/movie/chapter_5/scene_detect
    DEBUG: context.parse_options(): Parsing program options.
    DEBUG: context._init_video_manager(): Initializing VideoManager.
    INFO: video_manager.__init__(): Loaded 1 video, framerate: 23.98 FPS, resolution: 886 x 480
    INFO: video_manager.set_downscale_factor(): Downscale factor set to 3, effective resolution: 295 x 160
    DEBUG: context.parse_options(): VideoManager initialized.
    DEBUG: __init__.detect_content_command(): Detecting content, parameters:
      threshold: 30, min-scene-len: 14
    INFO: context.list_scenes_command(): Scene list CSV file name format:
      $VIDEO_NAME-Scenes.csv
    INFO: context.save_images_command(): Image output format set: JPEG
    DEBUG: context.process_input(): Processing input...
    INFO: context.process_input(): Detecting scenes...
    INFO: context.process_input(): Processed 0 frames in 0.0 seconds (average 0.00 FPS).
    DEBUG: context.process_input(): No frame metrics updated, skipping update of the stats file.
    INFO: context.process_input(): Detected 1 scenes, average shot length 0.0 seconds.
    INFO: context.process_input(): Writing scene list to CSV file:
      /Volumes/sources/sources/video/movie/chapter_5/scene_detect/landscape-Scenes.csv
    INFO: context.process_input(): Scene List:
    -----------------------------------------------------------------------
     | Scene # | Start Frame |  Start Time  |  End Frame  |   End Time   |
    -----------------------------------------------------------------------
     |      1  |           0 | 00:00:00.000 |           0 | 00:00:00.000 |
    -----------------------------------------------------------------------
    
    INFO: video_manager.set_downscale_factor(): Downscale factor set to 1, effective resolution: 886 x 480
    INFO: context._generate_images(): Generating output images (3 per scene)...
    DEBUG: context.cleanup(): Cleaning up...
    
    
    INFO: __init__.scenedetect_cli(): Version: v0.5.3
    INFO: __init__.scenedetect_cli(): Info Level: debug
    INFO: __init__.scenedetect_cli(): Output directory set:
      /Volumes/sources/sources/video/movie/chapter_5/scene_detect
    DEBUG: context.parse_options(): Parsing program options.
    DEBUG: context._init_video_manager(): Initializing VideoManager.
    INFO: video_manager.__init__(): Loaded 1 video, framerate: 23.98 FPS, resolution: 886 x 480
    INFO: video_manager.set_downscale_factor(): Downscale factor set to 3, effective resolution: 295 x 160
    DEBUG: context.parse_options(): VideoManager initialized.
    DEBUG: __init__.detect_content_command(): Detecting content, parameters:
      threshold: 30, min-scene-len: 14
    INFO: context.list_scenes_command(): Scene list CSV file name format:
      $VIDEO_NAME-Scenes.csv
    INFO: context.save_images_command(): Image output format set: JPEG
    DEBUG: context.process_input(): Processing input...
    INFO: context.process_input(): Detecting scenes...
    INFO: context.process_input(): Processed 0 frames in 0.0 seconds (average 0.00 FPS).
    DEBUG: context.process_input(): No frame metrics updated, skipping update of the stats file.
    INFO: context.process_input(): Detected 1 scenes, average shot length 0.0 seconds.
    INFO: context.process_input(): Writing scene list to CSV file:
      /Volumes/sources/sources/video/movie/chapter_5/scene_detect/landscape-Scenes.csv
    INFO: context.process_input(): Scene List:
    -----------------------------------------------------------------------
     | Scene # | Start Frame |  Start Time  |  End Frame  |   End Time   |
    -----------------------------------------------------------------------
     |      1  |           0 | 00:00:00.000 |           0 | 00:00:00.000 |
    -----------------------------------------------------------------------
    
    INFO: video_manager.set_downscale_factor(): Downscale factor set to 1, effective resolution: 886 x 480
    INFO: context._generate_images(): Generating output images (3 per scene)...
    DEBUG: context.cleanup(): Cleaning up...
    
    
    

    Expected Behavior: Expect the process to run with output and no error

    Computing Environment: Dockerfile

    FROM python:3.8-slim
    
    RUN apt-get update && apt-get install -y \
      libglib2.0-0 \
      libsm6 \
      libxext6 \
      libxrender-dev \
      libgl1-mesa-glx \
      && rm -rf /var/lib/apt/lists/*
    
    RUN pip install --no-cache-dir scenedetect[opencv,progress_bar]==0.5.3
    

    Additional Information: Just my gratefulness for making this!

    bug status: completed known issue 
    opened by tslater 19
  • Progress regarding refactor

    Progress regarding refactor

    I couldnt notice there was done anything refactoring lately, it that still underway? Or has it stopped? I have some ideas on how we can make this more modular. Atm it seems like the library is written to support the cli.

    status: duplicate 
    opened by Hellowlol 19
  • Weird problem with non-existence of MKVMerge

    Weird problem with non-existence of MKVMerge

    First of all, Thanks for awesome scene cutter tools/scripts(whatever I call), I was searching long time for it. I was doing lots of videos past 2 weeks. Today I got some weird problem: SceneDetect.notfound.mkvmerge.txt Here is used file codec Videocodec.txt I hope you works hard to fix this weird issue. By the way I used portable version. you see last error proved that! Thanks

    bug status: accepted community feedback requested 
    opened by raj6996 16
  • Support for Live Video Stream (Non-Terminating) Processing Mode

    Support for Live Video Stream (Non-Terminating) Processing Mode

    PySceneDetect should have a mode that allows for an OpenCV VideoCapture object that doesn't terminate (e.g. a webcam, or live internet stream) and continually provides updates for when a new scene is detected. This should work fine with both of the currently implemented scene detectors (ThresholdDetector and ContentDetector), although the main detection loop function scenedetect.detect_scenes() will need to be changed.

    Using the set format, a timecode should be printed, followed by a newline, at the discovery of each new scene. This should allow other programs monitoring the process output a notification that a new scene was found. Additionally, for integration with other Python programs, an incremental version of detect_scenes() should be created that allows the user to pass one frame per call, with the function returning the current frame number if a scene change was detected, or None otherwise.

    feature status: completed 
    opened by Breakthrough 15
  • Cut video without final frame

    Cut video without final frame

    Did a bit of experimenting this evening and got it figured out. You need to put the start and end arguments after the input argument. Also specify a frame before the end frame.

    I have also swapped from using duration, to specifying the end timecode. And using timecode for start, rather than number of seconds.

    bug status: completed 
    opened by SpangleLabs 14
  • Reduce false positives in ContentDetector due to camera movement

    Reduce false positives in ContentDetector due to camera movement

    Hi there! First of all, thanks for all your work on this clean, fast, and extremely promising module.

    The current algorithm for detecting fast cuts with ContentDetector is already quite reliable, but looking through the raw data to find the correct threshold value can be tiresome, and lowering the threshold can sometimes produce false positives, especially in clips where there's no cut but there is fast camera movement. Camera movement can produce a series of frames with high content_val, and if any of the frames go over the threshold, it's interpreted as a cut. You can try with these examples (1, 2) that I've taken from an old film I'm studying. There are real cuts that have a content_val of only 9 or 10 (file 2, frame 1172, 00:46), but also false positives with content_val greater than 10 (file 1, frame 403, 00:16).

    One possible way to deal with this would be to look for fast peaks in the amount of change -- peaks that can't last for more than a frame or two. Once we've calculated the content change for all the frames in the clip, we can then calculate the ratio of each frame's content_val to the content_val of the surrounding frames. In pseudocode:

    metathreshold = 3
    cut_list = []
    while i < len(frames):
        content_val_ratio = content_val(frames[i])
            / (content_val(frames[i - 2]) 
            + content_val(frames[i - 1])
            + content_val(frames[i + 1])
            + content_val(frames[i + 2])) / 4)
        if (content_val_ratio >= metathreshold and content_val(frames[i]) >= 5):
            cut_list.append(i)
        i += 1
    

    From the tests I've done, the "metathreshold" value of 3 (mark a frame as a cut if its content-val is more than three times the content-val of its neighbors) and the baseline content-val threshold of 5 (still, don't mark anything as a cut if its content-val is less than 5) seem like sane defaults. I think they're easier to pick out than the current threshold value, but this is open to discussion and more testing.

    I've been messing around with the code and come up with a way of implementing this as a SceneDetector object using the model you've already created. However, the current API calculates HSV values one by one as each frame is passed to the detector, so I also added a second post-processing step in scene_manager.py after all those values have been stored. This step calculates the running average of change in surrounding frames and produces a list of cuts based on this. There are probably other ways of doing this, though.

    Let me know if you think this is useful. If you're interested, I'll make a pull request.

    feature status: completed 
    opened by scarwire 13
  • Unable to run scenedetect on bluemix cf app

    Unable to run scenedetect on bluemix cf app

    I am running a python flask app on bluemix. The code runs perfectly well on local machine( macbook pro) but for some reason I am unable to run it on bluemix. Error is shown below:

    TypeError: 'int' object is not iterable

    The reason I am getting this error is because opencv-python which is being installed (via pip) does not support ffmpeg and thus it is unable to run this line of code.

    cap = cv2.VideoCapture(video_file_path)
    cap.isOpened()
    

    returns false

    Any solution for this?

    opened by yashgoyalMIT 13
  • runtime error with TypeError

    runtime error with TypeError

    Hello,

    I'm trying to test pySceneDetect with Python 2.7.12, numpy 1.11.1, scipy 0.17.1 and openCV 2.4.13 on Windows 10 64bit. All seemed good but I got error when trying to run PySceneDetect on command line, that was:

    C:\Works>scenedetect -i goldeneye.mp4 [PySceneDetect] Detecting scenes (threshold mode)... [PySceneDetect] FATAL ERROR - could not open video goldeneye.mp4. Traceback (most recent call last): File "C:\2ndPrograms\Python27\Scripts\scenedetect-script.py", line 9, in load_entry_point('PySceneDetect==0.3.4', 'console_scripts', 'scenedetect')() File "c:\2ndprograms\python27\lib\site-packages\scenedetect__init__.py", line 346, in main timecode_list = timecode_list TypeError: 'int' object is not iterable

    What is my fault? I think your code worked correctly but someone said TypeError needed to be fixed like in using List according to googling. Sorry for writing this asking in Issue raising page. Thank you.

    bug improvement status: completed 
    opened by gitcomo 13
  • v0.6 Beta Release & Feedback

    v0.6 Beta Release & Feedback

    PySceneDetect v0.6 is now in ~beta~ release candidate, including performance improvements and major API updates - see the new Quickstart guide (feedback is welcome!). You can install the beta from pip:

    pip install --upgrade --pre scenedetect
    

    Or downloading a portable .exe version for Windows. You can also download a .whl or .exe directly from the latest builds on AppVeyor (go to the latest successful build, click on any Python version, and go to Artifacts).

    Links:

    • API/CLI Docs: http://manual.scenedetect.com/en/v0.6
    • Updated Site: http://scenedetect.com/en/v0.6
    • Changelog & Release Notes: https://github.com/Breakthrough/PySceneDetect/releases/tag/v0.6-rc0)

    In addition to bug reports, please post any feedback on the new API changes, configuration file support, and performance changes. Owners of existing packages relying on scenedetect should pin their project to < 0.6 and prepare for the upcoming changes, however the final release will include some degree of backwards compatibility with v0.5 to avoid breaking most applications.

    Known Beta-Only Issues

    Issues only affecting the v0.6 beta. Checkmark indicates done and ready for next beta release. v0.6-dev4 will be the final beta release.

    • [X] Fix hang when using --backend pyav on Linux when program quits
      • Must manually enable multithreading mode now using a config file option (set threading-mode = auto under [backend-pyav])
    • [x] Quality set when using save-images is ignored, always set to 95 for JPEG and 100 for WebP

    See the changelog for a full list of known issues.

    discussion community feedback requested 
    opened by Breakthrough 12
  • newbie: got error

    newbie: got error "No scene detectors specified (...), or failed to process all command line arguments."

    Bug/Issue Description:

    install newer version with pip, run scenedetect in window cmd shows me errors (in Additional Information underneath).

    but

    I tried python script below, which works.

    from scenedetect import detect, ContentDetector, split_video_ffmpeg
    scene_list = detect('c:/video.mp4', ContentDetector())
    print(scene_list)
    split_video_ffmpeg('c:/video.mp4', scene_list)
    

    and

    I tried to download scenedetect portable version, it works too.

    question:

    How can I make my pip installation works?

    Required Information:

    1. Provide a full copy of the command line options you are using:

    scenedetect -i .\video.mp4 detect-adaptive list-scenes

    1. Add -v debug -l BUG_REPORT.txt to the beginning of the command, then re-run PySceneDetect and attach the generated BUG_REPORT.txt file.

    BUG_REPORT.txt

    Expected Behavior: have a scene list table in the concole.

    Computing Environment:

    • OS: Windows 10
    • Python Version: 3.9.10
    • OpenCV Version: opencv-python 4.5.5.62

    Additional Information:

    scenedetect -i video.mp4 detect-adaptive list-scenes
    [PySceneDetect] PySceneDetect v0.6.1
    [PySceneDetect] No scene detectors specified (detect-content, detect-threshold, etc...),
     or failed to process all command line arguments.
    Traceback (most recent call last):
      File "C:\Python3\lib\runpy.py", line 197, in _run_module_as_main
        return _run_code(code, main_globals, None,
      File "C:\Python3\lib\runpy.py", line 87, in _run_code
        exec(code, run_globals)
      File "C:\Python3\Scripts\scenedetect.exe\__main__.py", line 7, in <module>
      File "C:\Python3\lib\site-packages\scenedetect\__main__.py", line 33, in main
        cli.main(obj=cli_ctx)  # Parse CLI arguments with registered callbacks.
      File "C:\Python3\lib\site-packages\click\core.py", line 782, in main
        rv = self.invoke(ctx)
      File "C:\Python3\lib\site-packages\click\core.py", line 1276, in invoke
        sub_ctx = cmd.make_context(
      File "C:\Python3\lib\site-packages\click\core.py", line 700, in make_context
        self.parse_args(ctx, args)
      File "C:\Python3\lib\site-packages\click\core.py", line 1048, in parse_args
        value, args = param.handle_parse_result(ctx, opts, args)
      File "C:\Python3\lib\site-packages\click\core.py", line 1623, in handle_parse_result
        value = self.full_process_value(ctx, value)
      File "C:\Python3\lib\site-packages\click\core.py", line 1965, in full_process_value
        return Parameter.full_process_value(self, ctx, value)
      File "C:\Python3\lib\site-packages\click\core.py", line 1592, in full_process_value
        value = self.get_default(ctx)
      File "C:\Python3\lib\site-packages\click\core.py", line 1917, in get_default
        return Parameter.get_default(self, ctx)
      File "C:\Python3\lib\site-packages\click\core.py", line 1534, in get_default
        return self.type_cast_value(ctx, rv)
      File "C:\Python3\lib\site-packages\click\core.py", line 1561, in type_cast_value
        return self.type(value or (), self, ctx)
      File "C:\Python3\lib\site-packages\click\types.py", line 46, in __call__
        return self.convert(value, param, ctx)
      File "C:\Python3\lib\site-packages\click\types.py", line 681, in convert
        raise TypeError(
    TypeError: It would appear that nargs is set to conflict with the composite type arity.
    
    bug status: accepted 
    opened by rsyqvthv 5
  • Support cropping / region of interest

    Support cropping / region of interest

    Processing only a sub-set of a video frame should be possible. This can greatly improve performance and detection accuracy in some cases.

    To avoid any issues with cropping or output, both save-images and split-video should still output the full video. Cropping of the output can be considered in the future, but should be avoided if possible and done by post-processing the output of PySceneDetect. The same applies to non-rectangular ROIs or overlapping regions.

    This was originally brought up in #147. This is also a feature in PyVfxShotDetect, so we can consider implementing something similar: https://github.com/ThomasWeckenmann/PyVfxShotDetect/blob/master/scenedetect/bbox_video_stream.py

    feature status: accepted 
    opened by Breakthrough 0
  • Color Histogram Detector

    Color Histogram Detector

    As discussed in #53 by @r1b, I have taken inspiration from his notebook as well as this paper (pdf) and implemented a color histogram based detector. Command syntax is as follows:

        Command: 
            detect-hist
        
        Arguments:
            --threshold, -t
                Threshold (float) that must be exceeded to trigger a cut.
            
            --bits, -b
                The number of most significant bits to keep when quantizing the color
                channels of each frame.
            
            --min-scene-len, -m
                Same as other detectors
    

    For some detail on the detection algorithm, it works in a couple steps:

    1. The frame of the video is separated by color channel and each color channel is quantized. The quantization is done by only retaining the --bits/-b most significant bits of each pixel. The purpose of this step is to reduce the size of the histogram we will be generating in a future step to make it a bit more tractable.
    2. After quantizing each color channel, we want to combine the bits for each pixel of each color channel into one array. For example, with --bits 2, the resulting array would have elements with bit values of 0bRRGGBB where RR are the two most significant bits from the red channel, GG from the green channel, and BB from the blue channel. With --bits 4 this becomes 0bRRRRGGGGBBBB and so on. This is done by performing bitwise shift operations on the different color channels before joining them using bitwise or operations.
    3. With this one array, a histogram is calculated. The number of bins is given by the possible number of colors after all the quantization. So, for --bits 4 that would be 212 (12 comes from the 4 bits for each of the three color channels). Using --bits 2 would be 26 bins.
    4. This histogram is subtracted element-wise from the previous frame's histogram, and the resulting array has all its elements' absolute values summed to find the total difference. This is the value that is checked to trigger cuts and is what is recorded in the stats file as hist_diff.

    There are a couple things that I should mention with the current implementation. First and foremost is that the input frames need to be an 8-bit color image. This means that grayscale images that don't have the three color channels will not work. Also, inputs that have a bit-depth greater than 8 bits such as image sequences of 16-bit images will not work. I have included some checks to make sure the input is of the right shape and dtype.

    The threshold is very sensitive to changes in the analysis parameters. Changing options like the downscale factor or the --bits value will have a large impact on what a good threshold would be. Just something to note as the other detectors are not as sensitive to these kind of changes. For defaults, I have chosen values that work well on the goldeneye clip with default downscaling.

    Computationally, this detector is not as efficient as others. I have done some testing on my machine and included below the average fps of the detection for different detection algorithms with both default downscaling and -d 1.

    | detector | fps with -d default | fps with -d 1 | Other Notes | |--------------------|-----------------------|-----------------|-------------| | detect-hist | 637.78 | 49.31 | -b 4 | | detect-hist | 1450.72 | 53.43 | -b 2 | | detect-content | 1422.79 | 300.61 | | | detect-adaptive | 1480.52 | 293.96 | | | detect-threshold | 1425.77 | 1228.24 | |

    If this is something worth cleaning up/improving, I can work on tests and docs.

    opened by wjs018 0
  • Split video based on csv file

    Split video based on csv file

    As discussed in #235, #275, and #115 this is a frequently requested feature. I have put together a first pass at implementation based on @Breakthrough's outline in #275. I would not say this is in a complete state yet, but wanted to get some eyes on it and feedback as to how some of the details of this command should work. I have outlined the way it currently functions below:

    The new detector (load-scenes command from the cli) is designed to use a csv file as input and detect scene transitions based on the scenes in the csv. It doesn't actually do any video or image analysis and it ignores things like min_scene_len or the use of a StatsManager. It also isn't really meant to be used in conjunction with other detectors (though I haven't forbidden it yet). It's main use case is for manually editing a previously generated csv file to tweak the detected scenes and then using that to split the video based on the scenes in the csv file.

        Command: 
            load-scenes
        
        Arguments:
            --input, -i
                Specify path to input csv file. Currently required as no default is set.
            
            --start-col, -s
                Specify the header of the column used to mark the start of new scenes. Column
                contents can be anything parseable by `FrameTimecode`. Defaults to "Start Frame".
            
            --end-col, -e
                Specify the header of the column used to mark the end of scenes. Defaults
                to "End Frame".
            
            --framerate, -f
                Framerate of the video. This is needed only if scene starts and ends
                are specified in timecodes rather than frame numbers to do conversions.
    

    The way this command currently works is that it reads the input csv file row by row and as the video is processed, when the current frame number is equal to the frame number of the next scene start (per the csv), then it "detects" a cut. This means that the csv must be in order from earliest scene to latest. Also, if the start time of the video is later than the first scene in the csv, it will not detect anything. @Breakthrough, is this desired behavior? If not, then I might need some help brainstorming how to change this.

    Another important bit to mention is that this detector currently can't skip over unwanted scenes. This is something that was brought up in #275, but I am not sure how to (with the current api) mark scenes to be ignored. The detectors just produce a list of cuts. @Breakthrough I am guessing this is maybe an improvement for a future api change. EDIT: Just stumbled across #123 which is a relevant discussion for this point.

    As a corollary to the above point, even if the input csv file doesn't have a scene starting at frame 1, this detector (like all the others), will include a scene the begins at the first frame and goes until the first detected cut (from the csv).

    One final point is that currently the --end-col/-e argument is not really used for anything. I debated just getting rid of it entirely, but some of the uses thought up in #275 would require it even though the current api (I don't think) supports them.

    This command is compatible with the csv file generated by the list-scenes command as long as the -s flag is included (list-scenes -s). Otherwise, the column headers are not read correctly and the csv file in general is not formatted in a way to programmatically parse. See #243 and #136 for discussion on this.

    If it isn't obvious by now, this isn't in a final form yet, but I wanted to get some feedback. I haven't updated any docs or tests yet but can do so if this starts to gel into something approaching a final form.

    opened by wjs018 0
  • Setting start timecode of clips split with split-video

    Setting start timecode of clips split with split-video

    Similarly to https://github.com/Breakthrough/PySceneDetect/pull/291#issuecomment-1288973981 It would be cool to be able to force the start timecode of a clip to be baked as the "ffmpeg seek timecode", either through the custom ffmpeg options or maybe a global one like -timecode -tc like how -crf is used in pyscenedetect

    feature status: awaiting response 
    opened by camjac251 1
  • Support PyAV 10+ (Python 3.11)

    Support PyAV 10+ (Python 3.11)

    The current VideoStreamAv backend does not work with PyAV 10.0 and uses several now deprecated/removed features.

    Looks like binary packages of PyAV are only available from version 10 onwards for Python 3.11.

    technical item 
    opened by Breakthrough 0
Releases(v0.6.1-release)
  • v0.6.1-release(Nov 29, 2022)

    Release Notes

    Adds edge detection capability for fast cuts, addresses outstanding bugs, and includes various enhancements.

    Changelog

    Command-Line Changes:

    • [feature] Add moviepy backend wrapping the MoviePy package, uses ffmpeg binary on the system for video decoding
    • [feature] Edge detection can now be enabled with detect-content and detect-adaptive to improve accuracy in some cases, especially under lighting changes, see new -w/--weights option for more information
      • A good starting point is to place 100% weight on the change in a frame's hue, 50% on saturation change, 100% on luma (brightness) change, and 25% on change in edges, with a threshold of 32: detect-adaptive -w 1.0 0.5 1.0 0.25
      • Edge differences are typically larger than other components, so you may need to increase -t/--threshold higher when increasing the edge weight (the last component) with detect-content, for example: detect-content -w 1.0 0.5 1.0 0.25 -t 32
      • May be enabled by default in the future once it has been more thoroughly tested, further improvements for detect-content are being investigated as well (e.g. motion compensation, flash suppression)
      • Short-form of detect-content option --frame-window has been changed from -w to -f to accomodate this change
    • [enhancement] Progress bar now displays number of detections while processing, no longer conflicts with log message output
    • [enhancement] When using ffmpeg to split videos, -map 0 has been added to the default arguments so other audio tracks are also included when present (#271)
    • [enhancement] Add -a flag to version command to print more information about versions of dependencies/tools being used
    • [enhancement] The resizing method used used for frame downscaling or resizing can now be set using a config file, see [global] option downscale-method and [save-images] option scale-method
    • [other] Linear interpolation is now used as the default downscaling method (previously was nearest neighbor) for improved edge detection accuracy
    • [other] Add -c/--min-content-val argument to detect-adaptive, deprecate -d/--min-delta-hsv

    General:

    • [general] Recommend detect-adaptive over detect-content
    • [feature] Add new experimental backend VideoStreamMoviePy using the MoviePy package
    • [feature] Add edge detection to ContentDetector and AdaptiveDetector (#35)
      • Add ability to specify content score weights of hue, saturation, luma, and edge differences between frames
      • Default remains as 1.0, 1.0, 1.0, 0.0 so there is no change in behavior
      • Kernel size used for improving edge overlap can also be customized
    • [feature] AdaptiveDetector no longer requires a StatsManager and can now be used with frame_skip (#283)
    • [bugfix] Fix scenedetect.detect() throwing TypeError when specifying stats_file_path
    • [bugfix] Fix off-by-one error in end event timecode when end_time was set (reported end time was always one extra frame)
    • [bugfix] Fix a named argument that was incorrect (#299)
    • [enhancement] Add optional start_time, end_time, and start_in_scene arguments to scenedetect.detect() (#282)
    • [enhancement] Add -map 0 option to default arguments of split_video_ffmpeg to include all audio tracks by default (#271)
    • [docs] Add example for using a callback (#273)
    • [enhancement] Add new VideoCaptureAdapter to make existing cv2.VideoCapture objects compatible with a SceneManager (#276)
      • Primary use case is for handling input devices/webcams and gstreamer pipes, see updated examples
      • Files, image sequences, and network streams/URLs should continue to use VideoStreamCv2
    • [api] The SceneManager methods get_cut_list() and get_event_list() are deprecated, along with the base_timecode argument
    • [api] The base_timecode argument of get_scenes_from_cuts() in scenedetect.stats_manager is deprecated (the signature of this function has been changed accordingly)
    • [api] Rename AdaptiveDetector constructor parameter min_delta_hsv to `min_content_val
    • [general] The default crf for split_video_ffmpeg has been changed from 21 to 22 to match command line default
    • [enhancement] Add interpolation property to SceneManager to allow setting method of frame downscaling, use linear interpolation by default (previously nearest neighbor)
    • [enhancement] Add interpolation argument to save_images to allow setting image resize method (default remains bicubic)
    Source code(tar.gz)
    Source code(zip)
    PySceneDetect-0.6.1-win64-portable.zip(124.43 MB)
    PySceneDetect-0.6.1-win64.msi(126.84 MB)
    scenedetect-0.6.1-py3-none-any.whl(112.40 KB)
    scenedetect-0.6.1.tar.gz(96.60 KB)
  • v0.6-release(May 30, 2022)

    Release Notes

    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.

    Changelog

    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 with VideoStream), StatsManager, and save_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 a scenedetect.cfg file in your user config folder
    • 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-scene option to merge last scene if shorter than --min-scene-len
    • Add -b/--backend option to use a specific video decoding backend
      • Supported backends are opencv and pyav
      • Run scenedetect help to see a list of backends available on the current system
      • Both backends are included with Windows builds
    • split-video command:
      • -c/--copy now uses ffmpeg instead of mkvmerge (#77, #236)
      • Add -m/--mkvmerge flag to use mkvmerge instead of ffmpeg (#77)
      • Long name for -a has been changed to --args (from --override-args)
    • detect-adaptive command:
      • --drop-short-scenes now works properly with detect-adaptive
    • detect-content command:
      • Default threshold -t/--threshold lowered to 27 to be more sensitive to shot changes (#246)
      • Add override for global -m/--min-scene-len option
    • detect-threshold command:
      • Remove -p/--min-percent and -b/--block-size options
      • Add override for global -m/--min-scene-len option
    • save-images command now works when -i/--input is an image sequences
    • Default backend (OpenCV) is more robust to video decoder failures
    • -i/--input may no longer be specified multiple times, if required use an external tool (e.g. ffmpeg, mkvmerge) to perform concatenation before processing
    • -s/--stats no longer loads existing statistics and will overwrite any existing files
    • -l/--logfile now respects -o/--output
    • -v/--verbosity now 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() and split_video_mkvmerge() now take a single path as input
    • save_images() no longer accepts downscale_factor
      • Use scale or height/width arguments to resize images
    • New VideoStream replaces VideoManager (#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_number is 1-based whereas position is 0-based to align with PTS)
      • See test_time_invariants in tests/test_video_stream.py as a reference of specific behaviours
    • Changes to SceneManager:
      • detect_scenes() now performs video decoding in a background thread, improving performance on most systems
      • SceneManager is now responsible for frame downscaling via the downscale/auto_downscale properties
      • detect_scenes() no longer shows a progress bar by default, set show_progress=True to restore the previous behaviour
      • clear() now clears detectors, as they may be stateful
      • get_scene_list() now returns an empty list if there are no detected cuts, specify start_in_scene=True for previous behavior (one scene spanning the entire input)
    • Changes to StatsManager:
      • save_to_csv() now accepts a path or an open file handle
      • base_timecode argument has been removed from save_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
      • FrameTimecode objects can now perform arithmetic with formatted strings, e.g. 'HH:MM:SS.nnn'
    • Merged constants MAX_FPS_DELTA and MINIMUM_FRAMES_PER_SECOND_DELTA_FLOAT in scenedetect.frame_timecode into new MAX_FPS_DELTA constant
    • video_manager parameter has been removed from the AdaptiveDetector constructor
    • split_video_ffmpeg and split_video_mkvmerge function arguments have been renamed and defaults updated:
      • suppress_output is now show_output, default is False
      • hide_progress is now show_progress, default is False
    • block_size argument has been removed from the ThresholdDetector constructor
    • calculate_frame_score method of ContentDetector has been renamed to _calculate_frame_score, use new module-level function of the same name instead
    • get_aspect_ratio has been removed from scenedetect.platform (use the aspect_ratio property of a VideoStream instead)
    • Backwards compatibility with v0.5 to avoid breaking most applications on release while still allowing performance improvements

    Python Distribution Changes

    • 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 av to run the scenedetect command

    Known Issues

    • URL inputs are not supported by the save-images or split-video commands
    • Variable framerate videos (VFR) are not fully supported, and will yield incorrect timestamps (#168)
    • The detect-threshold option -l/--add-last-scene cannot 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
    Source code(tar.gz)
    Source code(zip)
    PySceneDetect-0.6-win64-portable.zip(113.26 MB)
    PySceneDetect-0.6-win64.msi(150.77 MB)
  • v0.5.6.1(Oct 12, 2021)

    Fixes crash when using detect-content or detect-adaptive with latest version of OpenCV (thanks @bilde2910). Does not affect the Windows distributions, for the installer/portable version continue to download v0.5.6.

    Source code(tar.gz)
    Source code(zip)
  • v0.5.6(Aug 15, 2021)

    Release Notes

    • New detection algorithm: detect-adaptive which works similar to detect-content, but with reduced false negatives during fast camera movement (thanks @scarwire and @wjs018)
    • Images generated by save-images can now be resized via the command line
    • Statsfiles now work properly with detect-threshold
    • Removed the -p/--min-percent option from detect-threshold
    • Add new option -l/--luma-only to detect-content/detect-adaptive to only consider brightness channel (useful for greyscale videos)

    Changelog

    • [feature] New adaptive content detector algorithm detect-adaptive (#153, thanks @scarwire and @wjs018)
    • [feature] Images generated with the save-images command (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.5 shrinks 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
    • [api] Calling seek() on a VideoManager will now respect the end time if set
    • [api] The split_video_ functions now return the exit code of invoking ffmpeg or mkvmerge (#209, thanks @AdrienLF)
    • [api] Removed the min_percent argument from ThresholdDetector as was not providing any performance benefit for the majority of use cases (#178)
    • [bugfix] The detect-threshold command now works properly with a statsfile (#211, thanks @jeremymeyers)
    • [bugfix] Fixed crash due to unhandled TypeError exception 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)

    Known Issues

    • Variable framerate videos (VFR) are not fully supported, and will yield incorrect timestamps (#168)
    • The -l/--add-last-scene option in detect-threshold cannot be disabled
    • Image sequences or URL inputs are not supported by the save-images or split-video commands (in v0.6 save-images works 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)
    Source code(tar.gz)
    Source code(zip)
    PySceneDetect-0.5.6-win64-portable.zip(73.18 MB)
    PySceneDetect-0.5.6-win64.exe(88.41 MB)
  • v0.5.5(Jan 17, 2021)

    Release Notes

    • One of the last major updates before transitioning to the new v1.0.x API
    • The --min-scene-len/-m option is now global rather than per-detector
    • There is a new global option --drop-short-scenes to 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-images command are now resized to match the display aspect ratio
    • A new flag -s/--skip-cuts has been added to the list-scenes command to allow standardized processing
    • The functionality of save-images is now accessible via the Python API through the save_images() function in scenedetect.scene_manager
    • Under the save-images command, renamed --image-frame-margin to --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 0 to restore original behaviour)

    Changelog

    Full changelog can be found here on Github.

    Known Issues

    • Image sequences or URL inputs are not supported by the save-images or split-video commands
    • Variable framerate videos (VFR) are not fully supported, and will yield incorrect timestamps (#168)
    Source code(tar.gz)
    Source code(zip)
    PySceneDetect-0.5.5-win64-portable.zip(73.15 MB)
    PySceneDetect-0.5.5-win64.exe(88.35 MB)
  • v0.5.4(Sep 15, 2020)

    Release Notes

    • Improved performance when using time and save-images commands
    • Improved performance of detect-threshold when using a small minimum percent
    • Fix crash when using detect-threshold with a statsfile
    • Fix crash when using save-images command under Python 2.7
    • Support for Python 3.3 and 3.4 has been deprecated (see below)
    • Version number on PyPI for this release is v0.5.4.1

    Changelog

    Full changelog can be found here on Github.

    Known Issues

    • 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)
    • In certain cases, video files which will not load will fail silently, with PySceneDetect reporting that it processed 0 frames. Better error handling/messaging is planned for these cases as part of #179
    Source code(tar.gz)
    Source code(zip)
  • v0.5.3(Jul 12, 2020)

    Release Notes

    • Resolved long-standing bug where split-video command 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 aac codec when using split-video (it can be overriden in both the command line and Python interface)
    • Improved timestamp accuracy when using split-video command to further reduce instances of duplicated or off-by-one frame issues
    • Fixed application crash when using the -l/--logfile argument

    Changelog

    Full changelog can be found here on Github.

    Known Issues

    • Seeking through long videos is inefficient, causing the time and save-images command to take a long time to run. This will be resolved in the next release (see #98)
    • The save-images command causes PySceneDetect to crash under Python 2.7 (see #174)
    • Using detect-threshold with 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 ffmpeg or mkvmerge
    Source code(tar.gz)
    Source code(zip)
  • v0.5.2(Mar 29, 2020)

    Minor release including only additions and bugfixes (thanks to everyone who contributed to this release!). Changelog:

    • [enhancement] --min-duration now accepts a timecode in addition to frame number (#128, thanks @tonycpsu)
    • [feature] Add --image-frame-margin option to save-images command to ignore a number of frames at the start/end of a scene (#129, thanks @tonycpsu)
    • [bugfix] --min-scene-len option 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-video command when using ffmpeg (#93, thanks @typoman)
    • [bugfix] Added links and filename sanitation to html output (#139 and #140, thanks @wsj018)
    • [bugfix] UnboundLocalError in detect_scenes when frame_skip is larger than 0 (#126, thanks @twostarxx)
    Source code(tar.gz)
    Source code(zip)
  • v0.5.1.1(Aug 3, 2019)

    • minor re-release of v0.5.1, includes updated setup.py which returns OpenCV to an optional dependency

    • to install from pip now with all dependencies:

      pip install scenedetect[opencv,progress_bar]

    • to install only PySceneDetect: (separate OpenCV installation required)

      pip install scenedetect

    • the release notes of v0.5.1 have been modified to include the prior command

    • no change to PySceneDetect program version

    • [feature] add get_duration method to VideoManager (#109, thanks @arianaa30)


    This change was made to support platforms where the opencv-python package is unavailable, and to allow using a non-pip version of OpenCV (e.g. a binary install or building from source). See #73 for why the original fix was implemented, and #111 for details on what prompted this re-release.

    Source code(tar.gz)
    Source code(zip)
  • v0.5.1(Jul 20, 2019)

    • [feature] Add new export-html command 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.
    Source code(tar.gz)
    Source code(zip)
  • v0.5(Aug 31, 2018)

    You can install via pip:

    pip install scenedetect
    

    There is now a manual published at manual.scenedetect.com. See the main project page for details on installing dependencies.

    The Windows build should be released within a week or so.

    Changelog

    • 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 ffmpeg by default, resulting in frame-perfect cuts (can still use mkvmerge by specifying the -c/--copy argument to the split-video command)
    • [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] (https://github.com/Breakthrough/PySceneDetect/pull/40))
    • [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] (https://github.com/Breakthrough/PySceneDetect/pull/26), 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
    Source code(tar.gz)
    Source code(zip)
  • v0.5-beta-1(Aug 7, 2018)

    Updated beta release, only bugfixes to API, several modifications/changes to CLI commands. Summary of major API changes:

    • Modify definition of end timecode returned by scenedetect.SceneManager.get_scene_list() method from N, where N is the last frame shown in the scene, to N+1. This now means that the end timecode/frame equals the start timecode/frame of the next adjacent scene. Also note that this is also the definition expected from the external tools used to export video when specifying the split-video command, improving compatibility with third-party tools.
    • If the frame_skip option is specified to be greater than 0 when using a scenedetect.SceneManager, it is now explicitly disallowed to use a scenedetect.StatsManager with the SceneManager. If quicker processing speed is required, users should set the downscale_factor via set_downscale_factor(downscale_factor=None). If no downscale_factor is passed (i.e. downscale_factor is None), the downscale factor will be computed automatically based on the resolution of the source material, which provides a balance of performance and accuracy for most videos.
    • Removed unnecessary new_time argument from FrameTimecode object, and modify second argument fps so it can also be a FrameTimecode object from which the framerate is copied, allowing creation of new timecodes from existing ones to follow a much more intuitive syntax.

    Summary of major CLI changes from v0.5-beta:

    • Fix erroneous output given by default split-video mode. The new default mode for split-video is what -p/--precise used to be, but somewhat faster, with an additional -h/--high-quality flag to increase output video quality at expense of time, thus the default mode for split-video is slower than it used to be, but significantly more accurate in terms of where output videos are split
    • The split-video flag -m/--mkvmerge has been changed to -c/--copy to better indicate what is happening, and requires mkvmerge, which produces output files significantly faster, but at the expense of frame-perfect accuracy when splitting.
    • Fix erroneous output given by split-video -c/--copy.
    • Changed split-video option -f/--ffmpeg-args to -a/--override-args to prevent conflicts with new options
    • Addsplit-video option -o/--output DIR to specify output directory as well as -f/--filename NAME to specify output filename, which allows the use of the macros $VIDEO_NAME and $SCENE_NUMBER in NAME

    Several updates to other commands as well; use the help command to list all available commands, and the help [command] command to view the options/flags for a particular command (or alternatively help all to show the entire PySceneDetect help/reference manual). Also fixed setup.py (thanks @ishandutta2007).

    Source code(tar.gz)
    Source code(zip)
  • v0.5-beta(Aug 1, 2018)

    Beta release of PySceneDetect v0.5 with significantly refactored API and CLI. Users are encouraged to upgrade to the v0.5-beta as soon as possible. The release of v0.5 will break existing scripts/programs; both the command-line interface and Python API have changed significantly to support future development.

    Try scenedetect help or scenedetect help all to get started. See the updated README.md for updated quickstart information.

    When the final version of v0.5 is released, beta users can upgrade seamlessly. The final release distribution of PySceneDetect v0.5 will be made available some time this month, including source/binary distributions.

    This is a source-only distribution, and can only be run locally via the scenedetect.py script. To install the beta, download v0.5-beta-1 or newer (via setup.py install - the version will show up as v0.5-dev). Requires ffmpeg or mkvmerge to enable support for the split-video command.

    Includes unit tests using pytest (to run, type pytest -v).

    Source code(tar.gz)
    Source code(zip)
  • v0.4(Jan 14, 2017)

    This latest release includes integrated video splitting via mkvmerge if installed on the system (included with Windows builds). Note, this update changes the behaviour of the -o / --output option. Overview of changes:

    • specifying -o OUTPUT_FILE.mkv will now automatically split the input video, generating a new video clip for each detected scene in sequence, starting with OUTPUT_FILE-001.mkv
    • CSV file output is now specified with the -co / --csv-output option (note, used to be -o in versions of PySceneDetect < 0.4)

    The specific components distributed with the Windows binaries are Python 3.4.4, OpenCV 3.1.0, Numpy 1.11.2, and mkvmerge 9.7.1.

    Source code(tar.gz)
    Source code(zip)
    PySceneDetect-0.4-win64-portable.zip(38.18 MB)
    PySceneDetect-0.4-win64.msi(39.82 MB)
  • v0.3.6(Jan 12, 2017)

    This release includes some performance improvements, internal application structure changes, and a new lightweight installer for Windows that doesn't require an existing Python environment (a portable version is also available). The recommended installation method for Linux and Mac users is to download the source distribution and run sudo setup.py install in the location of the extracted files (once you have installed the prerequisite OpenCV and Numpy packages for Python).

    • [enhance] speed improvement when using --frameskip option
    • [internal] moved application state and shared objects to a consistent interface (the SceneManager object) to greatly reduce the number of required arguments for certain API functions
    • [enhance] added installer for Windows builds (64-bit only currently)

    The specific components distributed with the Windows binaries are Python 3.4.4, OpenCV 3.1.0, and Numpy 1.11.2.

    Source code(tar.gz)
    Source code(zip)
    PySceneDetect-0.3.6-win64-portable.zip(34.69 MB)
    PySceneDetect-0.3.6-win64.msi(36.19 MB)
  • v0.3.5(Aug 3, 2016)

    This release includes some minor bug-fixes, as well as includes a portable build for 64-bit Windows users that don't want to install a Python environment (download PySceneDetect-XYZ-win64.zip and run scenedetect.exe from a command prompt; note you may need to add the folder to your %PATH% variable manually.).

    • [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
    • [internal] fix variable name typo in API documentation

    The specific components distributed with the Windows binaries are Python 3.4.4, OpenCV 3.1.0, and Numpy 1.11.2.

    Source code(tar.gz)
    Source code(zip)
    PySceneDetect-0.3.5-win64.zip(57.05 MB)
  • v0.3.4(Feb 9, 2016)

    This release improves the performance of content detection mode, adds a new command line option for selecting fade bias (threshold mode only), and includes various other improvements. List of changes included:

    • [enhance] added scene length, in seconds, to output file (-o) for easier integration with ffmpeg/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)
    Source code(tar.gz)
    Source code(zip)
  • v0.3.3(Jan 28, 2016)

    This release marks the first stable release, includes several bugfixes, and is now available on PyPI. Changes:

    • [bugfix] scenes are now written correctly 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 csv module
    Source code(tar.gz)
    Source code(zip)
  • v0.3.2-beta(Jan 26, 2016)

    This release adds image preview generation and duration (start/stop time) setting via four new command-line arguments (click here to view some examples):

    • [feature] added -si / --save-images flag 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 (-st and -et)
    • [feature] added command line option to specify maximum duration to process (-dt, overrides -et)
    Source code(tar.gz)
    Source code(zip)
  • v0.3.1-beta(Jan 23, 2016)

    New release with two new command line options - down sampling and frame skipping - both focused on performance/efficiency.

    • [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 install after downloading and extracting PySceneDetect)
    • [internal] additional API functions to remove requirement on passing OpenCV video objects, and allow just a file path instead
    Source code(tar.gz)
    Source code(zip)
  • v0.3-beta(Jan 8, 2016)

    The first major release of PySceneDetect, including all major features and functions. See the new USAGE.md file for helpful tips on how to use the new detection modes, and for optimal threshold values to try.

    Changes from CHANGELOG.md include:

    • 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
    Source code(tar.gz)
    Source code(zip)
  • v0.2.4-alpha(Dec 22, 2015)

    Bugfix with OpenCV version checking code - from the previous release, v0.2.3-alpha - for older versions of OpenCV (2.4 and older) on certain Linux distributions.

    Source code(tar.gz)
    Source code(zip)
  • v0.2.3-alpha(Aug 7, 2015)

    Bugfix so PySceneDetect works with the latest version of the OpenCV (3.0.0+) Python module while retaining compatibility with older versions. Note that although OpenCV is now at version 3, the Python module is still referenced as cv2.

    Source code(tar.gz)
    Source code(zip)
  • v0.2.2-alpha(Nov 26, 2014)

    Added statistics/analysis mode (-s) to generate a frame-by-frame analysis of a video (useful for finding appropriate values for scene detection parameters, and in preparation for content/adaptive detection methods), and bugfix for improper conversion of timecodes.

    Source code(tar.gz)
    Source code(zip)
  • v0.2.1-alpha(Nov 17, 2014)

    Added proper timecode formatting (in form HH:MM:SS.nnnnn), as well as generating a single comma-separated list in the output for easier importing into external tools (like mkvmerge).

    Source code(tar.gz)
    Source code(zip)
  • v0.2.0-alpha(Jun 10, 2014)

    PySceneDetect now shows a list of scenes in the terminal (you can specify a .CSV file to write to by specifying the -o / --output argument) by interpolating the timecodes/frame numbers between pairs of fades out and in.

    Source code(tar.gz)
    Source code(zip)
  • v0.1.0-alpha(Jun 6, 2014)

    Initial release of PySceneDetect. Includes threshold-based fade in/out detection for video files, currently displaying the result to the terminal.

    Source code(tar.gz)
    Source code(zip)
Owner
Brandon Castellano
Software engineer focused on embedded development, with background in computer vision. Currently at Google, working on Fuchsia.
Brandon Castellano
Cvplayer - A simple video player written in python using ffpyplayer and OpenCV

Video Player cvplayer is a minimal wrapper around the ffpyplayer.MediaPlayer cla

ADI 7 Dec 19, 2022
Cross-platform command-line AV1 / VP9 / HEVC / H264 encoding framework with per scene quality encoding

Av1an A cross-platform framework to streamline encoding Easy, Fast, Efficient and Feature Rich An easy way to start using AV1 / HEVC / H264 / VP9 / VP

Zen 947 Jan 1, 2023
This program is to make a video based on Deep Dream

This program is to make a video based on Deep Dream. The program is modified from DeepDreamAnim and DeepDreamVideo with additional functions for bleding two frames based on the optical flows. It also supports the image division to apply the Deep Dream algorithm to a large image.

Aertist 23 Jan 22, 2022
A python program which converts images and video into excel spreadsheets.

image2excel A program which converts images and video into Excel spreadsheets. Usage examples can be found in examples Videos can take a long time to

Oscar Peace 2 Aug 9, 2021
Python program - to extract slides from videos

Programa em Python - que fiz em algumas horas e que provavelmente tem bugs - para extrair slides de vídeos.

Natanael Antonioli 45 Nov 12, 2022
MPV remote controller is a program for remote controlling mpv player with device in your local network through web browser.

MPV remote controller is a program for remote controlling mpv player with device in your local network through web browser.

null 5 May 26, 2022
Program for converting video to GIF

video-to-gif Program for converting video to GIF Install the lib: pip install moviepy Usage: Specify the path to the video file. clip = VideoFileClip(

Artem Mokin 0 Dec 13, 2021
Program to play videos with props in Apex Legends

R5Fresh A video player for the Apex Legends mod R5Reloaded

null 9 Nov 13, 2022
Terminal-Video-Player - A program that can display video in the terminal using ascii characters

Terminal-Video-Player - A program that can display video in the terminal using ascii characters

null 15 Nov 10, 2022
MoviePy is a Python library for video editing, can read and write all the most common audio and video formats

MoviePy is a Python library for video editing: cutting, concatenations, title insertions, video compositing (a.k.a. non-linear editing), video processing, and creation of custom effects. See the gallery for some examples of use.

null 10k Jan 8, 2023
A Python library that simplifies working with video from soccer matches.

Match Video This is a Python library that simplifies working with video from soccer matches. It allows match video to be selected intuitively by perio

Grant Wenzinger 2 Jul 21, 2022
Python based script to operate FFMPEG.

FMPConvert Python based script to operate FFMPEG. Ver 1.0 -- 2022.02.08 Feature ✅ Maximum compatibility: Third-party dependency libraries unused ✅ Che

cybern000b 1 Feb 28, 2022
A GUI based datamoshing apllication for everyone! Apply this glitch to your videos and gifs. Supports all video formats!

A GUI based datamoshing apllication for everyone! Apply this glitch to your videos and gifs. Supports all video formats!

Akascape 131 Dec 31, 2022
A web RTSP play platform based on websocket and tornado, websocket use blob binaryType read as ArrayBuffer

A web RTSP play platform based on websocket and tornado, websocket use blob binaryType read as ArrayBuffer

null 2 Feb 25, 2022
An easy to use GUI based video to image sequence converter (and vice versa).

Vdo & Img Conversion Tools This is a quick conversion tool made with python that can save you a lot of time. With this tool you can extract image sequ

Akash Bora 3 Sep 18, 2022
TkVideoplayer - This is a simple library to play video files in tkinter.

TkVideoplayer - This is a simple library to play video files in tkinter.

Art/Paul 38 Dec 23, 2022
Repository to create Ascii art in CMD based on video file.

Made to take any file format, and transform it into ascii art, displayed as a video in the cmd. If the cmd formatting is wrong, try zooming a little and remember to make cmd fullscreen. I made my cmd fullscreen, and zoomed out one tic. Written in Python 3.9

null 60 Dec 17, 2022
Autocut the Twitch VODs based on Marker

Markut Given the VOD of the stream and the markers that are exported as a CSV file, generate a video using ffmpeg that cuts out part of the VOD accord

Tsoding 18 Dec 19, 2022
Techie Sneh 17 Nov 23, 2021