使用的gpu类型

This commit is contained in:
2022-04-21 14:45:37 +08:00
parent f79f4191c6
commit add2957cc2
2 changed files with 12 additions and 7 deletions

@ -3,7 +3,8 @@ import subprocess
from datetime import datetime, timedelta
from typing import IO
from config import FFMPEG_EXEC, VIDEO_BITRATE, FFMPEG_USE_GPU, VIDEO_CLIP_EACH_SEC, VIDEO_CLIP_OVERFLOW_SEC, PROD_ENV
from config import FFMPEG_EXEC, VIDEO_BITRATE, FFMPEG_USE_GPU, VIDEO_CLIP_EACH_SEC, VIDEO_CLIP_OVERFLOW_SEC, PROD_ENV, \
FFMPEG_USE_INTEL_GPU
def get_video_real_duration(filename):
@ -17,10 +18,10 @@ def encode_video_with_subtitles(orig_filename: str, subtitles: list[str], new_fi
encode_process = subprocess.Popen([
FFMPEG_EXEC, "-hide_banner", "-progress", "-", "-v", "0", "-y",
"-i", orig_filename, "-vf",
",".join("subtitles=%s" % i for i in subtitles) + (",hwupload_cuda" if FFMPEG_USE_GPU else ""),
"-c:a", "copy", "-c:v", "h264_nvenc" if FFMPEG_USE_GPU else "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 else []),
",".join("subtitles=%s" % i for i in subtitles) + (",hwupload_cuda" if FFMPEG_USE_GPU and not FFMPEG_USE_INTEL_GPU else ""),
"-c:a", "copy", "-c:v", "h264" if not FFMPEG_USE_GPU else ("h264_qsv" if FFMPEG_USE_INTEL_GPU else "h264_nvenc"),
"-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 []),
"-qmin", "10", "-qmax", "32", "-crf", "16",
# "-t", "10",
new_filename