换用danmu2ass

This commit is contained in:
2022-06-15 21:11:33 +08:00
parent 33f1afc976
commit 4c3d74fed8
3 changed files with 11 additions and 12 deletions

View File

@ -7,7 +7,7 @@ from typing import Union
from bs4 import BeautifulSoup
from config import DANMAKU_FACTORY_EXEC, VIDEO_RESOLUTION, DANMAKU_SPEED, DEFAULT_FONT_NAME
from config import DANMU_ASS_EXEC, VIDEO_RESOLUTION, DANMAKU_SPEED, DEFAULT_FONT_NAME
from exception.danmaku import NoDanmakuException, DanmakuFormatErrorException
from util.file import check_file_exist
@ -34,12 +34,11 @@ def diff_danmaku_files(base_file: Union[os.PathLike[str], str], file: Union[os.P
def danmaku_to_subtitle(file: Union[os.PathLike[str], str], time_shift: float):
new_subtitle_name = md5(file.encode("utf-8")).hexdigest() + ".ass"
(_w, _h) = VIDEO_RESOLUTION.split("x")
process = subprocess.Popen((
DANMAKU_FACTORY_EXEC, "--ignore-warnings",
"-r", str(VIDEO_RESOLUTION), "-s", str(DANMAKU_SPEED), "-f", "5",
"-S", "40", "-N", str(DEFAULT_FONT_NAME), "--showmsgbox", "FALSE",
"-O", "255", "-L", "1", "-D", "0",
"-o", "ass", new_subtitle_name, "-i", file, "-t", str(time_shift)
DANMU_ASS_EXEC, "--force", "-a", "0.9", "-d", str(DANMAKU_SPEED), "--font", str(DEFAULT_FONT_NAME),
"--font-size", "40", "--lane-size", "40", "--width", _w, "--height", _h, "-o", new_subtitle_name,
"-p", "1", "--time-offset", str(time_shift), "--width-ratio", "1", file
))
process.wait()
return new_subtitle_name