How to Show Fallback Image When FFmpeg Stream Disconnects

Maintaining a continuous live stream when the primary input source disconnects is crucial for a professional broadcasting setup. This article explains how to configure FFmpeg to automatically inject a static slate or fallback image when a live video source drops, ensuring your stream remains active and your viewers are not left with a blank screen or a dropped connection.

To achieve a seamless fallback transition in FFmpeg, the most reliable method is to loop a static background image and overlay the live stream on top of it. When the live stream disconnects, the overlay filter passes the background image through to the output while FFmpeg attempts to reconnect to the source.

The FFmpeg Command

Use the following command structure to set up the fallback mechanism:

ffmpeg -loop 1 -f image2 -i slate.png \
-reconnect 1 -reconnect_at_eof 1 -reconnect_streamed 1 -reconnect_delay_max 5 \
-i rtmp://example.com/live/stream \
-filter_complex "[0:v][1:v] overlay=eof_action=repeat [outv]" \
-map "[outv]" -map 1:a? -c:v libx264 -c:a aac -f flv rtmp://example.com/live/destination

How It Works

This setup ensures that your destination RTMP server receives a continuous video stream (the slate image) even when the source input experiences packet loss or a complete disconnect.