forked from DavidLangmeier/encAlot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHM.py
34 lines (28 loc) · 1.32 KB
/
HM.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
import subprocess
import sys
from pathlib import Path
import Helper
# encoder specific path variables
hm_root = "codecs/HM"
hm_exe = Helper.getEXE(hm_root, "TAppEncoder")
hm_encoderConfig = Path("codecs/HM/cfg/encoder_randomaccess_main.cfg")
def encode(seqCfg_path, filename, tbr, output_path):
print("*** HEVC-HM encoding started, Filename: " + filename + ", TargetBitrate: " + str(tbr) + " ***")
binaryOutput = output_path + filename + "_" + "HM" + "_" + str(int(tbr / 1000)) + "kbps" + "_str.bin"
recOutput = output_path + filename + "_" + "HM" + "_" + str(int(tbr / 1000)) + "kbps" + "_rec.yuv"
logfile = output_path + filename + "_" + "HM" + "_" + str(int(tbr / 1000)) + "kbps" + "_log.txt"
targetBitrate = "--TargetBitrate=" + str(tbr)
log = open(Path(logfile), "w+")
result = subprocess.run([hm_exe,
"-c", hm_encoderConfig,
"-c", Path(seqCfg_path),
"-b", Path(binaryOutput),
"-o", Path(recOutput),
targetBitrate,
"--PrintMSSSIM=1"],
stdout=log,
stderr=sys.stdout
)
log.close()
if result.returncode == 0:
print("*** encoding finished ***\n")