如何使ffmpeg将其输出写入命名管道

Bas*_*022 2 linux ffmpeg pipe

我知道我可以ffmpeg把它的输出stdout和stderr使用pipe:1,并pipe:2分别作为output_file参数.(文件)

但是命名管道呢,我可以写一个吗?

如果没有,有没有办法将数据重定向stdout到Linux中的命名管道?(像ffmpeg <parameters> | pipe123)

这个问题是这个问题的后续问题.

ab7*_*b77 13

您可以先创建一个命名管道ffmpeg,然后使用以下方法写入它:

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%
Run Code Online (Sandbox Code Playgroud)

读取outpipe命名管道(Python示例):

# python -c "import os; fifo_read = open('outpipe', 'r', 0); print fifo_read.read().splitlines()[0]"
RIFFAVI LIST<hdrlavih8j...
...
Run Code Online (Sandbox Code Playgroud)

- ab1