How to make ffmpeg write its output to a named pipe

后端 未结 2 990
孤独总比滥情好
孤独总比滥情好 2021-01-03 04:35

I know i can make ffmpeg put its output to stdout and stderr using pipe:1 and pipe:2, respectively, as

2条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-03 04:56

    You could create a named pipe first and have ffmpeg write to it using the following approach:

    ffmpeg output to named pipe:

    # 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%
    

    reading outpipe named pipe (Python example):

    # python -c "import os; fifo_read = open('outpipe', 'r', 0); print fifo_read.read().splitlines()[0]"
    RIFFAVI LIST

    -- ab1

提交回复
热议问题