-
Notifications
You must be signed in to change notification settings - Fork 30
/
vfr_to_cfr.py
27 lines (20 loc) · 733 Bytes
/
vfr_to_cfr.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import glob
import os
from concurrent.futures import ThreadPoolExecutor
input_dir = "/"
output_dir = "/"
files = glob.glob(input_dir + "/**/*.mkv", recursive=True)
files.sort()
if not os.path.exists(output_dir):
os.mkdir(output_dir)
def process_file(file_path):
fixed_file_path = file_path.replace("'", "").replace("!", "")
os.rename(file_path, fixed_file_path)
out_path = os.path.join(
output_dir, os.path.splitext(os.path.basename(fixed_file_path))[0] + "_mux.mkv"
)
os.system(
f"ffmpeg -i '{f}' -map 0 -c:a copy -c:s copy -fps_mode cfr -crf 5 '{out_path}' -y"
)
with ThreadPoolExecutor(max_workers=4) as executor:
executor.map(process_file, files)