Coder Social home page Coder Social logo

aproinov / pyscenedetect Goto Github PK

View Code? Open in Web Editor NEW

This project forked from breakthrough/pyscenedetect

0.0 0.0 0.0 150.5 MB

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

Home Page: http://scenedetect.com

License: Other

Python 99.84% CSS 0.09% HTML 0.08%

pyscenedetect's Introduction

PySceneDetect

Video Scene Cut Detection and Analysis Tool

Build Status PyPI Status PyPI Version PyPI License


Latest Release: v0.6.2 (July 23, 2023)

Website: scenedetect.com

Quickstart Example: scenedetect.com/cli/

Documentation: scenedetect.com/docs/

Discord: https://discord.gg/H83HbJngk7


Quick Install:

pip install scenedetect[opencv] --upgrade

Requires ffmpeg/mkvmerge for video splitting support. Windows builds (MSI installer/portable ZIP) can be found on the download page.


Quick Start (Command Line):

Split input video on each fast cut using ffmpeg:

scenedetect -i video.mp4 split-video

Save some frames from each cut:

scenedetect -i video.mp4 save-images

Skip the first 10 seconds of the input video:

scenedetect -i video.mp4 time -s 10s

More examples can be found throughout the documentation.

Quick Start (Python API):

To get started, there is a high level function in the library that performs content-aware scene detection on a video (try it from a Python prompt):

from scenedetect import detect, ContentDetector
scene_list = detect('my_video.mp4', ContentDetector())

scene_list will now be a list containing the start/end times of all scenes found in the video. There also exists a two-pass version AdaptiveDetector which handles fast camera movement better, and ThresholdDetector for handling fade out/fade in events.

Try calling print(scene_list), or iterating over each scene:

from scenedetect import detect, ContentDetector
scene_list = detect('my_video.mp4', ContentDetector())
for i, scene in enumerate(scene_list):
    print('    Scene %2d: Start %s / Frame %d, End %s / Frame %d' % (
        i+1,
        scene[0].get_timecode(), scene[0].get_frames(),
        scene[1].get_timecode(), scene[1].get_frames(),))

We can also split the video into each scene if ffmpeg is installed (mkvmerge is also supported):

from scenedetect import detect, ContentDetector, split_video_ffmpeg
scene_list = detect('my_video.mp4', ContentDetector())
split_video_ffmpeg('my_video.mp4', scene_list)

For more advanced usage, the API is highly configurable, and can easily integrate with any pipeline. This includes using different detection algorithms, splitting the input video, and much more. The following example shows how to implement a function similar to the above, but using the scenedetect API:

from scenedetect import open_video, SceneManager, split_video_ffmpeg
from scenedetect.detectors import ContentDetector
from scenedetect.video_splitter import split_video_ffmpeg

def split_video_into_scenes(video_path, threshold=27.0):
    # Open our video, create a scene manager, and add a detector.
    video = open_video(video_path)
    scene_manager = SceneManager()
    scene_manager.add_detector(
        ContentDetector(threshold=threshold))
    scene_manager.detect_scenes(video, show_progress=True)
    scene_list = scene_manager.get_scene_list()
    split_video_ffmpeg(video_path, scene_list, show_progress=True)

See the documentation for more examples.

Reference

Help & Contributing

Please submit any bugs/issues or feature requests to the Issue Tracker. Before submission, ensure you search through existing issues (both open and closed) to avoid creating duplicate entries. Pull requests are welcome and encouraged. PySceneDetect is released under the BSD 3-Clause license, and submitted code should be compliant.

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.

Code Signing

This program uses free code signing provided by SignPath.io, and a free code signing certificate by the SignPath Foundation

License

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

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

pyscenedetect's People

Contributors

breakthrough avatar wjs018 avatar spanglelabs avatar tonycpsu avatar scarwire avatar nirabo avatar ivan23kor avatar jffaria avatar dadus33 avatar elcombato avatar obroomhall avatar petrpulc avatar soumitraagarwal avatar talkain avatar lvdingqin avatar e271828- avatar leingang avatar lgtm-com[bot] avatar nathanielcwm avatar mtillmann avatar markusbauer avatar stlalpha avatar filips-alpe avatar dlu avatar piercus avatar colelawrence avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.