FFmpeg & RTMP Relay Guide

Technical setup guide for video encoding and localized streaming routing.

Why FFmpeg + RTMP Relay?

Directly looping videos on YouTube Live can trigger GOP alignment errors, packet drops, or complete connection drops because encoders usually restart their timelines when starting a new video.

Pinku's Lab uses a local Windows Helper to run FFmpeg on the user's computer. FFmpeg is configured with a fixed frame rate, two-second keyframe interval, AAC audio, and a quality-specific bitrate before sending output directly to YouTube's secure RTMPS ingest endpoint.

Typical FFmpeg Command Structure

When you launch the stream, Pinku's Lab executes a local terminal task using the following parameters:

ffmpeg -re -stream_loop -1 -f concat -safe 0 -i playlist.txt \
  -c:v libx264 -preset veryfast -b:v 4500k -maxrate 4500k -bufsize 9000k \
  -g 60 -keyint_min 60 -sc_threshold 0 -c:a aac -b:a 128k -ar 44100 \
  -f flv rtmp://localhost:1935/live/stream
  • -re: Reads input at native frame rates (vital for live simulation).
  • -stream_loop -1: Loops the input list infinitely.
  • -f concat: Glues files in the playlist index together.
  • -g 60: Forces a Group of Pictures (GOP) keyframe boundary every 2 seconds (assuming 30fps stream) as required by YouTube ingest.

Troubleshooting Disconnects

If your stream disconnects, check your upload bandwidth and system CPU usage. Live hardware encoding requires stable resource availability. Use quality presets (e.g. 720p or 1080p) that keep your CPU load below 70%.