forked from DavidLangmeier/encAlot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVVenC.py
43 lines (35 loc) · 1.57 KB
/
VVenC.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
40
41
42
43
import subprocess
import sys
from pathlib import Path
import Helper
# encoder specific path variables
vvenc_root = "codecs/vvenc"
vvenc_exe = Helper.getEXE(vvenc_root, "vvencFFapp")
vvenc_encoderCfgPath = "codecs/vvenc/cfg/randomaccess_"
def encode(seqCfg_path, filename, tbr, preset, threads, output_path):
print("*** vvenc encoding started; Filename: " + filename + ", TargetBitrate: " + str(tbr) + ", preset: " + preset
+ ", Threads: " + str(threads) + " ***")
encoderConfig = vvenc_encoderCfgPath + preset + ".cfg"
BinaryOutput = output_path + filename + "_" + "vvenc" + "_" \
+ preset + "_" + str(int(tbr / 1000)) + "kbps" + "_str.bin"
RecOutput = output_path + filename + "_" + "vvenc" + "_" \
+ preset + "_" + str(int(tbr / 1000)) + "kbps" + "_rec.yuv"
logfile = output_path + filename + "_" + "vvenc" + "_" + str(threads) + "T_" \
+ preset + "_" + str(int(tbr / 1000)) + "kbps" + "_log.txt"
targetBitrate = "--TargetBitrate=" + str(tbr)
options = [vvenc_exe,
"-c", Path(encoderConfig),
"-c", Path(seqCfg_path),
"-b", Path(BinaryOutput),
"-o", Path(RecOutput),
targetBitrate]
if threads > 1:
options.append("--Threads=" + str(threads))
log = open(Path(logfile), "w+")
result = subprocess.run(options,
stdout=log,
stderr=sys.stdout
)
log.close()
if result.returncode == 0:
print("*** encoding finished ***\n")