Save RTSP Stream to MP4 with FFmpeg Without Re-encoding

This article explains how to capture a live video stream from an RTSP camera and save it directly into an MP4 file using FFmpeg without re-encoding. By copying the original video and audio codecs instead of re-encoding them, you will minimize CPU usage, preserve the original video quality, and save the stream in real-time.

The Basic Command

To capture an RTSP stream and save it as an MP4 file without re-encoding, use the following FFmpeg command:

ffmpeg -rtsp_transport tcp -i "rtsp://username:password@camera_ip:port/stream_path" -c copy output.mp4

Command Breakdown

Advanced Options

Limit the Recording Duration

If you want to record the stream for a specific amount of time (for example, 10 minutes), add the -t parameter before the output file name:

ffmpeg -rtsp_transport tcp -i "rtsp://camera_url" -c copy -t 00:10:00 output.mp4

Split Recording into Segments

To continuously record the stream and split it into hourly files without gaps, you can use FFmpeg’s segment muxer:

ffmpeg -rtsp_transport tcp -i "rtsp://camera_url" -c copy -map 0 -f segment -segment_time 3600 -segment_format mp4 -reset_timestamps 1 capture_%03d.mp4

This command splits the stream into 3600-second (1 hour) chunks, naming them sequentially (capture_001.mp4, capture_002.mp4, etc.).