Back to All Guides
codeAugust 16, 2026•7 min read•RTSPLink Dev Team

Node.js RTSP Stream Proxy & WebSocket Broadcast Tutorial

Ingest RTSP streams in Node.js using FFmpeg subprocesses and relay MPEG-TS frames to browser clients via WebSockets.

#Node.js#WebSockets#FFmpeg#JSMPEG#TypeScript
Live RTSP Test Feed

Need an active live RTSP stream to test this integration?

Generate a free 20-minute authenticated live H.264 video feed with frame counters to test in VLC, OpenCV, or NVR software.

#1Node.js FFmpeg RTSP Child Process

Spawn an FFmpeg process in Node.js to read RTSP over TCP and write MPEG-TS chunks directly to a WebSocket server:

Node.js WebSocket RTSP Server
const { spawn } = require('child_process');
const WebSocket = require('ws');

const wss = new WebSocket.Server({ port: 8080 });

const ffmpeg = spawn('ffmpeg', [
  '-rtsp_transport', 'tcp',
  '-i', 'rtsp://rtsplink.com/live/test?token=demo',
  '-f', 'mpegts',
  '-codec:v', 'mpeg1video',
  '-b:v', '1000k',
  '-r', '30',
  '-'
]);

ffmpeg.stdout.on('data', (chunk) => {
  wss.clients.forEach((client) => {
    if (client.readyState === WebSocket.OPEN) client.send(chunk);
  });
});

console.log('RTSP WebSocket broadcast proxy listening on ws://localhost:8080');

Ready to test your live RTSP video stream?

Generate free authenticated 20-minute RTSP links with unlimited bandwidth and inspect frame timestamps in seconds.

Related Tutorials & Setup Guides

View all 100+ guides