如何使ffmpeg将其输出写入命名管道 [英] How to make ffmpeg write its output to a named pipe
问题描述
我知道我可以使ffmpeg
分别使用pipe:1
和pipe:2
作为output_file
参数将其输出输出到stdout
和stderr
. (文档)
I know i can make ffmpeg
put its output to stdout
and stderr
using pipe:1
and pipe:2
, respectively, as output_file
parameter. (Docs)
但是命名管道该怎么办,我可以使其写入一个管道吗?
But what about named pipes, can i make it write to one?
如果没有,是否可以将stdout
中的数据重定向到Linux中的命名管道? (类似于ffmpeg <parameters> | pipe123
)
If not, is there a way to redirect the data in stdout
to a named pipe in Linux? (something like ffmpeg <parameters> | pipe123
)
This question is a follow-up of this question.
推荐答案
您可以先创建一个命名管道,并使用以下方法将ffmpeg
写入命名管道:
You could create a named pipe first and have ffmpeg
write to it using the following approach:
ffmpeg
输出到命名管道:
# mkfifo outpipe
# ffmpeg -i input_file.avi -f avi pipe:1 > outpipe
FFmpeg version 0.6.5, Copyright (c) 2000-2010 the FFmpeg developers
built on Jan 29 2012 17:52:15 with gcc 4.4.5 20110214 (Red Hat 4.4.5-6)
...
[avi @ 0x1959670]non-interleaved AVI
Input #0, avi, from 'input_file.avi':
Duration: 00:00:34.00, start: 0.000000, bitrate: 1433 kb/s
Stream #0.0: Video: cinepak, yuv420p, 320x240, 15 tbr, 15 tbn, 15 tbc
Stream #0.1: Audio: pcm_u8, 22050 Hz, 1 channels, u8, 176 kb/s
Output #0, avi, to 'pipe:1':
Metadata:
ISFT : Lavf52.64.2
Stream #0.0: Video: mpeg4, yuv420p, 320x240, q=2-31, 200 kb/s, 15 tbn, 15 tbc
Stream #0.1: Audio: mp2, 22050 Hz, 1 channels, s16, 64 kb/s
Stream mapping:
Stream #0.0 -> #0.0
Stream #0.1 -> #0.1
Press [q] to stop encoding
frame= 510 fps= 0 q=11.5 Lsize= 1292kB time=33.96 bitrate= 311.7kbits/s
video:1016kB audio:265kB global headers:0kB muxing overhead 0.835379%
读取outpipe
命名管道(Python
示例):
reading outpipe
named pipe (Python
example):
# python -c "import os; fifo_read = open('outpipe', 'r', 0); print fifo_read.read().splitlines()[0]"
RIFFAVI LIST<hdrlavih8j...
...
-ab1
这篇关于如何使ffmpeg将其输出写入命名管道的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!