You've already forked lubo_toolkit
							
							工作流,去除cmd弹框
This commit is contained in:
		@@ -4,16 +4,17 @@ import platform
 | 
				
			|||||||
import subprocess
 | 
					import subprocess
 | 
				
			||||||
import sys
 | 
					import sys
 | 
				
			||||||
import threading
 | 
					import threading
 | 
				
			||||||
 | 
					from hashlib import md5
 | 
				
			||||||
from typing import Optional, IO, Union
 | 
					from typing import Optional, IO, Union
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from datetime import datetime, timedelta
 | 
					from datetime import datetime, timedelta
 | 
				
			||||||
from PyQt5 import QtGui
 | 
					from PyQt5 import QtGui
 | 
				
			||||||
from PyQt5.QtCore import Qt, QThread, pyqtSignal
 | 
					from PyQt5.QtCore import Qt, QThread, pyqtSignal
 | 
				
			||||||
from PyQt5.QtWidgets import QWidget, QLabel, QApplication, QFrame, QVBoxLayout, QPushButton, \
 | 
					from PyQt5.QtWidgets import QWidget, QLabel, QApplication, QFrame, QVBoxLayout, QPushButton, \
 | 
				
			||||||
    QSizePolicy, QMessageBox, QProgressBar
 | 
					    QSizePolicy, QMessageBox
 | 
				
			||||||
from danmaku_xml_helper import get_file_start, diff_danmaku_files, danmaku_to_subtitle
 | 
					from danmaku_xml_helper import get_file_start, diff_danmaku_files
 | 
				
			||||||
from config import load_config, FFMPEG_EXEC, DANMAKU_FACTORY_EXEC, FFMPEG_USE_INTEL_GPU, FFMPEG_USE_NVIDIA_GPU, \
 | 
					from config import load_config, FFMPEG_EXEC, DANMAKU_FACTORY_EXEC, FFMPEG_USE_INTEL_GPU, FFMPEG_USE_NVIDIA_GPU, \
 | 
				
			||||||
    VIDEO_BITRATE, VIDEO_CLIP_EACH_SEC, VIDEO_CLIP_OVERFLOW_SEC
 | 
					    VIDEO_BITRATE, VIDEO_CLIP_EACH_SEC, VIDEO_CLIP_OVERFLOW_SEC, VIDEO_RESOLUTION, DANMAKU_SPEED, DEFAULT_FONT_NAME
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class Job:
 | 
					class Job:
 | 
				
			||||||
@@ -329,7 +330,7 @@ class WorkerThread(QThread):
 | 
				
			|||||||
                "-qmin", "10", "-qmax", "32", "-crf", "16",
 | 
					                "-qmin", "10", "-qmax", "32", "-crf", "16",
 | 
				
			||||||
                # "-t", "10",
 | 
					                # "-t", "10",
 | 
				
			||||||
                new_filename
 | 
					                new_filename
 | 
				
			||||||
            ], stdout=subprocess.PIPE)
 | 
					            ], **subprocess_args(True))
 | 
				
			||||||
        elif FFMPEG_USE_INTEL_GPU:
 | 
					        elif FFMPEG_USE_INTEL_GPU:
 | 
				
			||||||
            if platform.system().lower() == "windows":
 | 
					            if platform.system().lower() == "windows":
 | 
				
			||||||
                print("[+]Use Intel QSV Acceleration")
 | 
					                print("[+]Use Intel QSV Acceleration")
 | 
				
			||||||
@@ -343,7 +344,7 @@ class WorkerThread(QThread):
 | 
				
			|||||||
                    "-qmin", "10", "-qmax", "32", "-crf", "16",
 | 
					                    "-qmin", "10", "-qmax", "32", "-crf", "16",
 | 
				
			||||||
                    # "-t", "10",
 | 
					                    # "-t", "10",
 | 
				
			||||||
                    new_filename
 | 
					                    new_filename
 | 
				
			||||||
                ], stdout=subprocess.PIPE)
 | 
					                ], **subprocess_args(True))
 | 
				
			||||||
            else:
 | 
					            else:
 | 
				
			||||||
                print("[+]Use Intel VAAPI Acceleration")
 | 
					                print("[+]Use Intel VAAPI Acceleration")
 | 
				
			||||||
                encode_process = subprocess.Popen([
 | 
					                encode_process = subprocess.Popen([
 | 
				
			||||||
@@ -356,7 +357,7 @@ class WorkerThread(QThread):
 | 
				
			|||||||
                    "-qmin", "10", "-qmax", "32", "-crf", "16",
 | 
					                    "-qmin", "10", "-qmax", "32", "-crf", "16",
 | 
				
			||||||
                    # "-t", "10",
 | 
					                    # "-t", "10",
 | 
				
			||||||
                    new_filename
 | 
					                    new_filename
 | 
				
			||||||
                ], stdout=subprocess.PIPE)
 | 
					                ], **subprocess_args(True))
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            print("[+]Use CPU Encode")
 | 
					            print("[+]Use CPU Encode")
 | 
				
			||||||
            encode_process = subprocess.Popen([
 | 
					            encode_process = subprocess.Popen([
 | 
				
			||||||
@@ -369,7 +370,7 @@ class WorkerThread(QThread):
 | 
				
			|||||||
                "-qmin", "10", "-qmax", "32", "-crf", "16",
 | 
					                "-qmin", "10", "-qmax", "32", "-crf", "16",
 | 
				
			||||||
                # "-t", "10",
 | 
					                # "-t", "10",
 | 
				
			||||||
                new_filename
 | 
					                new_filename
 | 
				
			||||||
            ], stdout=subprocess.PIPE)
 | 
					            ], **subprocess_args(True))
 | 
				
			||||||
        self.handle_ffmpeg_output(encode_process.stdout)
 | 
					        self.handle_ffmpeg_output(encode_process.stdout)
 | 
				
			||||||
        return encode_process.wait()
 | 
					        return encode_process.wait()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -533,6 +534,18 @@ def base_ts_to_filename(start_ts: float, is_mp4=False) -> str:
 | 
				
			|||||||
        return base_start.strftime("%Y%m%d_%H%M.flv")
 | 
					        return base_start.strftime("%Y%m%d_%H%M.flv")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					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)
 | 
				
			||||||
 | 
					    ), **subprocess_args(True))
 | 
				
			||||||
 | 
					    process.wait()
 | 
				
			||||||
 | 
					    return new_subtitle_name
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Create a set of arguments which make a ``subprocess.Popen`` (and
 | 
					# Create a set of arguments which make a ``subprocess.Popen`` (and
 | 
				
			||||||
# variants) call work with or without Pyinstaller, ``--noconsole`` or
 | 
					# variants) call work with or without Pyinstaller, ``--noconsole`` or
 | 
				
			||||||
# not, on Windows and Linux. Typical use::
 | 
					# not, on Windows and Linux. Typical use::
 | 
				
			||||||
@@ -588,7 +601,7 @@ def check_exec(name: Union[os.PathLike[str], str]) -> bool:
 | 
				
			|||||||
    if is_windows():
 | 
					    if is_windows():
 | 
				
			||||||
        check_process = subprocess.Popen([
 | 
					        check_process = subprocess.Popen([
 | 
				
			||||||
            "where.exe", name
 | 
					            "where.exe", name
 | 
				
			||||||
        ], stdout=subprocess.PIPE)
 | 
					        ], **subprocess_args(True))
 | 
				
			||||||
        check_process.wait()
 | 
					        check_process.wait()
 | 
				
			||||||
        return len(check_process.stdout.readlines()) > 0
 | 
					        return len(check_process.stdout.readlines()) > 0
 | 
				
			||||||
    elif is_linux():
 | 
					    elif is_linux():
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,8 +1,6 @@
 | 
				
			|||||||
import datetime
 | 
					import datetime
 | 
				
			||||||
import os
 | 
					import os
 | 
				
			||||||
import argparse
 | 
					import argparse
 | 
				
			||||||
import subprocess
 | 
					 | 
				
			||||||
from hashlib import md5
 | 
					 | 
				
			||||||
from typing import Union
 | 
					from typing import Union
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from bs4 import BeautifulSoup
 | 
					from bs4 import BeautifulSoup
 | 
				
			||||||
@@ -43,19 +41,6 @@ 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)
 | 
					    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__':
 | 
					if __name__ == '__main__':
 | 
				
			||||||
    parser = argparse.ArgumentParser()
 | 
					    parser = argparse.ArgumentParser()
 | 
				
			||||||
    parser.add_argument("base", help="以此为标准")
 | 
					    parser.add_argument("base", help="以此为标准")
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user