-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenc_hevc_vceenc.py
66 lines (55 loc) · 1.65 KB
/
enc_hevc_vceenc.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
"""
AMD VCE
https://github.com/rigaya/VCEEnc/blob/master/VCEEncC_Options.en.md
Rembrandt Radeon 680M H.265/HEVC encode features
10bit depth: yes
max profile: main10
max bitrate: 1000000 kbps
ref frames: 1-16
pre analysis: yes
max streams: 16
timeout support: yes
smart access: no
lut: --vpp-colorspace lut3d=<path> lut3d_interp=<string>
"""
from lib import BaseEncoder
OUTPUT_BUFFER = 32
PROFILES = {
'yuv420:8': 'main',
'yuv422:8': 'main',
'yuv420:10': 'main10',
'yuv422:10': 'main10',
}
COLORS = {
'BT.709': 'bt709'
# smpte2084 bt2020nc bt2020c
}
class Encoder(BaseEncoder):
CMD = ['vceencc', '--avsw']
can_scale = True
def __init__(self, vid):
#print(f'hevc_vceenc idx:{vid.idx()}')
self.params = {
'c': 'hevc',
'u': 'slow',
'-cqp': vid.crf,
'-profile': PROFILES[vid.idx()],
'-tier': 'high',
'-output-depth': vid.bits,
'-output-buf': OUTPUT_BUFFER,
}
if vid.gop:
self.params['-gop-len'] = vid.gop
if vid.color_primaries:
self.params['-colorprim'] = COLORS[vid.color_primaries]
if vid.transfer_characteristics:
self.params['-transfer'] = COLORS[vid.transfer_characteristics]
if vid.matrix_coefficients:
self.params['-colormatrix'] = COLORS[vid.matrix_coefficients]
self.res = vid.res
def get_params(self):
return self.params
def get_filter(self, *args, scale=None, **kwargs):
if not scale:
return {}
return ['--output-res', f'-2x{self.res}', '--vpp-resize', 'lanczos3']