Step-by-Step: Build a 24/7 YouTube Livestream System With Node.js, FFmpeg, PM2, and a Small Linux VM
This lesson shows you how to build a simple but reliable 24/7 YouTube livestream stack without turning your laptop into the permanent broadcast machine. The core idea is straightforward: 1. Use your main computer as the operator workstation. 2. Use a small Linux VM as the always-on runtime. 3. Prebuild the heavy media assets before you stream. 4. Let FFmpeg handle the broadcast. 5. Let PM2 keep the long-running processes alive. If you copy this architecture, you will get a setup that is easier to restart, easier to debug, and much harder to break accidentally. ## What You Are Building By the end of this guide, you will have: - A local operator machine for setup, media prep, and manual control. - A lightweight Linux VM for the live runtime. - A Node.js app that prepares the loop, manages the stream state, and runs helper services. - An FFmpeg broadcast pipeline that can update overlays without a full restart. - A PM2 process model that keeps the stream services alive across crashes and reboots. ## Recommended Architecture Use this split: - Operator workstation: Build media assets, run manual maintenance actions, inspect logs, and deploy updates. - Linux VM: Run the always-on stream, chat responder, and health reporting. Why this matters: - Heavy browser automation and media generation are bursty workloads. - 24/7 broadcasting needs stable, boring, repeatable workloads. - Those are not the same job, so do not force them onto the same box. ## Minimum Stack Install or prepare these pieces: - Node.js 20+ - FFmpeg - PM2 - Git - OpenSSH - A Linux VM with Ubuntu 22.04 or similar - A YouTube channel enabled for live streaming - A Telegram bot or another alerting destination if you want health summaries Recommended VM size: - 2 vCPU - 1 to 4 GB RAM - Enough disk for logs plus generated loop assets ## Folder Layout Use a layout like this: ```text your-project/ src/ live/ stream.js chatResponder.js healthReporter.js overlayControl.js scripts/ start-live.sh deploy-live.ps1