This commit is contained in:
Jerry Yan 2022-04-22 09:45:38 +08:00
parent 102c174f34
commit d312878796

View File

@ -17,6 +17,7 @@ def get_video_real_duration(filename):
def encode_video_with_subtitles(orig_filename: str, subtitles: list[str], new_filename: str): def encode_video_with_subtitles(orig_filename: str, subtitles: list[str], new_filename: str):
if FFMPEG_USE_GPU: if FFMPEG_USE_GPU:
if FFMPEG_USE_INTEL_GPU: if FFMPEG_USE_INTEL_GPU:
print("[+]Use Intel VAAPI Acceleration")
encode_process = subprocess.Popen([ encode_process = subprocess.Popen([
FFMPEG_EXEC, "-hide_banner", "-progress", "-", "-v", "0", "-y", FFMPEG_EXEC, "-hide_banner", "-progress", "-", "-v", "0", "-y",
"-hwaccel", "vaapi", "-i", orig_filename, "-vf", "-hwaccel", "vaapi", "-i", orig_filename, "-vf",
@ -29,6 +30,7 @@ def encode_video_with_subtitles(orig_filename: str, subtitles: list[str], new_fi
new_filename new_filename
], stdout=subprocess.PIPE) ], stdout=subprocess.PIPE)
else: else:
print("[+]Use Nvidia NvEnc Acceleration")
encode_process = subprocess.Popen([ encode_process = subprocess.Popen([
FFMPEG_EXEC, "-hide_banner", "-progress", "-", "-v", "0", "-y", FFMPEG_EXEC, "-hide_banner", "-progress", "-", "-v", "0", "-y",
"-hwaccel", "cuvid", "-i", orig_filename, "-vf", "-hwaccel", "cuvid", "-i", orig_filename, "-vf",
@ -41,6 +43,7 @@ def encode_video_with_subtitles(orig_filename: str, subtitles: list[str], new_fi
new_filename new_filename
], stdout=subprocess.PIPE) ], stdout=subprocess.PIPE)
else: else:
print("[+]Use CPU Encode")
encode_process = subprocess.Popen([ encode_process = subprocess.Popen([
FFMPEG_EXEC, "-hide_banner", "-progress", "-", "-v", "0", "-y", FFMPEG_EXEC, "-hide_banner", "-progress", "-", "-v", "0", "-y",
"-i", orig_filename, "-vf", "-i", orig_filename, "-vf",