乐闻世界logo
搜索文章和话题

Which file formats of ffmpeg support the use of stdin?

1个答案

1

When using FFmpeg for video and audio processing, file formats supporting stdin input are primarily those that do not depend on file size or container-specific metadata. Typically, these formats are streaming-based, such as Transport Stream (TS) or raw formats like PCM audio or raw video data. This is because these formats enable continuous reading and processing of data without requiring seeks to specific file positions.

Common file formats supporting stdin input include:

  1. MPEG Transport Stream (TS) - This format is widely used for digital video broadcasting and live streaming, and it is well-suited for piping.

  2. Raw audio formats (e.g., PCM) - This format lacks file headers and metadata, with continuous data streams, making it ideal for reading from standard input.

  3. Raw video formats - Similar to raw audio, raw video (typically in YUV or RGB formats) can be streamed through stdin as they consist of continuous video frame data.

Example

If you have a live video data stream that you want to encode or convert using FFmpeg, you can use the following command to pipe the data into FFmpeg:

bash
cat input.yuv | ffmpeg -f rawvideo -pixel_format yuv420p -video_size 1920x1080 -i - -c:v libx264 output.mp4

In this example, the cat input.yuv command reads data from a raw YUV video file and pipes it into FFmpeg. FFmpeg reads the input stream from stdin using the -i - option. The -f rawvideo option specifies that the input format is raw video data.

Important considerations

When using stdin, ensure you fully understand the data format and correctly set FFmpeg's input parameters (such as format -f, video size -video_size, pixel format -pixel_format, etc.), as FFmpeg cannot automatically detect these parameters from stdin. Additionally, the input data must be streamable; otherwise, it may result in processing failures or data corruption.

2024年8月14日 23:58 回复

你的答案