管道输入到ffmpeg [英] Pipe input in to ffmpeg
问题描述
我正在尝试使用ffmpeg解码音频数据.虽然它可以从文件加载,但我想避免使用文件,因为这样做意味着我将不得不使用临时文件.取而代之的是,我想使用stdin传递数据(我之前已经加载过).
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具有特殊的管道标志,该标志指示程序使用stdin. 请注意,几乎总是需要明确定义输入格式.
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位Little-endian格式):
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:
pipe docs are here
supported audio types are here
这篇关于管道输入到ffmpeg的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!