Capture RTSPS Stream with FFmpeg on macOS

This guide explains how to capture and record a secure RTSP (RTSPS) stream using FFmpeg on macOS. You will learn how to install FFmpeg with the necessary secure protocols, construct the correct command-line syntax for TLS/SSL streams, and save the incoming stream directly to a local video file.

Step 1: Install FFmpeg on macOS

The easiest way to install FFmpeg on macOS is using Homebrew. Homebrew compiles FFmpeg with built-in support for secure protocols like TLS, which is required for RTSPS.

Open your Terminal application and run the following command:

brew install ffmpeg

To verify that your FFmpeg installation supports secure protocols, run:

ffmpeg -protocols | grep rtsps

If rtsps appears in the output, your installation is ready.

Step 2: Prepare the RTSPS URL

An RTSPS URL typically includes the username, password, IP address, port (usually 322 or 8554 for secure streams), and the stream path. It follows this format:

rtsps://username:password@ip_address:port/stream_path

Step 3: Run the FFmpeg Capture Command

To capture the stream and save it as an MP4 file without re-encoding (which preserves quality and minimizes CPU usage), use the following command structure:

ffmpeg -rtsp_transport tcp -tls_verify 0 -i "rtsps://username:password@ip_address:port/stream_path" -c copy output.mp4

Command Breakdown:

  • -rtsp_transport tcp: Forces FFmpeg to use TCP instead of UDP. TCP is highly recommended for RTSPS to prevent packet loss and video corruption.
  • -tls_verify 0: Bypasses SSL certificate verification. This is often necessary because many IP cameras use self-signed certificates. If your camera has a valid SSL certificate from a trusted authority, you can omit this flag or set it to 1.
  • -i "rtsps://...": Specifies the input source. Ensure the URL is enclosed in double quotes to prevent the terminal from misinterpreting special characters like ? or & in the stream path.
  • -c copy: Copies the video and audio streams directly from the source without re-encoding them. This ensures zero quality loss and requires negligible CPU power.
  • output.mp4: The destination file where the recorded stream will be saved.

Step 4: Stop the Capture

To stop recording, press Ctrl + C in your Terminal window. FFmpeg will safely finalize the container and save the completed video file to your current working directory.