feat: add hardware accelerated main-stream HD previews
This commit is contained in:
@@ -268,12 +268,13 @@ def write_media_config():
|
||||
'record': bool(c['enabled'] and c['record'] and quality == 'main' and not STORAGE['paused']),
|
||||
'recordDeleteAfter': str(policy['retentionDays'] * 24) + 'h',
|
||||
}
|
||||
paths[stream_name(c, 'compat')] = {
|
||||
'source': 'publisher', 'record': False,
|
||||
'runOnDemand': shlex.join([sys.executable, str(ROOT / 'preview.py'), str(DATA)]) if c['enabled'] else '',
|
||||
'runOnDemandRestart': True,
|
||||
'runOnDemandStartTimeout': '45s', 'runOnDemandCloseAfter': '15s',
|
||||
}
|
||||
for quality in ('compat', 'hd'):
|
||||
paths[stream_name(c, quality)] = {
|
||||
'source': 'publisher', 'record': False,
|
||||
'runOnDemand': shlex.join([sys.executable, str(ROOT / 'preview.py'), str(DATA)]) if c['enabled'] else '',
|
||||
'runOnDemandRestart': True,
|
||||
'runOnDemandStartTimeout': '45s', 'runOnDemandCloseAfter': '15s',
|
||||
}
|
||||
config = {
|
||||
'logLevel': 'warn', 'logDestinations': ['stdout'],
|
||||
'api': True, 'apiAddress': '127.0.0.1:' + str(API_PORT),
|
||||
@@ -287,7 +288,7 @@ def write_media_config():
|
||||
'authInternalUsers': [{'user': 'vision', 'pass': setting('mediaSecret'),
|
||||
'ips': ['127.0.0.1', '::1'],
|
||||
'permissions': [{'action': a} for a in ('read', 'api', 'playback')]
|
||||
+ [{'action': 'publish', 'path': '~^cam_[a-f0-9]{16}_compat$'}]}],
|
||||
+ [{'action': 'publish', 'path': '~^cam_[a-f0-9]{16}_(compat|hd)$'}]}],
|
||||
'pathDefaults': {'recordFormat': 'fmp4', 'recordPath': str(RECORDINGS / '%path' / '%Y-%m-%d_%H-%M-%S-%f'),
|
||||
'recordSegmentDuration': '5m', 'recordPartDuration': '1s'},
|
||||
'paths': paths,
|
||||
@@ -610,7 +611,7 @@ class Handler(BaseHTTPRequestHandler):
|
||||
# browser must keep that session query on subsequent playlists.
|
||||
target = url.urlsplit(url.urljoin(path, r.getheader('Location', '')))
|
||||
if (port != HLS_PORT or target.scheme or target.netloc
|
||||
or not re.fullmatch(r'/cam_[a-f0-9]{16}_(main|sub|compat)/[a-zA-Z0-9_.-]+', target.path)):
|
||||
or not re.fullmatch(r'/cam_[a-f0-9]{16}_(main|sub|compat|hd)/[a-zA-Z0-9_.-]+', target.path)):
|
||||
raise Problem('视频服务返回了无效的播放跳转', 502)
|
||||
location = '/media/live' + target.path + ('?' + target.query if target.query else '')
|
||||
self.send_response(r.status)
|
||||
@@ -666,7 +667,7 @@ class Handler(BaseHTTPRequestHandler):
|
||||
self.answer({'items': items})
|
||||
elif path.startswith('/media/live/'):
|
||||
suffix = path[len('/media/live/'):]
|
||||
if not re.fullmatch(r'cam_[a-f0-9]{16}_(main|sub|compat)/[a-zA-Z0-9_.-]+', suffix):
|
||||
if not re.fullmatch(r'cam_[a-f0-9]{16}_(main|sub|compat|hd)/[a-zA-Z0-9_.-]+', suffix):
|
||||
raise Problem('视频路径不正确')
|
||||
self.proxy(HLS_PORT, '/' + suffix + ('?' + parsed.query if parsed.query else ''))
|
||||
elif path == '/media/playback':
|
||||
|
||||
Reference in New Issue
Block a user