Skip to main content

Auto slice the highlight shorts based on the density of danmaku.

Project description

auto-slice-video

Auto slice the highlight shorts based on the density of danmaku.

English | 简体中文

Features

  • Detect the dense period of danmaku based on the sliding window algorithm.
  • Slice the video based on the density of danmaku.
  • Support GPU accelerated calculation.(Automatically choose whether to use GPU acceleration)
  • Support custom quantity slicing videos.
  • Support custom slice duration.
  • Add detailed log information.
  • Support cli usage and api usage.

Demo

Installation

To use this tool, you need to install ffmpeg first.

  • Windows: choco install ffmpeg (via Chocolatey) or other methods.
  • macOS: brew install ffmpeg (via Homebrew).
  • Linux: sudo apt install ffmpeg (Debian/Ubuntu).

More OS please refer to the official website.

Then install the autosv package.

pip install autosv

Usage

cli usage

# eg. The default parameters are shown in 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 usage

from autosv import slice_video_by_danmaku
# The default parameters are the same as the cli usage
slice_video_by_danmaku(ass_path, video_path, duration=300, top_n=3, max_overlap=60, step=1)

common issues

What is the difference between cpu and gpu implementation?

Generally speaking, the gpu implementation is faster and more efficient than the cpu implementation due to the parallel computing. In my practice, when the input data is around 30k(Try test/sample2.ass), the gpu implementation only takes 2 seconds, while the cpu implementation takes 33 seconds, which is 16.5 times faster with only 55 MB VRAM occupied.

Why I cannot use the gpu acceleration?

The autosv will detect whether the cuda is available on the machine via nvcc -V, if your machine has nvidia gpu, please make sure your driver is installed and the cuda is available. Meanwhile, make sure you have installed the numba and numpy with the right version.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

autosv-0.0.2.tar.gz (59.5 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

autosv-0.0.2-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file autosv-0.0.2.tar.gz.

File metadata

  • Download URL: autosv-0.0.2.tar.gz
  • Upload date:
  • Size: 59.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.16

File hashes

Hashes for autosv-0.0.2.tar.gz
Algorithm Hash digest
SHA256 d7438ccef7df7395bdd486fa8e7f1860e379ee74d74a382acc704dea1b30fa1b
MD5 c08e89f8c2ac7b97255eb762bfa8bb71
BLAKE2b-256 bd47fa32d5df45be08c68fe9f2fc7137721d5843778c182497c75f13ce3549e3

See more details on using hashes here.

File details

Details for the file autosv-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: autosv-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 10.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.16

File hashes

Hashes for autosv-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d2fb3e380ed3528fa1d959b9959be34d764dc91970d2c5cbc3611a036245543a
MD5 394f011db05f40e8eac39b0613e7db0a
BLAKE2b-256 bb480d82782d811a7773dfdf0ef4eedbc52c5d63f78954bb8c5084365d056f21

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page