FFMPEG 通过 netcat 从管道接收流失败

FFMPEG 通过 netcat 从管道接收流失败

我正在尝试通过 netcat 接收流并将其传送到 FFMPEG 然后输出到文件,但出现了错误。

我尝试过的最基本的命令是:

$ nc -l -p 1935 | ffmpeg -v debug -y -f h264 -i pipe:0 out.mp4

ffmpeg version 3.1 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 4.8.2 (GCC)
  configuration: --prefix=/pkg/ffmpeg.org/3.1/ffmpeg --libdir=/usr/lib64 --shlibdir=/usr/lib64 --incdir=/usr/include --enable-gpl --enable-libx264 --enable-shared --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopus --enable-libschroedinger --enable-libtheora --enable-libvorbis --enable-libx264 --enable-postproc --enable-runtime-cpudetect --enable-memalign-hack --enable-pthreads --disable-x11grab --enable-bzlib --enable-zlib --enable-static --enable-libmp3lame --enable-libx264 --enable-librtmp
  libavutil      55. 27.100 / 55. 27.100
  libavcodec     57. 48.101 / 57. 48.101
  libavformat    57. 40.101 / 57. 40.101
  libavdevice    57.  0.101 / 57.  0.101
  libavfilter     6. 46.102 /  6. 46.102
  libswscale      4.  1.100 /  4.  1.100
  libswresample   2.  1.100 /  2.  1.100
  libpostproc    54.  0.100 / 54.  0.100
Splitting the commandline.
Reading option '-v' ... matched as option 'v' (set logging level) with argument 'debug'.
Reading option '-y' ... matched as option 'y' (overwrite output files) with argument '1'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'h264'.
Reading option '-i' ... matched as input file with argument 'pipe:0'.
Reading option 'out.mp4' ... matched as output file.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option v (set logging level) with argument debug.
Applying option y (overwrite output files) with argument 1.
Successfully parsed a group of options.
Parsing a group of options: input file pipe:0.
Applying option f (force format) with argument h264.
Successfully parsed a group of options.
Opening an input file: pipe:0.
[pipe @ 0xe79c80] Setting default whitelist 'crypto'
[h264 @ 0xe794c0] Before avformat_find_stream_info() pos: 0 bytes read:1537 seeks:0 nb_streams:1
[h264 @ 0xe82b00] sps_id 5 out of range
[h264 @ 0xe82b00] missing picture in access unit with size 1537
[h264 @ 0xe82b00] Invalid NAL unit 0, skipping.
[h264 @ 0xe82b00] no frame!
[h264 @ 0xe794c0] decoding for stream 0 failed
[h264 @ 0xe794c0] Could not find codec parameters for stream 0 (Video: h264, 1 reference frame, none(left)): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[h264 @ 0xe794c0] After avformat_find_stream_info() pos: 1537 bytes read:1537 seeks:0 frames:1
Input #0, h264, from 'pipe:0':
  Duration: N/A, bitrate: N/A
    Stream #0:0, 1, 1/1200000: Video: h264, 1 reference frame, none(left), 25 tbr, 1200k tbn, 50 tbc
Successfully opened the file.
Parsing a group of options: output file out.mp4.
Successfully parsed a group of options.
Opening an output file: out.mp4.
[file @ 0xe925c0] Setting default whitelist 'file,crypto'
Successfully opened the file.
detected 1 logical cores


[graph 0 input from stream 0:0 @ 0xe9ac60] Setting 'video_size' to value '0x0'
[buffer @ 0xe9ad60] Unable to parse option value "0x0" as image size
[graph 0 input from stream 0:0 @ 0xe9ac60] Setting 'pix_fmt' to value '-1'
[buffer @ 0xe9ad60] Unable to parse option value "-1" as pixel format
[graph 0 input from stream 0:0 @ 0xe9ac60] Setting 'time_base' to value '1/1200000'
[graph 0 input from stream 0:0 @ 0xe9ac60] Setting 'pixel_aspect' to value '0/1'
[graph 0 input from stream 0:0 @ 0xe9ac60] Setting 'sws_param' to value 'flags=2'
[graph 0 input from stream 0:0 @ 0xe9ac60] Setting 'frame_rate' to value '50/2'
[buffer @ 0xe9ad60] Unable to parse option value "0x0" as image size
[buffer @ 0xe9ad60] Error setting option video_size to value 0x0.
[graph 0 input from stream 0:0 @ 0xe9ac60] Error applying options to the filter.
Error opening filters!
[AVIOContext @ 0xe9a700] Statistics: 0 seeks, 0 writeouts
[AVIOContext @ 0xe82000] Statistics: 1537 bytes read, 0 seeks

由于收到该Consider increasing the value for the 'analyzeduration' and 'probesize' options消息,我随后尝试:

nc -l -p 1935 | ffmpeg -v debug -y -f h264 -analyzeduration 9M -probesize 9M -i pipe:0 out.mp4

我遇到了同样的错误,所以我开始添加自己的编解码器参数,因为它似乎无法确定它是什么类型的流。

nc -l -p 1935 | ffmpeg -v debug -y -f h264 -c:a aac -pix_fmt yuv420p -s 1280x720 -framerate 30 -analyzeduration 9M -probesize 9M -i pipe:0 out.mp4

但现在我得到:

Option video_size not found.

有任何想法吗?

相关内容