스트리밍 지연 제거: Node.js에서 우선순위 선점 FFmpeg 대기열 구축
Eliminating Streaming Lag: Building a Priority Preemption FFmpeg Queue in Node.js
대부분의 자체 호스팅 스트리밍 서버는 사용자가 '재생'을 클릭할 때까지 기다렸다가 호환되지 않는 컨테이너의 트랜스코딩을 시작합니다.
핵심 요약
자동 요약- 1대부분의 자체 호스팅 스트리밍 서버는 사용자가 '재생'을 클릭할 때까지 기다렸다가 호환되지 않는 컨테이너의 트랜스코딩을 시작합니다.
- 25~15초 동안 버퍼링이 진행되고 CPU 사용률이 높아집니다.
- 3최근 Homeflix에 대한 오픈 소스 기여에서 우리는 실시간 트랜스코딩을 사전 예방적이고 우선순위가 지정된 백그라운드 엔진으로 대체했습니다.
원문 본문
출처 · dev.toMost self-hosted streaming servers wait until you click "Play" to start transcoding incompatible containers. The result? 5–15 seconds of buffering and pegged CPUs.
In my recent open-source contribution to Homeflix, we replaced real-time transcoding with a proactive, prioritized background engine.
The Core Challenge: Worker Preemption
If the background queue is converting a movie and a user hits "Play" on a TV show, running two FFmpeg jobs will bottleneck the CPU.
Here is the atomic preemption lifecycle we designed:
function preemptActiveConversion(nextPriorityId) { if (!activeConversion || !activeConversion.process) return; activeConversion.preempted = true; activeConversion.process.kill('SIGTERM'); // Fallback watchdog if process hangs setTimeout(() => { if (activeConversion?.process) activeConversion.process.kill('SIGKILL'); }, 2000); // Clean partial files to prevent disk corruption cleanPartialCache(activeConversion.item.tempPath); requeuePreemptedItem(activeConversion.item); } Key Takeaways in the Article:
- 5-Tier Conversion Scheduling: User priority → Series episodes → Resumed items → Movies.
- Scene Regex Parsing: Resilient normalization for messy P2P & Telegram filenames.
- The Windows Installer Bug: Why bundling
chocolatey/bin/ffmpeg.exefails in Electron NSIS packages (and how to resolve the real binary).
Read the complete breakdown and run the build locally:
https://adilrahman.cc/blog/homeflix-background-transcoding-engine?utm_source=devto
이 글은 dev.to 의 원문을 정제해 보여드립니다. 저작권은 원저작자에게 있습니다.
전체 내용이 궁금하다면
dev.to 원문에서 이어 읽기




