Capture RTMP Stream to Stdout Using FFmpeg on macOS

This guide provides a quick, direct solution for capturing a live RTMP network stream and piping it directly to standard output (stdout) on macOS using the FFmpeg command-line tool. You will learn the necessary installation steps, the exact command syntax, and how to format the output stream so it can be read by other applications or processes in real-time.

Step 1: Install FFmpeg on macOS

To run FFmpeg on macOS, the easiest method is to use the Homebrew package manager. If you do not have Homebrew installed, you can get it from their official site, then install FFmpeg by opening your Terminal and running:

brew install ffmpeg

Step 2: The Command to Capture RTMP to Stdout

To pipe an RTMP stream directly to stdout, run the following command in your Terminal:

ffmpeg -i "rtmp://example.com/live/stream_key" -c copy -f mpegts -

Command Breakdown:

How to Use the Stdout Stream

Because the stream is written directly to stdout, you can pipe it into another tool for playback or processing. For example, to pipe the stream directly into the FFplay media player:

ffmpeg -i "rtmp://example.com/live/stream_key" -c copy -f mpegts - | ffplay -