pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/timerring/auto-slice-video

media="all" rel="stylesheet" href="https://github.githubassets.com/assets/primer-71a44d5be3f782c5.css" /> GitHub - timerring/auto-slice-video: 基于弹幕密度的高能片段自动切片工具 (Auto slice the highlight shorts based on the density of danmaku.)
Skip to content

基于弹幕密度的高能片段自动切片工具 (Auto slice the highlight shorts based on the density of danmaku.)

License

Notifications You must be signed in to change notification settings

timerring/auto-slice-video

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

auto-slice-video

基于弹幕密度的高能片段自动切片机

English | 简体中文

简介

如果您觉得项目不错,欢迎 ⭐ 也欢迎 PR 合作,如果有任何疑问,欢迎提 issue 交流。

可自定义切片数量和时长的视频自动切片工具,支持 GPU 加速计算,支持命令行使用和 API 使用。

功能

  • 基于滑动窗口算法检测弹幕密集的时间段
  • 根据弹幕密度自动切片视频
  • 支持 Nvidia GPU 加速计算(自动选择是否使用GPU加速
  • 支持自定义数量的视频切片
  • 支持自定义切片时长
  • 添加详细的日志信息
  • 支持命令行使用和API使用

效果展示

如上,对一段视频提取 3 条高能片段,每个片段 300 秒,允许最大重叠 60 秒。然后计算并且切分出了 3 条高能片段。形式为 xxxs_原始视频名称xxx 代表该切片在原始视频中的起始时间(秒),方便用户定位。

安装

使用此工具前,您需要先安装ffmpeg:

  • Windows: choco install ffmpeg(通过Chocolatey)或其他方法
  • macOS: brew install ffmpeg(通过Homebrew
  • Linux: sudo apt install ffmpeg(Debian/Ubuntu)

更多操作系统安装 ffmpeg 请参考官方网站

然后安装 autosv:

pip install autosv

使用方法

命令行使用

# eg. 默认参数见 autosv -h
autosv -a sample.ass -v sample.mp4
autosv -a sample.ass -v sample.mp4 -d 300 -n 3 --overlap 60 --step 1
autosv -h
# optional arguments:
#   -h, --help            show this help message and exit
#   -V, --version         Print version information
#   -a ASS, --ass ASS     The input ass file of the danmaku
#   -v VIDEO, --video VIDEO
#                         The input video file
#   -d DURATION, --duration DURATION
#                         The duration(seconds) of the sliced highlight video, default is 60
#   -n TOP_N, --top_n TOP_N
#                         The number of the top dense periods to return, default is 1
#   --overlap OVERLAP     The overlapped(seconds) between the sliced highlight videos, default is 30
#   --step STEP           The step(seconds) of the sliding window, default is 1

API使用

from autosv import slice_video_by_danmaku
# 基本参数同上
slice_video_by_danmaku(ass_path, video_path, duration=300, top_n=3, max_overlap=60, step=1)

常见问题

GPU 和 CPU 实现有什么区别?

一般来说,当输入计算数据较大时,由于 GPU 是并行计算,因此GPU 计算比 CPU 计算更快且更高效。在我的实测中,当输入数据规模达到3万多条时 (见test/sample2.ass),GPU 计算仅用 2 秒,而 CPU 计算用 33 秒,GPU 实现速度是 CPU 实现的 16.5 倍,并且仅占用 55 MB 的显存。

为什么我不能使用 GPU 加速?

autosv 会通过 nvcc -V 检测机器上是否可用cuda,如果您的机器有NVIDIA GPU,请确保您的驱动已安装且cuda可用。同时,确保您已安装正确版本的numbanumpy

About

基于弹幕密度的高能片段自动切片工具 (Auto slice the highlight shorts based on the density of danmaku.)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy