|
|
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",
|
|
|
"-i", input_path,
|
|
|
"-c:v", "h264_nvenc",
|
|
|
"-preset", "fast",
|
|
|
"-cq", "23",
|
|
|
"-an",
|
|
|
output_path
|
|
|
]
|
|
|
|
|
|
subprocess.run(cmd, check=True)
|
|
|
|
|
|
print("✅ All videos converted to H.264 using GPU.")
|
|
|
|