Dump RTMP Live Stream to FLV with FFmpeg
This guide provides a straightforward, step-by-step tutorial on how to use FFmpeg to capture a live RTMP stream and save it directly into an FLV container. You will learn the exact command-line syntax required to dump the stream without re-encoding, preserving the original quality of the broadcast while keeping CPU usage to an absolute minimum.
The Basic Command
To dump a live RTMP stream directly to an FLV file, run the following FFmpeg command in your terminal:
ffmpeg -i "rtmp://example.com/live/stream_key" -c copy output.flvCommand Breakdown
-i "rtmp://example.com/live/stream_key": This specifies the input source. Replace the placeholder URL with your actual RTMP stream destination. It is recommended to wrap the URL in quotation marks to prevent the terminal from misinterpreting special characters.-c copy: This is the most crucial parameter. It tells FFmpeg to copy the audio and video payloads directly from the incoming stream without re-encoding them. Since no decoding or encoding takes place, this process uses negligible CPU resources and prevents any quality loss.output.flv: This is the destination file path. FFmpeg automatically detects the.flvextension and packages the copied streams into an FLV container.
Handling Unstable Connections
Live streams can sometimes suffer from network jitter or brief disconnects. To make your dumping process more resilient, you can add parameters to handle timeouts and force the output format:
ffmpeg -rw_timeout 10000000 -i "rtmp://example.com/live/stream_key" -c copy -f flv output.flv-rw_timeout 10000000: Sets a receiver/writer timeout in microseconds (10 seconds in this example). If the network stream stalls for longer than this duration, FFmpeg will exit instead of hanging indefinitely.-f flv: Explicitly forces the output format to FLV, ensuring the container integrity even if the file extension is omitted or changed.