管道输入到 ffmpeg 标准输入 [英] Pipe input in to ffmpeg stdin
问题描述
我正在尝试使用 ffmpeg 来解码音频数据.虽然它可以从文件加载,但我想避免使用文件,因为这样做意味着我必须使用临时文件.相反,我想使用标准输入输入数据(我之前加载过).
I am trying to use ffmpeg to decode audio data. While it works to load from a file, I would like to avoid using files because to do so, means I would have to use a temporary. Instead, I'd like to pipe in the data(which I've previously loaded) using stdin.
这可能吗?
例如
- 手动加载 mp3 文件
- 将其导入 ffmpeg 生成的进程
- 获取原始输出
(它也适用于 ffprobe 和 ffplay)
(it should work with ffprobe and ffplay also)
推荐答案
ffmpeg 有一个特殊的管道标志,指示程序使用标准输入.请注意,几乎总是需要明确定义输入格式.
ffmpeg has a special pipe flag that instructs the program to consume stdin. note that almost always the input format needs to be defined explicitly.
示例(输出采用 PCM 有符号的 16 位小端格式):
example (output is in PCM signed 16-bit little-endian format):
cat file.mp3 | ffmpeg -f mp3 -i pipe: -c:a pcm_s16le -f s16le pipe:
这篇关于管道输入到 ffmpeg 标准输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!