How to Read Raw YUV Video from Stdin with FFmpeg

Reading raw YUV video data from standard input (stdin) is a powerful way to pipeline video processing in FFmpeg without creating temporary files. Because raw YUV streams do not contain headers or metadata, FFmpeg cannot automatically detect the video’s properties like resolution, frame rate, or pixel format. This guide will show you how to explicitly configure FFmpeg to receive and decode raw YUV data directly from stdin.

To read raw YUV data from stdin, you must define the input parameters before specifying the input source. Use the hyphen symbol (-) as the input filename to tell FFmpeg to read from stdin.

Here is the standard command structure:

[source_command] | ffmpeg -f rawvideo -pixel_format yuv420p -video_size 1920x1080 -framerate 30 -i - output.mp4

Parameter Breakdown

Practical Example

If you have a raw YUV file named input.yuv and want to stream it through stdin to convert it to an MP4, run:

cat input.yuv | ffmpeg -f rawvideo -pixel_format yuv420p -video_size 1280x720 -framerate 24 -i - output.mp4

This configuration ensures FFmpeg accurately parses the incoming raw byte stream and processes it according to your exact specifications.