嘤特尔GPU加速
This commit is contained in:
parent
d5bb50c583
commit
265734262c
@ -15,13 +15,39 @@ def get_video_real_duration(filename):
|
||||
|
||||
|
||||
def encode_video_with_subtitles(orig_filename: str, subtitles: list[str], new_filename: str):
|
||||
if FFMPEG_USE_GPU:
|
||||
if FFMPEG_USE_INTEL_GPU:
|
||||
encode_process = subprocess.Popen([
|
||||
FFMPEG_EXEC, "-hide_banner", "-progress", "-", "-v", "0", "-y",
|
||||
"-hwaccel", "vaapi", "-i", orig_filename, "-vf",
|
||||
",".join("subtitles=%s" % i for i in subtitles) + ",hwupload",
|
||||
"-c:a", "copy", "-c:v", "h264_vaapi",
|
||||
"-f", "mp4", "-preset:v", "fast", "-profile:v", "high", "-level", "4.1",
|
||||
"-b:v", VIDEO_BITRATE, "-rc:v", "vbr", "-tune:v", "hq",
|
||||
"-qmin", "10", "-qmax", "32", "-crf", "16",
|
||||
# "-t", "10",
|
||||
new_filename
|
||||
], stdout=subprocess.PIPE)
|
||||
else:
|
||||
encode_process = subprocess.Popen([
|
||||
FFMPEG_EXEC, "-hide_banner", "-progress", "-", "-v", "0", "-y",
|
||||
"-hwaccel", "cuvid", "-i", orig_filename, "-vf",
|
||||
",".join("subtitles=%s" % i for i in subtitles) + ",hwupload_cuda",
|
||||
"-c:a", "copy", "-c:v", "h264_nvenc",
|
||||
"-f", "mp4", "-preset:v", "fast", "-profile:v", "high", "-level", "4.1",
|
||||
"-b:v", VIDEO_BITRATE, "-rc:v", "vbr", "-tune:v", "hq",
|
||||
"-qmin", "10", "-qmax", "32", "-crf", "16",
|
||||
# "-t", "10",
|
||||
new_filename
|
||||
], stdout=subprocess.PIPE)
|
||||
else:
|
||||
encode_process = subprocess.Popen([
|
||||
FFMPEG_EXEC, "-hide_banner", "-progress", "-", "-v", "0", "-y",
|
||||
"-i", orig_filename, "-vf",
|
||||
",".join("subtitles=%s" % i for i in subtitles),
|
||||
"-c:a", "copy", "-c:v", "h264" if not FFMPEG_USE_GPU else ("h264_qsv" if FFMPEG_USE_INTEL_GPU else "h264_nvenc"),
|
||||
"-c:a", "copy", "-c:v", "h264",
|
||||
"-f", "mp4", "-preset:v", "fast", "-profile:v", "high", "-level", "4.1",
|
||||
"-b:v", VIDEO_BITRATE, "-rc:v", "vbr", *(["-tune:v", "hq"] if FFMPEG_USE_GPU and not FFMPEG_USE_INTEL_GPU else []),
|
||||
"-b:v", VIDEO_BITRATE, "-rc:v", "vbr",
|
||||
"-qmin", "10", "-qmax", "32", "-crf", "16",
|
||||
# "-t", "10",
|
||||
new_filename
|
||||
|
Loading…
x
Reference in New Issue
Block a user