add patch script for call site + recorders.js growing_codec guard

This commit is contained in:
Zac Gaetano 2026-06-04 17:50:41 -04:00
parent a5573a918d
commit 42a591cc97

View file

@ -0,0 +1,52 @@
import sys
# ── capture-manager.js: pass growingCodecName at the call site ──────────────
path = '/opt/wild-dragon/services/capture/src/capture-manager.js'
src = open(path).read()
old_call = """ hlsDir: (sourceType === 'sdi' || sourceType === 'deltacast') ? sdiHlsDir : null,
videoCodec,
audioMap,
interlaced: isInterlacedSource,
});"""
new_call = """ hlsDir: (sourceType === 'sdi' || sourceType === 'deltacast') ? sdiHlsDir : null,
videoCodec,
growingCodecName: gCodec,
audioMap,
interlaced: isInterlacedSource,
});"""
if old_call in src:
src = src.replace(old_call, new_call, 1)
open(path, 'w').write(src)
print('OK capture-manager.js call site patched')
else:
print('FAIL capture-manager.js call site not found')
sys.exit(1)
# ── recorders.js: expand binary growing_codec guard ─────────────────────────
path2 = '/opt/wild-dragon/services/mam-api/src/routes/recorders.js'
src2 = open(path2).read()
# Sidecar env GROWING_CODEC=
old_env = "`GROWING_CODEC=${recorder.growing_codec === 'hevc_nvenc' ? 'hevc_nvenc' : 'avci100'}`,"
new_env = "`GROWING_CODEC=${['avci50','avci100','avci200','hevc_nvenc'].includes(recorder.growing_codec) ? recorder.growing_codec : 'avci100'}`,"
# startBody growing_codec
old_body = " growing_codec: recorder.growing_codec === 'hevc_nvenc' ? 'hevc_nvenc' : 'avci100',"
new_body = " growing_codec: ['avci50','avci100','avci200','hevc_nvenc'].includes(recorder.growing_codec) ? recorder.growing_codec : 'avci100',"
ok = True
for old, new, label in [(old_env, new_env, 'GROWING_CODEC env'), (old_body, new_body, 'startBody growing_codec')]:
if old in src2:
src2 = src2.replace(old, new, 1)
print(f'OK recorders.js {label}')
else:
print(f'FAIL recorders.js {label}')
ok = False
if ok:
open(path2, 'w').write(src2)
print('recorders.js written OK')
else:
sys.exit(1)