perf(nvr): 메인 MJPEG 540p·q11 — 720p·q9는 마당 요청이 원격에서 564바이트 만에 끊겼다(실측 13→5.3Mbps)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
kimandClaude Sonnet 5.5 committed 2026-10-01 11:51:03 +09:00
1 parent f25a39a035
commit 40f563c5f8
1 file changed
+3 -3
+3 -3
View File
@@ -677,11 +677,11 @@ export function registerNvrRoutes(
if (closed) return;
// 카메라 자체에 상하반전 옵션이 없는 모델(예: Mercusys — 미러만 지원)을 위해 ffmpeg
// 필터로 소프트웨어 180도 회전을 넣는다(2026-07-23). hflip+vflip 조합 = 180도 회전.
// 메인 스트림은 MJPEG 변환 전에 최대 720p로 줄인다 — 1080p JPEG를 초당 10장 내보내면 원격에서
// 메인 스트림은 MJPEG 변환 전에 최대 540p로 줄인다 — 1080p JPEG를 초당 10장 내보내면 원격에서
// 15~30Mbps가 나온다(2026-10-01 마당). 원본이 720p 이하면 그대로 둔다. 서브는 이미 작다.
const vfParts: string[] = [];
if (extraCam?.rotate180) vfParts.push('hflip', 'vflip');
if (stream === 0) vfParts.push('scale=w=-2:h=min(720\\,ih)');
if (stream === 0) vfParts.push('scale=w=-2:h=min(540\\,ih)');
const rotateFilterArgs = vfParts.length ? ['-vf', vfParts.join(',')] : [];
const proc: ChildProcess = spawn('ffmpeg', [
// HEVC 디코딩을 GPU(NVDEC)로 옮겨 4분할 고화질 동시 재생시 CPU 부하 감소.
@@ -701,7 +701,7 @@ export function registerNvrRoutes(
'-c:v', 'mjpeg',
// 6분할을 원격으로 보면 q5·10fps 합계가 ~50Mbps였다(2026-10-01). 그리드 타일은 작아서 q8·8fps로 충분.
// 메인(720p로 축소)은 q9 — 마당 실측 q5 18.8→q9 13.2Mbps.
'-q:v', stream === 0 ? '9' : '8',
'-q:v', stream === 0 ? '11' : '8',
'-r', '8',
'-an',
'-f', 'mjpeg',