-
Notifications
You must be signed in to change notification settings - Fork 19
/
transcode_video.py
39 lines (32 loc) · 1.02 KB
/
transcode_video.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
28
29
30
31
32
33
34
35
36
37
38
39
from ffmpeg_process_factory import EncodingArguments, EncoderOptions
from utils import line, Logger, Timer
from better_ffmpeg_progress import FfmpegProcess
log = Logger("transcode_video.py")
def transcode_video(
original_video_path, args, value, output_path, message, combination=None
):
encoder_opts = EncoderOptions(
encoder=args.encoder,
options=args.encoder_options,
av1_cpu_used=args.av1_cpu_used,
)
encoding_args = EncodingArguments(
original_video_path,
encoder_opts,
output_path,
args.parameter,
value,
combination,
)
process = FfmpegProcess(
encoding_args.get_arguments(), print_detected_duration=False
)
line()
log.info(f"{message}...\n")
timer = Timer()
timer.start()
process.run(log_file="transcode_log.txt", progress_bar_description="")
time_taken = timer.stop(args.decimal_places)
print(f"Time Taken: {time_taken}s")
log.info(f"Output file: {output_path}")
return time_taken