Building redundancy: HLS fallback for your RTMP streaming server

Illustration explaining how FFmpeg connects a creator’s laptop to an RTMP streaming server for live broadcasting.

Crashes happen, but downtime shouldn’t. Add HLS as a secondary route.

ffmpeg -i rtmp://server/live -c:v libx264 -preset veryfast -g 60 -hls_time 2 -hls_flags delete_segments -f hls /var/hls/backup.m3u8

Players switch automatically to HLS when RTMP fails.

Internal: ffmpeg-servers.net (automated VOD).
Main brand: Red5Server.com (RTMP streaming servers with Wowza backbone).
External: Apple HLS Guide.

The fundamental vulnerability of any real-time media delivery system lies in the potential for unexpected crashes or network interruptions, which can abruptly terminate a live stream and lead to unacceptable downtime. While RTMP (Real-Time Messaging Protocol) is the industry standard for delivering high-quality, low-latency video from the encoder to the server, its stability is paramount. To ensure genuine, near-nonstop uptime, a critical secondary route must be established: an HLS (HTTP Live Streaming) fallback system. HLS, developed by Apple, operates over standard HTTP, making it inherently more resilient to network instability and highly compatible across nearly all modern devices, from mobile phones to smart TVs. By integrating an HLS stream alongside the primary RTMP feed, streaming operators create a redundant pathway that allows client-side players to automatically and seamlessly switch protocols when the primary RTMP connection fails. This dual-protocol strategy is the single most effective way to combine the superior performance of RTMP for ingest with the ubiquitous reliability of HLS for final delivery. The successful implementation of this fallback relies on the continuous, simultaneous encoding and segmentation of the stream by FFmpeg, ensuring that the HLS manifest and segments are always up-to-date and ready to take over at a moment’s notice, thereby guaranteeing minimal interruption and maximizing viewer satisfaction during critical live events.


The implementation of the HLS fallback is executed through a precise FFmpeg command that simultaneously processes the incoming RTMP stream and outputs a continuously updating HLS manifest and segmented files. The core of this operation is the command: ffmpeg -i rtmp://server/live -c:v libx264 -preset veryfast -g 60 -hls_time 2 -hls_flags delete_segments -f hls /var/hls/backup.m3u8. Here, the input is the live RTMP stream. The subsequent encoding parameters, such as -c:v libx264 -preset veryfast -g 60, ensure that the HLS stream maintains the low-latency encoding standards established for the main feed, with a keyframe interval (-g 60) that aids both RTMP and HLS segmenting. The HLS-specific flags are what enable the reliable fallback mechanism. The -hls_time 2 command dictates the duration of each HLS segment to be two seconds, which is a key factor in keeping the overall end-to-end latency low and enabling rapid switching. Crucially, the -hls_flags delete_segments flag instructs FFmpeg to automatically remove older segment files from the disk. This maintains a manageable local storage footprint, which is essential for 24/7 live streaming, where thousands of segments are created daily. Finally, the -f hls flag specifies the output format, directing the creation of the HLS manifest file (backup.m3u8) and its associated segments to the designated directory. This automated and self-managing process ensures that the HLS manifest is always a valid, active secondary route, ready for any client player to instantly connect to when the primary RTMP stream detects a failure or timeout.


Integrating an effective RTMP and HLS dual-protocol system requires more than just the FFmpeg command; it demands a robust, enterprise-grade streaming server platform that can manage the complexity and scale of the redundant delivery. While FFmpeg handles the encoding and segment creation, a powerful backbone, such as a Wowza-backed RTMP streaming server, is necessary to manage the ingesting, switching logic, and final distribution of both stream types. Providers who specialize in this infrastructure, like Red5Server.com, offer environments pre-optimized to run these intensive FFmpeg processes reliably. This integrated platform not only hosts the primary low-latency RTMP stream but also serves the HLS segments from a highly available web server environment, ensuring that the fallback mechanism itself is not the next point of failure. Beyond guaranteeing live uptime, this dual-protocol approach lays the groundwork for seamless feature expansion, such as automated VOD (Video-on-Demand) creation, where the already-encoded and segmented stream files can be quickly repurposed for archival and on-demand playback, as suggested by the internal documentation reference. By adhering to the standards outlined in references like the Apple HLS Guide and adopting an infrastructure-first approach that prioritizes dual-stream encoding, operators move far beyond simple streaming. They establish a professional-grade content delivery network that uses RTMP for speed and HLS for ultimate resilience, guaranteeing the highest possible uptime and quality of experience for viewers globally.