Niconvert 是一个弹幕转 ass 字幕工具,以便在桌面播放器观看弹幕。
注: 仅弹幕转换,不带弹幕下载功能,获取B站弹幕方法。
效果预览
界面截图
支持如下特性:
- 转换 Bilibili 的 xml 格式文件
- 按位置或关键词过滤,更复杂的条件过滤可以使用脚本
- 碰撞算法布局,避免弹幕重叠
- 命令行和图形界面,可运行在 Linux、MacOS、Windows 上
- 常见的 ass 样式定制,字体、字号、速度、时间轴偏移等
MIT
弹幕转换工具
我已经利用 you-get 下载了 xml 文件,如何直接导入到该程序中?
使用新版的接口重新实现。
不太懂 python 只好来提交 issue 了
AcfunDownloader 类里面应改为 VIDEO_UID_RE = re.compile(r"\[video\](\d+)\[/video\]", re.I)
,否则一些视频会 indexError。
求修复。
作者你好,我想询问一下如何将该程序打包成exe可执行程序
我现在使用的 pyinstaller 在打包好之后执行程序会出现以下问题
无法正常使用
打包命令测试过以下这些
pyinstaller -D main.pyw
pyinstaller --hidden-import=queue -w -F main.py
这些
所以我现在想询问一下该如何打包
PS:我的Python基础很差,所以很多基础的东西我可能没有查询到
另附一份打包时的Log
64 INFO: PyInstaller: 4.2
65 INFO: Python: 3.9.2
66 INFO: Platform: Windows-10-10.0.18362-SP0
67 INFO: wrote C:\Users\chen\Downloads\niconvert-master\niconvert-master\main.spec
69 INFO: UPX is not available.
71 INFO: Extending PYTHONPATH with paths
['C:\\Users\\chen\\Downloads\\niconvert-master\\niconvert-master',
'C:\\Users\\chen\\Downloads\\niconvert-master\\niconvert-master']
95 INFO: checking Analysis
95 INFO: Building Analysis because Analysis-00.toc is non existent
97 INFO: Initializing module dependency graph...
99 INFO: Caching module graph hooks...
108 WARNING: Several hooks defined for module 'win32ctypes.core'. Please take care they do not conflict.
112 INFO: Analyzing base_library.zip ...
4008 INFO: Processing pre-find module path hook distutils from 'c:\\users\\chen\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks\\pre_find_module_path\\hook-distutils.py'.
4010 INFO: distutils: retargeting to non-venv dir 'c:\\users\\chen\\appdata\\local\\programs\\python\\python39\\lib'
7271 INFO: Caching module dependency graph...
7381 INFO: running Analysis Analysis-00.toc
7396 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
required by c:\users\chen\appdata\local\programs\python\python39\python.exe
7480 WARNING: lib not found: api-ms-win-core-path-l1-1-0.dll dependency of c:\users\chen\appdata\local\programs\python\python39\python39.dll
7499 INFO: Analyzing C:\Users\chen\Downloads\niconvert-master\niconvert-master\main.pyw
7820 INFO: Processing module hooks...
7821 INFO: Loading module hook 'hook-difflib.py' from 'c:\\users\\chen\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
7823 INFO: Excluding import of doctest from module difflib
7824 INFO: Loading module hook 'hook-distutils.py' from 'c:\\users\\chen\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
7830 INFO: Loading module hook 'hook-distutils.util.py' from 'c:\\users\\chen\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
7832 INFO: Excluding import of lib2to3.refactor from module distutils.util
7832 INFO: Loading module hook 'hook-encodings.py' from 'c:\\users\\chen\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
7918 INFO: Loading module hook 'hook-heapq.py' from 'c:\\users\\chen\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
7921 INFO: Excluding import of doctest from module heapq
7921 INFO: Loading module hook 'hook-lib2to3.py' from 'c:\\users\\chen\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
7962 INFO: Loading module hook 'hook-multiprocessing.util.py' from 'c:\\users\\chen\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
7963 INFO: Excluding import of test from module multiprocessing.util
7963 INFO: Excluding import of test.support from module multiprocessing.util
7965 INFO: Loading module hook 'hook-pickle.py' from 'c:\\users\\chen\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
7967 INFO: Excluding import of argparse from module pickle
7967 INFO: Loading module hook 'hook-sysconfig.py' from 'c:\\users\\chen\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
7968 INFO: Loading module hook 'hook-xml.etree.cElementTree.py' from 'c:\\users\\chen\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
7969 INFO: Loading module hook 'hook-xml.py' from 'c:\\users\\chen\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
8034 INFO: Loading module hook 'hook-_tkinter.py' from 'c:\\users\\chen\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
8194 INFO: checking Tree
8194 INFO: Building Tree because Tree-00.toc is non existent
8195 INFO: Building Tree Tree-00.toc
8261 INFO: checking Tree
8262 INFO: Building Tree because Tree-01.toc is non existent
8263 INFO: Building Tree Tree-01.toc
8342 INFO: checking Tree
8342 INFO: Building Tree because Tree-02.toc is non existent
8343 INFO: Building Tree Tree-02.toc
8370 INFO: Looking for ctypes DLLs
8407 INFO: Analyzing run-time hooks ...
8412 INFO: Including run-time hook 'c:\\users\\chen\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_multiprocessing.py'
8415 INFO: Including run-time hook 'c:\\users\\chen\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_win32api.py'
8419 INFO: Including run-time hook 'c:\\users\\chen\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth__tkinter.py'
8425 INFO: Looking for dynamic libraries
8837 INFO: Looking for eggs
8837 INFO: Using Python library c:\users\chen\appdata\local\programs\python\python39\python39.dll
8839 INFO: Found binding redirects:
[]
8844 INFO: Warnings written to C:\Users\chen\Downloads\niconvert-master\niconvert-master\build\main\warn-main.txt
8896 INFO: Graph cross-reference written to C:\Users\chen\Downloads\niconvert-master\niconvert-master\build\main\xref-main.html
8939 INFO: checking PYZ
8939 INFO: Building PYZ because PYZ-00.toc is non existent
8940 INFO: Building PYZ (ZlibArchive) C:\Users\chen\Downloads\niconvert-master\niconvert-master\build\main\PYZ-00.pyz
9646 INFO: Building PYZ (ZlibArchive) C:\Users\chen\Downloads\niconvert-master\niconvert-master\build\main\PYZ-00.pyz completed successfully.
9657 INFO: checking PKG
9657 INFO: Building PKG because PKG-00.toc is non existent
9658 INFO: Building PKG (CArchive) PKG-00.pkg
9675 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
9677 INFO: Bootloader c:\users\chen\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\bootloader\Windows-64bit\runw.exe
9677 INFO: checking EXE
9678 INFO: Building EXE because EXE-00.toc is non existent
9678 INFO: Building EXE from EXE-00.toc
9681 INFO: Copying icons from ['c:\\users\\chen\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\bootloader\\images\\icon-windowed.ico']
9682 INFO: Writing RT_GROUP_ICON 0 resource with 104 bytes
9683 INFO: Writing RT_ICON 1 resource with 3752 bytes
9683 INFO: Writing RT_ICON 2 resource with 2216 bytes
9683 INFO: Writing RT_ICON 3 resource with 1384 bytes
9684 INFO: Writing RT_ICON 4 resource with 38188 bytes
9684 INFO: Writing RT_ICON 5 resource with 9640 bytes
9684 INFO: Writing RT_ICON 6 resource with 4264 bytes
9684 INFO: Writing RT_ICON 7 resource with 1128 bytes
9688 INFO: Appending archive to EXE C:\Users\chen\Downloads\niconvert-master\niconvert-master\build\main\main.exe
9691 INFO: Building EXE from EXE-00.toc completed successfully.
9695 INFO: checking COLLECT
9695 INFO: Building COLLECT because COLLECT-00.toc is non existent
9697 INFO: Building COLLECT COLLECT-00.toc
10804 INFO: Building COLLECT COLLECT-00.toc completed successfully.
指定url,成功率不高
不如直接bili助手下载xml弹幕,但是又是UTF-8的,windows用还得转换成GB2312格式才不报错
gui界面不能保存配置,导致命令行效率高点,但又不支持通配符,还是Linux体验好
输出文件还要指定文件名,对一整个文件夹的xml批量转换很费力,本来直接改个后缀就好了
相比较另一个轮子,优势就是弹幕布局和安装方便了
我按照 文档-JSON 文件格式定义 的要求将弹幕文件保存为json格式后,发现所有弹幕都无法显示。打开转化后的.ass文件,发现弹幕大概全部跑屏幕外去了。如
PlayResX: 1080
PlayResY: 1920
...
Dialogue: -3,0:00:17.00,0:00:27.00,Danmaku,,0000,0000,0000,,{\move(2080, 497280, -160, 497280)}新年快乐
注意这个\move(2080, 497280, -160, 497280)
json:
[
{
"color": "ffffff",
"is_guest": false,
"start": 17,
"style": "scroll",
"content": "新年快乐",
"commenter": "ignore"
},
...
转换时没有使用多余的参数
python3 main.pyw -o some.ass some.cmt.xml
播放器是IINA
不知道这是正常现象还是选项没调对
希望能保存最后一次配置的参数
http://danmu.aixifan.com/V2/{}?pageSize=500&pageNo=1
Linux MPlayer:
现在我没有转换B站弹幕的必要了,所以基本上不维护了。
现在这个项目的唯一价值就是用 Python 的 GUI 库 tkinter 写了个较为复杂的界面,偶然写点小程序时用来参考参考。
把许可证换成 MIT,迟点就 archive 掉不管了。
用popsub打开会说字体格式不标准。播放器里都是一个一个圆点
如题,发现acfun不行啊,找不到弹幕
[2023-01-13 00:28:08] 开始转换 ...
Traceback (most recent call last):
File "D:\Aira2c\Download\niconvert-master\niconvert\fndtk\utils.py", line 23, in redirect_stdio
yield
File "D:\Aira2c\Download\niconvert-master\niconvert\fndtk\main.py", line 106, in on_convert_button_clicked
convert(*args_list)
File "D:\Aira2c\Download\niconvert-master\niconvert\fndcli\main.py", line 43, in convert
producer.start_handle()
File "D:\Aira2c\Download\niconvert-master\niconvert\libsite\producer.py", line 22, in start_handle
self.load_input_file()
File "D:\Aira2c\Download\niconvert-master\niconvert\libsite\producer.py", line 29, in load_input_file
self.all_danmakus = bilibili.loads(path)
File "D:\Aira2c\Download\niconvert-master\niconvert\libsite\bilibili.py", line 74, in loads
danmakus = list(map(Danmaku, comments))
File "D:\Aira2c\Download\niconvert-master\niconvert\libsite\bilibili.py", line 7, in __init__
self.raw = self._raw()
File "D:\Aira2c\Download\niconvert-master\niconvert\libsite\bilibili.py", line 18, in _raw
attr_string, content_string = reg.findall(self.text)[0]
IndexError: list index out of range
看了大大写的F&Q,得知要获取辅助地址可以使用 Niconvert Commnet Link脚本,但是脚本链接点开就找不到页面,不知是不是我的打开方式错误,请大大告知正确的使用方法,谢谢
niconvert.py中代码耦合十分严重= =
现在的转换过程的入口是WebSite类,但是Website的init中却又使用了(依赖于)子类的create_downloader()。
希望能把下载解析的过程和转换的过程,也就是 AB站的Downloader 和 AssSubtitle+NicoSubtitle分开,这样结构能够更清晰些。转换过程使用标准格式作为初始化参数,这样对于其他弹幕来源(比如内容为弹幕xml的字符串)也会有很好的支持。
在乐视上的弹幕,我是用控制台看到xml连接再复制出来的。要再改成辅助地址很麻烦啊
在potplayer和QQ影音中都是一个一个黑点。用popsub转换之后才能显示正确
http://www.bilibili.tv/sp/%E8%8B%8D%E8%93%9D%E9%92%A2%E9%93%81%E7%9A%84%E7%90%B6%E9%9F%B3
例如可以从浏览器里复制一季的地址,然后全部粘贴进去。
更高级的使用是可以定义文件名规则,让用户自己匹配下载的动画的文件名。
E:\program\niconvert-master>python3 niconvert.pyw http://www.acfun.tv/v/ac108003
0 -o 1.ass
--------
下载文件
--------
下载:http://www.acfun.tv/v/ac1080030_1
下载:http://www.acfun.tv/api/getVideoByID.aspx?vid=1092287
Traceback (most recent call last):
File "niconvert.pyw", line 19, in <module>
run_cli()
File "niconvert.pyw", line 8, in run_cli
main()
File "E:\program\niconvert-master\niconvert\fndcli\main.py", line 79, in main
convert(*parseargs())
File "E:\program\niconvert-master\niconvert\fndcli\main.py", line 38, in conve
rt
producer.start_download()
File "E:\program\niconvert-master\niconvert\libsite\producer.py", line 71, in
start_download
video = make_video(self.config, page)
File "E:\program\niconvert-master\niconvert\libsite\producer.py", line 32, in
make_video
return page.video_class(config, meta)
File "E:\program\niconvert-master\niconvert\libsite\acfun.py", line 81, in __i
nit__
self.cid = self._cid()
File "E:\program\niconvert-master\niconvert\libsite\acfun.py", line 112, in _c
id
raise Exception('无法获取 cid,请用辅助参数指定')
Exception: 无法获取 cid,请用辅助参数指定
niconvert-master\niconvert\libsite\bilibili.py", line 25, in _raw 'color': int(attrs[3]), ValueError: invalid literal for int() with base 10: 'undefined'
print(attrs)
['64.668', '1', '25', 'undefined', '1506859710', '1', '3ad3c7aa', '23835664667639810']
异步模式下有一定概率弹幕会重叠,有办法算出前一个弹幕和当前弹幕显示时长的差吗?
因为B站现在的弹幕是字数越长显示时间越短的,所以可能需要算出具体的显示时间差才能防止滚动弹幕重叠?
作者你好!
最近一直在用 Nicovert2.0 来转换 Bilibili 的弹幕,发现一个小问题:转换单个文件时,点击浏览按钮选择xml弹幕文件,会自动填充输出的ass文件路径。但我想转换多个文件时就发现自动填充输出文件路径的功能失效了。我查看了代码,发现是对输出文本框内的路径后缀检查的问题,于是修改了一下:
def on_input_filename_button_clicked(self):
strvar = self.input_filename_strvar
filetypes = [
('XML 文件', '*.xml'),
('JSON 文件', '*.json'),
]
tku.on_filedialog(self, strvar=strvar, method='load',
defaultextension='.xml',
filetypes=filetypes)()
# 自动设置输出文件名
input_filename = strvar.get().strip()
if input_filename == '':
return
''' 取消自动设置输出文件名时对原来文本框内路径的检测
output_filename = self.output_filename_strvar.get().strip()
if output_filename.endswith('.ass'):
return
'''
path = str(Path(input_filename).with_suffix('.ass'))
self.output_filename_strvar.set(path)
这样可能会方便一些。
再次感谢您的 Niconver !🤗
想上传本地做好的 ass 上去,但是 xml 格式才能好好的支持。
经测试,在打开没有某一类弹幕的json时(如没有
libass/display.py
class Display
中的弹幕类型,当danmaku.content内容为空时,程序报错。
在对相关区间做出如下修改后:
` def _max_length(self):
''' 最长的行字符数 '''
try:
assert hasattr(self.danmaku.content,'split')
return max(map(display_length, self.danmaku.content.split('\n')))
except AssertionError:
return 256
def _width(self):
''' 整条字幕宽度 '''
char_count = self.max_length / 2
return intceil(self.font_size * char_count)
def _height(self):
''' 整条字幕高度 '''
try:
assert hasattr(self.danmaku.content,'split')
line_count = len(self.danmaku.content.split('\n'))
return line_count * self.font_size
except AssertionError:
return self.font_size`
该文件不再报错。随后在
libass/util.py中correct_typos报错
在此处将程序修改为
def correct_typos(text):
''' 修正一些评论者的拼写错误 '''
try:
assert hasattr(text,'replace')
text = text.replace('/n', '\\N')
text = text.replace('>', '>')
text = text.replace('<', '<')
except AssertionError:
text = " "#Use a space as a dummy text to avoid further Nonetype Errors.
return text
程序不再报错,正常生成ass文件。
如题,文件太多,是否可以增加一个批量转换功能呢
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.