Skip to main content

Bilibili Live Danmaku Tools 哔哩哔哩直播弹幕处理工具

本工具可用于处理 B站录播姬 产生的弹幕 XML。具体功能有:

  1. 分切 弹幕 XML
  2. 合并 弹幕 XML
  3. 分析 弹幕 XML 中的弹幕数量以及礼物价格
  4. 分析 弹幕 XML 中的高能点(主要用于生成录播)

安装

pip3 install danmaku_tools

典型使用例子

合并

根据 flv 文件的长度合并 XML

python3 -m danmaku_tools.merge_danmaku video_1.xml video_2.xml video_3.xml --video_time ".flv" --output video_combined.xml

经常和类似这样的视频合并命令同时使用

echo "file video_1.flv\n file video_2.flv" > video_input.txt
ffmpeg -f concat -safe 0 -i video_input.txt -c copy video_combined.flv

根据 XML 开始时间合并 XML

python3 -m danmaku_tools.merge_danmaku video_1.xml video_2.xml video_3.xml --output video_combined.xml

剪切

从 123.45 秒开始剪切 XML

python3 -m danmaku_tools.cut_danmaku --start_time 123.45 video_input.xml --output video_output.xml

从 123.45 秒到 567.89 开始剪切 XML

python3 -m danmaku_tools.cut_danmaku --start_time 123.45 --end_time 567.89 video_input.xml --output video_output.xml

经常和类似这样的视频剪切命令同时使用

ffmpeg -ss 123.45 -to 567.89 -i video_input.flv video_output.flv

分析流水

python3 -m danmaku_tools.analyze_danmaku video.xml

输出如下:

弹幕:46541条
醒目留言:15294.0元
礼物:7366.440000000309元
大航海:10116.0元
大航海类别:{'舰长': 41, '提督': 1}
总流水 32776.44000000031元

分析高能

python3 -m danmaku_tools.danmaku_energy_map video.xml `# 输入 XML 文件` \
  --graph video.he.png `# 高能进度条 png` \
  --he_map he_list.txt `# 高能列表` \
  --sc_list sc_list.txt `# 醒目留言列表` \
  --sc_srt sc.srt `# 醒目留言字幕` \
  --he_time he_time.txt `# 最高能时间点` \
  --he_range he_range.txt `# 最高能时间段`

Metadata

Release files for danmaku-tools 0.0.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for danmaku-tools 0.0.9
File Size Uploaded
danmaku-tools-0.0.9.tar.gz 25.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for danmaku-tools 0.0.9
File Interpreter ABI Platform
danmaku_tools-0.0.9-py3-none-any.whl Python 3 none any Details

Total release size: 52.5 kB

Release files / danmaku-tools-0.0.9.tar.gz

Download URL danmaku-tools-0.0.9.tar.gz
Size 25.5 kB
Tags Source
SHA-256 checksum
How to use checksums
2cdcbdae817ec5220673d1f079dd029c4c8422aad781f06981ba3ee6b04c6302
BLAKE2b-256 checksum
How to use checksums
febd06e7801d40bea37341e31e567927d4500c1a87401155ff5cf7fd1bc31278
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.9.13

Release files / danmaku_tools-0.0.9-py3-none-any.whl

Download URL danmaku_tools-0.0.9-py3-none-any.whl
Size 27.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
866fa5cbd016ff7dc10caa6c06591165082a8dba9c0e91700960a01505f0a541
BLAKE2b-256 checksum
How to use checksums
6ebce2fb5b7b20c5fac3cfd199cdf8eaa4b80c2959f974dd6c12bdc79f6eb96d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.9.13

Release history Release notifications | RSS feed

This release

0.0.9 This release

2 release files

0.0.8

1 release file

0.0.7

1 release file

0.0.6

1 release file

0.0.5

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page