Command Guide

FFmpeg RTSP — Essential Commands for IP Camera Streams

FFmpeg is the Swiss Army knife for working with RTSP streams from IP cameras. This guide covers the most useful commands — from testing a stream to recording and converting.

Test an RTSP Stream with ffplay

ffplay is the simplest way to verify an RTSP stream works:

ffplay rtsp://admin:password@192.168.1.100:554/stream1

Force TCP if UDP drops frames:

ffplay -rtsp_transport tcp rtsp://admin:password@192.168.1.100:554/stream1

Show stream info without playing:

ffprobe -rtsp_transport tcp rtsp://admin:password@192.168.1.100:554/stream1

Record RTSP Stream to MP4 with FFmpeg

# Record 60 seconds to MP4 ffmpeg -rtsp_transport tcp -i rtsp://admin:pass@IP:554/stream1 -t 60 -c copy output.mp4 # Continuous recording (no time limit) ffmpeg -rtsp_transport tcp -i rtsp://admin:pass@IP:554/stream1 -c copy output.mp4 # Segment into 1-hour files ffmpeg -rtsp_transport tcp -i rtsp://admin:pass@IP:554/stream1 \ -c copy -f segment -segment_time 3600 \ -strftime 1 "recording_%Y%m%d_%H%M%S.mp4"

Use -c copy whenever possible so FFmpeg writes the camera's H.264 or H.265 stream directly without re-encoding.

Convert RTSP to HLS (for Browser Playback)

RTSP does not play directly in browsers, so a common workflow is converting the stream to HLS:

ffmpeg -rtsp_transport tcp -i rtsp://admin:pass@IP:554/stream1 \ -c:v libx264 -c:a aac \ -f hls -hls_time 2 -hls_list_size 3 \ /var/www/html/stream/playlist.m3u8

If you want this continuously for many viewers, MediaMTX or go2rtc is usually easier than managing FFmpeg scripts by hand.

Re-stream RTSP with MediaMTX

MediaMTX (formerly rtsp-simple-server) re-publishes one RTSP source to many viewers:

# mediamtx.yml paths: camera1: source: rtsp://admin:pass@192.168.1.100:554/stream1

Then viewers connect to: rtsp://localhost:8554/camera1

It also exposes HLS at: http://localhost:8888/camera1/index.m3u8

And WebRTC at: http://localhost:8889/camera1

Tip: For iPhone viewing without FFmpeg, SmartRTSP connects directly to your camera's RTSP URL — no MediaMTX needed.

GStreamer RTSP Commands

GStreamer is the main alternative when you need custom, pipeline-based RTSP processing:

# Play RTSP stream gst-launch-1.0 rtspsrc location=rtsp://admin:pass@IP:554/stream1 ! decodebin ! autovideosink # Force TCP transport gst-launch-1.0 rtspsrc location=rtsp://admin:pass@IP:554/stream1 protocols=tcp ! decodebin ! autovideosink # Save to file gst-launch-1.0 rtspsrc location=rtsp://admin:pass@IP:554/stream1 ! rtph264depay ! h264parse ! mp4mux ! filesink location=output.mp4

GStreamer is especially common on embedded Linux, Raspberry Pi, Jetson, and hardware-accelerated video pipelines.

FFmpeg vs GStreamer vs MediaMTX — Which to Use?

ToolBest ForComplexityPlatform
ffplayQuick RTSP testLowAll
FFmpegRecording, conversionMediumAll
GStreamerEmbedded, pipelinesHighLinux/RPi
MediaMTXRe-streaming, multi-protocolMediumAll (Docker)
go2rtcHome Assistant, WebRTCLowAll
SmartRTSPiPhone/Mac live viewVery LowiOS/macOS

View RTSP on iPhone Without FFmpeg

FFmpeg is powerful, but it requires a desktop or server. If you just want to watch an RTSP camera on iPhone or Mac, SmartRTSP is much simpler.

  • No command line needed
  • Supports H.264 and H.265 hardware decoding
  • ONVIF auto-discovery
  • Free download

Download SmartRTSP on the App Store →

FFmpeg RTSP FAQ

How do I test an RTSP stream with FFmpeg?

Use ffplay -rtsp_transport tcp rtsp://user:pass@IP:554/stream. It opens the stream in a player window immediately.

How do I record an RTSP stream with FFmpeg?

Run ffmpeg -rtsp_transport tcp -i rtsp://user:pass@IP/stream -c copy output.mp4 to save the camera stream directly to MP4.

What is MediaMTX?

MediaMTX is an open-source media server that can receive an RTSP stream and re-publish it as RTSP, HLS, WebRTC, or RTMP.

Can I view RTSP on iPhone without FFmpeg?

Yes — SmartRTSP connects directly to RTSP cameras on iPhone and Mac with no computer required.