dddd / TCR /convertVid.py
naxyang's picture
Upload 45 files
e3c5b14 verified
raw
history blame contribute delete
954 Bytes
import os
import subprocess
# 视频目录
video_dir = r"C:\Users\yang2\Desktop\rebuttal\len_ab\TCR\m30"
# 要处理的视频文件列表
video_files = ["n1.mp4", "n2.mp4", "n3.mp4"]
for video in video_files:
input_path = os.path.join(video_dir, video)
output_path = os.path.join(video_dir, f"h264_{video}") # 输出文件名
print(f"GPU converting {input_path} -> {output_path} ...")
cmd = [
"ffmpeg",
"-hwaccel", "cuda", # 启用 GPU 加速
"-i", input_path,
"-c:v", "h264_nvenc", # 使用 NVIDIA GPU 的 H.264 编码器
"-preset", "fast", # 编码速度:fast/balanced/slow
"-cq", "23", # 质量控制:越小质量越高(类似 CRF)
"-an", # 移除音频
output_path
]
subprocess.run(cmd, check=True)
print("✅ All videos converted to H.264 using GPU.")