You've already forked lubo_toolkit
工作流,更新双GPU加速
This commit is contained in:
@ -1,10 +1,14 @@
|
||||
import datetime
|
||||
import os
|
||||
import argparse
|
||||
import subprocess
|
||||
from hashlib import md5
|
||||
from typing import Union
|
||||
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
from config import DANMAKU_FACTORY_EXEC, VIDEO_RESOLUTION, DANMAKU_SPEED, DEFAULT_FONT_NAME
|
||||
|
||||
|
||||
class NoDanmakuException(Exception):
|
||||
...
|
||||
@ -39,6 +43,19 @@ def diff_danmaku_files(base_file: Union[os.PathLike[str], str], file: Union[os.P
|
||||
return get_file_start(file) - get_file_start(base_file)
|
||||
|
||||
|
||||
def danmaku_to_subtitle(file: Union[os.PathLike[str], str], time_shift: float):
|
||||
new_subtitle_name = md5(file.encode("utf-8")).hexdigest() + ".ass"
|
||||
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)
|
||||
))
|
||||
process.wait()
|
||||
return new_subtitle_name
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("base", help="以此为标准")
|
||||
|
Reference in New Issue
Block a user