Copy RTSP to RTMP with FFmpeg Without Re-encoding

This guide explains how to efficiently redirect video and audio streams from an RTSP source to an RTMP target using FFmpeg without re-encoding. By leveraging FFmpeg's stream copying functionality, you can route your live feed (such as from an IP camera) to streaming destinations like YouTube, Twitch, or a custom RTMP server with minimal CPU usage and virtually zero added latency.

The FFmpeg Command

To copy the streams directly without transcoding, use the following FFmpeg command:

ffmpeg -rtsp_transport tcp -i "rtsp://your_rtsp_source_url" -c copy -f flv "rtmp://your_rtmp_target_url"

Parameter Breakdown

  • -rtsp_transport tcp: This forces FFmpeg to use TCP instead of UDP for the RTSP connection. TCP prevents packet loss and eliminates visual artifacts or corruption in the stream.
  • -i "rtsp://your_rtsp_source_url": Specifies the input RTSP stream URL.
  • -c copy: This is the key parameter. It tells FFmpeg to copy both the video and audio streams directly (codec copy) without decoding and re-encoding them. This keeps CPU usage extremely low.
  • -f flv: Specifies the output format as FLV, which is the standard container format required for RTMP streaming.
  • "rtmp://your_rtmp_target_url": Specifies the destination RTMP URL (which usually includes your stream key, for example: rtmp://a.rtmp.youtube.com/live2/your-stream-key).

Stream Compatibility Requirements

Because you are copying the streams directly without re-encoding, the codecs used by your RTSP source must be compatible with the RTMP destination.

  • Video: The RTSP source should output H.264 video. While some modern RTMP ingestion servers support H.265 (HEVC), H.264 remains the most widely compatible format.
  • Audio: The RTSP source should output AAC or MP3 audio. If your RTSP camera uses G.711 (PCMA/PCMU), you may need to re-encode only the audio while still copying the video using -c:v copy -c:a aac.