支持透明度调整

This commit is contained in:
2023-04-30 08:35:57 +08:00
parent 0e8cbba577
commit 1b7628936f
4 changed files with 16 additions and 4 deletions

View File

@ -8,6 +8,7 @@ from typing import Union
from bs4 import BeautifulSoup
from config import DANMAKU_EXEC, VIDEO_RESOLUTION, DANMAKU_SPEED, DANMAKU_FONT_NAME, DANMAKU_FONT_SIZE, \
DANMAKU_OPACITY, \
DANMAKU_USE_DANMU2ASS, DANMAKU_USE_DANMAKUFACTORY
from exception.danmaku import NoDanmakuException, DanmakuFormatErrorException
from util.file import check_file_exist
@ -50,7 +51,7 @@ def danmaku_to_subtitle_use_danmaku_factory(file: Union[os.PathLike[str], str],
DANMAKU_EXEC, "--ignore-warnings",
"-r", str(VIDEO_RESOLUTION), "-s", str(DANMAKU_SPEED), "-f", "5",
"-S", str(DANMAKU_FONT_SIZE), "-N", str(DANMAKU_FONT_NAME), "--showmsgbox", "FALSE",
"-O", "255", "-L", "1", "-D", "0",
"-O", "{:.0f}".format(DANMAKU_OPACITY*255/100), "-L", "1", "-D", "0",
"-o", "ass", new_subtitle_name, "-i", file, "-t", str(time_shift)
))
@ -58,7 +59,7 @@ def danmaku_to_subtitle_use_danmaku_factory(file: Union[os.PathLike[str], str],
def danmaku_to_subtitle_use_danmu2ass(file: Union[os.PathLike[str], str], time_shift: float, new_subtitle_name: str):
(_w, _h) = VIDEO_RESOLUTION.split("x")
return subprocess.Popen((
DANMAKU_EXEC, "--force", "-a", "1", "-d", str(DANMAKU_SPEED), "--font", str(DANMAKU_FONT_NAME),
DANMAKU_EXEC, "--force", "-a", "{:.1f}".format(DANMAKU_OPACITY/100.0), "-d", str(DANMAKU_SPEED), "--font", str(DANMAKU_FONT_NAME),
"--font-size", str(DANMAKU_FONT_SIZE), "--lane-size", str(DANMAKU_FONT_SIZE), "--width", _w, "--height", _h,
"-o", new_subtitle_name, "-p", "1", "--time-offset", str(time_shift), "--width-ratio", "1", file
))