How to Output Raw Video from FFmpeg to stdout

To output raw video data from FFmpeg directly to standard output (stdout), you need to instruct FFmpeg to use the raw video muxer and direct the output file path to the system’s standard output stream. This guide explains how to construct the correct FFmpeg command using the pipe protocol and format flags, ensuring your raw video frames are seamlessly piped into other applications or scripts.

The Standard Command Structure

To output raw video to stdout, use the hyphen character (-) or pipe:1 as the output destination. You must also specify the raw video format using the -f rawvideo flag and define the desired pixel format.

Here is the standard command:

ffmpeg -i input.mp4 -f rawvideo -pix_fmt rgb24 -

Alternatively, you can use the explicit pipe syntax:

ffmpeg -i input.mp4 -f rawvideo -pix_fmt yuv420p pipe:1

Parameter Breakdown

Preventing Console Log Corruption

By default, FFmpeg writes its configuration details, progress reports, and errors to standard error (stderr). This naturally keeps the raw video data on stdout clean. However, to ensure no accidental log data interferes with your stream, you can disable the banner and lower the log level:

ffmpeg -hide_banner -loglevel panic -i input.mp4 -f rawvideo -pix_fmt rgb24 -

Practical Example: Piping to Another Program

When piping raw video to another program, the receiving application must be configured to read from standard input (stdin) and know the exact dimensions and pixel format of the video, as raw video contains no header metadata.

For example, to pipe raw video from FFmpeg directly into another player like FFplay:

ffmpeg -i input.mp4 -f rawvideo -pix_fmt yuv420p - | ffplay -f rawvideo -pixel_format yuv420p -video_size 1920x1080 -