工作流,优化双卡协同,加视频防音画不同步
This commit is contained in:
parent
a393639ac1
commit
28a56b6b83
@ -328,6 +328,7 @@ class WorkerThread(QThread):
|
||||
"-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",
|
||||
"-fflags", "+genpts", "-shortest", "-movflags", "faststart",
|
||||
# "-t", "10",
|
||||
new_filename
|
||||
], **subprocess_args(True))
|
||||
@ -342,6 +343,7 @@ class WorkerThread(QThread):
|
||||
"-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",
|
||||
"-fflags", "+genpts", "-shortest", "-movflags", "faststart",
|
||||
# "-t", "10",
|
||||
new_filename
|
||||
], **subprocess_args(True))
|
||||
@ -355,6 +357,7 @@ class WorkerThread(QThread):
|
||||
"-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",
|
||||
"-fflags", "+genpts", "-shortest", "-movflags", "faststart",
|
||||
# "-t", "10",
|
||||
new_filename
|
||||
], **subprocess_args(True))
|
||||
@ -368,6 +371,7 @@ class WorkerThread(QThread):
|
||||
"-f", "mp4", "-preset:v", "fast", "-profile:v", "high", "-level", "4.1",
|
||||
"-b:v", VIDEO_BITRATE, "-rc:v", "vbr",
|
||||
"-qmin", "10", "-qmax", "32", "-crf", "16",
|
||||
"-fflags", "+genpts", "-shortest", "-movflags", "faststart",
|
||||
# "-t", "10",
|
||||
new_filename
|
||||
], **subprocess_args(True))
|
||||
@ -384,30 +388,34 @@ class WorkerThread(QThread):
|
||||
print("[>]Duration:", duration)
|
||||
if duration > (VIDEO_CLIP_EACH_SEC * 5):
|
||||
# qsv 压制前2段,剩余交由nvenc压制
|
||||
new_filename0 = base_ts_to_filename(base_ts)
|
||||
new_filename1 = base_ts_to_filename(base_ts + VIDEO_CLIP_EACH_SEC * 2)
|
||||
_slices = int(duration / VIDEO_CLIP_EACH_SEC)
|
||||
new_filename0 = base_ts_to_filename(base_ts + (_slices - 1) * VIDEO_CLIP_EACH_SEC)
|
||||
new_filename1 = base_ts_to_filename(base_ts)
|
||||
print("[+]Use Intel QSV Acceleration")
|
||||
encode_process0 = subprocess.Popen([
|
||||
FFMPEG_EXEC, "-hide_banner", "-progress", "-", "-loglevel", "error", "-y",
|
||||
"-hwaccel", "qsv", "-t", str(VIDEO_CLIP_EACH_SEC * 2 + (VIDEO_CLIP_OVERFLOW_SEC * 0.8)), "-i",
|
||||
orig_filename, "-vf",
|
||||
"-hwaccel", "qsv", "-ss", str((_slices - 1) * VIDEO_CLIP_EACH_SEC),
|
||||
"-copyts", "-i", orig_filename, "-vf",
|
||||
",".join("subtitles=%s" % i for i in subtitles),
|
||||
"-c:a", "copy", "-c:v", "h264_qsv",
|
||||
"-c:a", "copy", "-c:v", "h264_qsv", "-ss", str((_slices - 1) * VIDEO_CLIP_EACH_SEC),
|
||||
"-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",
|
||||
"-fflags", "+genpts", "-shortest", "-movflags", "faststart",
|
||||
# "-t", "10",
|
||||
new_filename0
|
||||
], **subprocess_args(True))
|
||||
print("[+]Use Nvidia NvEnc Acceleration")
|
||||
encode_process1 = subprocess.Popen([
|
||||
FFMPEG_EXEC, "-hide_banner", "-progress", "-", "-loglevel", "error", "-y",
|
||||
"-ss", str(VIDEO_CLIP_EACH_SEC * 2), "-copyts", "-i", orig_filename, "-vf",
|
||||
"-t", str((_slices - 1) * VIDEO_CLIP_EACH_SEC + (VIDEO_CLIP_OVERFLOW_SEC * 0.5)),
|
||||
"-i", orig_filename, "-vf",
|
||||
",".join("subtitles=%s" % i for i in subtitles),
|
||||
"-c:a", "copy", "-c:v", "h264_nvenc", "-ss", str(VIDEO_CLIP_EACH_SEC * 2),
|
||||
"-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",
|
||||
"-fflags", "+genpts", "-shortest", "-movflags", "faststart",
|
||||
# "-t", "10",
|
||||
new_filename1
|
||||
], **subprocess_args(True))
|
||||
@ -418,30 +426,34 @@ class WorkerThread(QThread):
|
||||
return [new_filename0, new_filename1]
|
||||
elif duration > (VIDEO_CLIP_EACH_SEC * 3):
|
||||
# 至少也要能切2片,才用双GPU加速
|
||||
new_filename0 = base_ts_to_filename(base_ts, True)
|
||||
new_filename1 = base_ts_to_filename(base_ts + VIDEO_CLIP_EACH_SEC)
|
||||
_slices = int(duration / VIDEO_CLIP_EACH_SEC)
|
||||
new_filename0 = base_ts_to_filename(base_ts + _slices * VIDEO_CLIP_EACH_SEC, True)
|
||||
new_filename1 = base_ts_to_filename(base_ts)
|
||||
print("[+]Use Intel QSV Acceleration")
|
||||
encode_process0 = subprocess.Popen([
|
||||
FFMPEG_EXEC, "-hide_banner", "-progress", "-", "-loglevel", "error", "-y",
|
||||
"-hwaccel", "qsv", "-t", str(VIDEO_CLIP_EACH_SEC + (VIDEO_CLIP_OVERFLOW_SEC * 0.8)), "-i",
|
||||
orig_filename, "-vf",
|
||||
"-hwaccel", "qsv", "-ss", str(_slices * VIDEO_CLIP_EACH_SEC),
|
||||
"-copyts", "-i", orig_filename, "-vf",
|
||||
",".join("subtitles=%s" % i for i in subtitles),
|
||||
"-c:a", "copy", "-c:v", "h264_qsv",
|
||||
"-c:a", "copy", "-c:v", "h264_qsv", "-ss", str(_slices * VIDEO_CLIP_EACH_SEC),
|
||||
"-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",
|
||||
"-fflags", "+genpts", "-shortest", "-movflags", "faststart",
|
||||
# "-t", "10",
|
||||
new_filename0
|
||||
], **subprocess_args(True))
|
||||
print("[+]Use Nvidia NvEnc Acceleration")
|
||||
encode_process1 = subprocess.Popen([
|
||||
FFMPEG_EXEC, "-hide_banner", "-progress", "-", "-loglevel", "error", "-y",
|
||||
"-ss", str(VIDEO_CLIP_EACH_SEC), "-copyts", "-i", orig_filename, "-vf",
|
||||
"-t", str(_slices * VIDEO_CLIP_EACH_SEC + VIDEO_CLIP_OVERFLOW_SEC * 0.5),
|
||||
"-i", orig_filename, "-vf",
|
||||
",".join("subtitles=%s" % i for i in subtitles),
|
||||
"-c:a", "copy", "-c:v", "h264_nvenc", "-ss", str(VIDEO_CLIP_EACH_SEC),
|
||||
"-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",
|
||||
"-fflags", "+genpts", "-shortest", "-movflags", "faststart",
|
||||
# "-t", "10",
|
||||
new_filename1
|
||||
], **subprocess_args(True))
|
||||
@ -471,6 +483,7 @@ class WorkerThread(QThread):
|
||||
"-ss", str(current_sec),
|
||||
"-i", file_name, "-c", "copy", "-f", "mp4",
|
||||
"-t", str(VIDEO_CLIP_EACH_SEC + VIDEO_CLIP_OVERFLOW_SEC),
|
||||
"-fflags", "+genpts", "-shortest", "-movflags", "faststart",
|
||||
"{}.mp4".format(current_dt)
|
||||
], **subprocess_args(True))
|
||||
self.handle_ffmpeg_output(split_process.stdout)
|
||||
|
@ -47,6 +47,7 @@ if __name__ == '__main__':
|
||||
"-ss", str(current_sec),
|
||||
"-i", input_file, "-c", "copy", "-f", "mp4",
|
||||
"-t", str(EACH_SEC + OVERFLOW_SEC),
|
||||
"-shortest",
|
||||
"{}.mp4".format(current_dt)
|
||||
])
|
||||
split_process.wait()
|
||||
|
Loading…
x
Reference in New Issue
Block a user