1 Star 0 Fork 0

zyncgit/PySceneDetect

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
BSD-3-Clause

PySceneDetect

Video Scene Cut Detection and Analysis Tool

Build Status PyPI Status PyPI Version PyPI License


Latest Release: v0.6.3 (March 9, 2024)

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-2024 Brandon Castellano. All rights reserved.

By downloading, copying, installing, or using this software, you agree to the terms of this license, and those contained in the "Ancillary Software Licenses" section below. If you do not agree to any of these terms or licenses, do not download, install, copy, or use the software or any other material included in in distribution. ----------------------------------------------------------------------- PySceneDetect License (BSD 3-Clause) < http://www.bcastell.com/projects/PySceneDetect > Copyright (C) 2014-2024, Brandon Castellano. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ----------------------------------------------------------------------- Ancillary Software Licenses This software uses the following third-party open source libraries and are released under the terms detailed below. By downloading, copying, installing or using this software/tutorial, you agree to these terms. ----------------------------------------------------------------------- > click [Copyright (C) 2017, Armin Ronacher]: This software uses OpenCV; see thirdparty/LICENSE-CLICK or visit: [ http://click.pocoo.org/license/ ] > NumPy [Copyright (C) 2005-2016, Numpy Developers]: This software uses Numpy; see thirdparty/LICENSE-NUMPY or visit: [ http://www.numpy.org/license.html ] > OpenCV [Copyright (C) 2017, Itseez]: This software uses OpenCV; see thirdparty/LICENSE-OPENCV or visit: [ http://opencv.org/license.html ] > PyAV [Copyright (C) 2017, Mike Boers and others]: This software uses PyAV; see thirdparty/LICENSE-PYAV or visit: [ https://github.com/PyAV-Org/PyAV/blob/main/LICENSE.txt ] > pytest [Copyright (C) 2004-2017, Holger Krekel and others]: This software uses pytest; see thirdparty/LICENSE-PYTEST or visit: [ https://docs.pytest.org/en/latest/license.html ] > simpletable [Copyright (C) 2014-2019, Matheus Vieira Portela and others]: This software uses simpletable; see thirdparty/LICENSE-SIMPLETABLE or visit: [ https://github.com/matheusportela/simpletable/blob/master/LICENSE ] > tqdm [Copyright (C) 2013-2018, Casper da Costa-Luis, Google Inc., and Noam Yorav-Raphael]: This software uses tqdm; see thirdparty/LICENSE-TQDM or visit: [ https://github.com/tqdm/tqdm/blob/master/LICENCE ] ----------------------------------------------------------------------- This software may also invoke FFmpeg or mkvmerge, if available. If required, these programs can be obtained from following URLs: FFmpeg: [ https://ffmpeg.org/download.html ] mkvmerge: [ https://mkvtoolnix.download/downloads.html ] Once installed, ensure the program is in your PATH variable (i.e. you can run the `ffmpeg` or `mkvmerge` command from any location). Certain distributions of PySceneDetect may include ffmpeg. See thirdparty/LICENSE-FFMPEG file or visit [ https://ffmpeg.org ] FFmpeg is a trademark of Fabrice Bellard mkvmerge is Copyright (C) 2005-2016, Matroska Windows distributions may include a compiled Python distribution. For license information regarding the distributed version of Python, see the thirdparty/LICENSE-PYTHON file, or visit [ https://docs.python.org/3/license.html ]

简介

Ai分镜头 展开 收起
Python 等 3 种语言
BSD-3-Clause
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/zyncgit/PySceneDetect.git
git@gitee.com:zyncgit/PySceneDetect.git
zyncgit
PySceneDetect
PySceneDetect
develop

搜索帮助