gwy15 / danmu2ass Goto Github PK
View Code? Open in Web Editor NEW将哔哩哔哩的 弹幕 转化为 ass 字幕文件,实时预览
License: MIT License
将哔哩哔哩的 弹幕 转化为 ass 字幕文件,实时预览
License: MIT License
建议-o
选项支持-
参数,以-
为参数时(danmu2ass -o - foo.xml
)将生成的 ass 内容输出到标准输出。
如果一条弹幕中间部分带有回车符,在转换成ass文件后,导致回车符后面的字符另起一行,从而导致这部分内容不会被当成字幕内容。
例如,原始的xml数据为:
<d p="1.085,1,25,5566168,1649656743447,0,xxxx,0" user="xxxx">呵
呵
比
你
们
更
喜
欢
晚
晚</d>
转换后对应的ass内容为:
Dialogue: 2,0:00:01.08,0:00:16.09,Float,,0,0,0,,{\move(1280, 224, -660, 224)\c&Hd8ee54&}呵
呵
比
你
们
更
喜
欢
晚
晚
这样的字幕内容会导致最终的渲染只有内容 呵
,而 呵比你们更喜欢晚晚
因为格式问题被当作错误数据而不被渲染。
在ass格式中,如果要实现换行效果需要显式地使用\N
来代替不可见的回车符(参见:aegisub手册)。
也就是说,如果要正确显示上面提到的内容,对应的ass内容应该为:
Dialogue: 2,0:00:01.08,0:00:16.09,Float,,0,0,0,,{\move(1280, 224, -660, 224)\c&Hd8ee54&}呵\N呵\N比\N你\N们\N更\N喜\N欢\N晚\N晚
所以在生成ass文件时需要进行一次字符替换,将\n
替换为\N
。
使用最新的 Windows release, 指定输出文件名无效,输出被存在当前工作目录。同时这也会导致因为某些默认名称含有非法字符而保存失败。例如
.\danmu2ass.exe -o "C:\Users\<Username>\AppData\Local\Temp\PotPlayer\945572024-1-30102.ass" "https://www.bilibili.com/video/BV1xD4y157D4?spm_id_from=..0.0"
中默认文件名包括 |
.
正常的抓到的弹幕是这个形式:
<d p="2814.009,1,25,65532,1701171728450,0,22146432,0" user="潘柒颂PanChihSong">对三,要不起</d>
但是最近录到的弹幕里偶尔会出现这种弹幕,我怀疑是b站新出的弹幕复读功能:
<d p="2814.062,7,100,16777215,1701171730079,0,0,0" user="***">[1.0,0.0,"0.8-0.5",10.0,"对三,要不起",0.0,0.0,0.0,0.0,10000,0,true,"黑体",1]</d>
如果存在这种弹幕,他后面的所有弹幕都不能转化成ass文件,我尝试阅读了这个软件的源代码但是没读懂,所以请问这个问题该如何解决呢?
如果我通过加denylist的方式解决,我在denylist里加一个[
能把这些弹幕排除掉吗?谢谢!
请问可以支持一下直接通过cid获取弹幕文件
输入的命令:
D:\Peter\Downloads\danmu2ass>danmu2ass.exe -a 0.78 -d 8 -w 1920 -h 1080 -p 1.0 --time-offset 1.3 "[整合全弹幕]【中字】Tiny Stars-涩谷香音&唐可可《LoveLive!Superstar!》.xml"
成功输出了.ass,但我的.xml有830KB输出的.ass却只有13KB
而且显示区域也不是满屏幕
输入的命令:
D:\Peter\Downloads\danmu2ass>danmu2ass.exe -a 0.78 -d 8 -w 1920 -h 1080 -p 1.0 --time-offset 1.3 --force "[整合全弹幕]【中字】Tiny Stars-涩谷香音&唐可可《LoveLive!Superstar!》.xml"
返回的结果:
2022-08-17T15:35:51.353Z INFO danmu2ass::cli > 转换 [整合全弹幕]【中字】Tiny Stars-涩谷香音&唐可可《LoveLive!Superstar!》.xml => [整合全弹幕]【中字】Tiny Stars-涩谷香音&唐可可《LoveLive!Superstar!》.ass
Error: p 属性解析错误
Caused by:
未知的弹幕类型:7
请问,该仓库使用什么 LICENSE 授权?该 repo 中不存在 LICENSE 文件,源代码文件也没有 LICENSE header。
不加 --release
时测试通过。
$ cargo test --release
Compiling danmu2ass v0.2.2
Finished release [optimized] target(s) in 1.17s
Running unittests src/lib.rs (target/release/deps/danmu2ass-2c26aa49fb432fe9)
running 7 tests
test ass_writer::tests::test_escape_text ... ok
test ass_writer::tests::time_point_fmt ... ok
test input_type::tests::parse_bv ... ok
test xml_parser::tests::from_xml ... ok
test input_type::tests::parse_season_or_episode ... ok
test xml_parser::tests::parse_break_line ... FAILED
test xml_parser::tests::iterator ... FAILED
failures:
---- xml_parser::tests::parse_break_line stdout ----
thread 'xml_parser::tests::parse_break_line' panicked at 'assertion failed: `(left == right)`
left: `"呵\n呵\n比\n你\n们\n更\n喜\n欢\n晚\n晚"`,
right: `"0-呵\n呵\n比\n你\n们\n更\n喜\n欢\n晚\n晚"`', src/xml_parser.rs:357:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
---- xml_parser::tests::iterator stdout ----
thread 'xml_parser::tests::iterator' panicked at 'assertion failed: `(left == right)`
left: `Danmu { timeline_s: 0.581, content: "快快快", type: Float, fontsize: 25, rgb: (227, 63, 255) }`,
right: `Danmu { timeline_s: 0.581, content: "0-快快快", type: Float, fontsize: 25, rgb: (227, 63, 255) }`', src/xml_parser.rs:325:9
failures:
xml_parser::tests::iterator
xml_parser::tests::parse_break_line
test result: FAILED. 5 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
error: test failed, to rerun pass `--lib`
https://github.com/jnxyp/Bilibili-Block-List
希望可以使用这样xml文件屏蔽弹幕
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.