-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathtranscode_video.py
More file actions
47 lines (38 loc) · 1.21 KB
/
Copy pathtranscode_video.py
File metadata and controls
47 lines (38 loc) · 1.21 KB
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
40
41
42
43
44
45
46
47
import os
from typing import Any, Optional
from better_ffmpeg_progress import FfmpegProcess
from ffmpeg_process_factory import EncoderOptions, EncodingArguments
from utils import Logger, Timer, force_decimal_places, line
log = Logger("transcode_video.py")
def transcode_video(
original_video_path: str,
args: Any,
value: Optional[str],
output_path: str,
message: str,
combination: Optional[list[str]] = None,
) -> float:
encoder_opts = EncoderOptions(
encoder=args.encoder,
av1_cpu_used=args.av1_cpu_used,
)
encoding_args = EncodingArguments(
original_video_path,
encoder_opts,
output_path,
args.parameter,
value,
combination,
input_options=args.input_options,
output_options=args.output_options,
)
process = FfmpegProcess(encoding_args.get_arguments(), print_detected_duration=False)
line()
log.info(f"{message}...\n")
timer = Timer()
timer.start()
process.run(print_command=args.debug)
time_taken = timer.stop(args.decimal_places)
log.info(f"Time Taken: {force_decimal_places(time_taken, args.decimal_places)}s")
log.info(f"Output file: {output_path}")
return time_taken