使用ffmpeg和ffserver创建2x1实时流失败,输出错误未连接

时间:2017-06-25 20:44:29

标签: ffmpeg camera rtsp ffserver cctv

我想将2个RTSP流(CCTV摄像机)组合成一个水平的2x1条带并转换为webm,以便在HTML5网页中使用。

我能够轻松地将流转换为mpeg或avi文件,但是当我尝试将其发布到ffserver ffm feed时,我就碰壁了。

这是我的工作ffmpeg命令,它写出一个文件:

ffmpeg -rtsp_transport tcp -thread_queue_size 12 -i "rtsp://192.168.1.132:554/user=admin&password=mypassword&channel=1&stream=1.sdp" -i "rtsp://192.168.1.132:554/user=admin&password=mypassword&channel=2&stream=1.sdp" -filter_complex "[0:v][1:v] hstack=inputs=2 [v]" -map "[v]" -r 30 output.mpg

似乎ffmpeg进程正在输出两个流,其中一个是MPEG?在上面的命令中,我不得不将一个帧率“-r 30”放入命令,否则我得到一个错误,表示MPEG 1/2不支持5/1的帧率?

当我尝试流式传输到ffserver时,我收到一个错误:

ffmpeg -rtsp_transport tcp -thread_queue_size 12 -i "rtsp://192.168.1.132:554/user=admin&password=mypassword&channel=1&stream=1.sdp" -i "rtsp://192.168.1.132:554/user=admin&password=mypassword&channel=2&stream=1.sdp" -filter_complex "[0:v][1:v] hstack=inputs=2 [v]" -map "[v]" -r 30 http://localhost:8090/feed5.ffm

我得到的错误是“过滤器hstack有一个未连接的输出”:

ffmpeg version N-86111-ga441aa90e8-static http://johnvansickle.com/ffmpeg/  Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 5.4.1 (Debian 5.4.1-8) 20170304
  configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc-5 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gray --enable-libass --enable-libfreetype --enable-libfribidi --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libzimg
  libavutil      55. 63.100 / 55. 63.100
  libavcodec     57. 96.101 / 57. 96.101
  libavformat    57. 72.101 / 57. 72.101
  libavdevice    57.  7.100 / 57.  7.100
  libavfilter     6. 89.101 /  6. 89.101
  libswscale      4.  7.101 /  4.  7.101
  libswresample   2.  8.100 /  2.  8.100
  libpostproc    54.  6.100 / 54.  6.100
Input #0, rtsp, from 'rtsp://192.168.1.132:554/user=admin&password=mypassword&channel=1&stream=1.sdp':
  Duration: N/A, start: 0.166667, bitrate: N/A
    Stream #0:0: Video: h264 (High), yuv420p(progressive), 352x288, 6 fps, 6 tbr, 90k tbn, 180k tbc
Input #1, rtsp, from 'rtsp://192.168.1.132:554/user=admin&password=mypassword&channel=2&stream=1.sdp':
  Duration: N/A, start: 0.166667, bitrate: N/A
    Stream #1:0: Video: h264 (High), yuv420p(progressive), 352x288, 6 fps, 6 tbr, 90k tbn, 180k tbc
Filter hstack has an unconnected output

我的ffserver conf非常基础:

HTTPPort 8090
HTTPBindAddress 0.0.0.0
MaxHTTPConnections 2000
MaxClients 1000
MaxBandwidth 100000
CustomLog -

<Feed feed5.ffm>
File /mnt/ramdisk/feed5.ffm
Truncate
FileMaxSize 5M
ACL allow 127.0.0.1
</Feed>

<Stream feed5.webm>
     Format webm
     Feed feed5.ffm
     VideoCodec libvpx
     VideoSize 640x360
     NoAudio
   AVOptionVideo quality realtime
   StartSendOnKey
   VideoBitRate 140
</Stream>

<Stream status.html>
Format status
ACL allow localhost
ACL allow 192.168.0.0 192.168.255.255
</Stream>
<Redirect index.html>
URL http://www.ffmpeg.org/
</Redirect>

编辑:

以上是ffmpeg命令的调试输出:

ffmpeg -v debug -rtsp_transport tcp -thread_queue_size 12 -i "rtsp://192.168.1.132:554/user=admin&password=mypassword&channel=1&stream=1.sdp" -i "rtsp://192.168.1.132:554/user=admin&password=mypassword&channel=2&stream=1.sdp" -filter_complex "[0:v][1:v] hstack=inputs=2 [v]" -map "[v]" -r 30 http://localhost:8090/feed5.ffm
ffmpeg version N-86111-ga441aa90e8-static http://johnvansickle.com/ffmpeg/  Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 5.4.1 (Debian 5.4.1-8) 20170304
  configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc-5 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gray --enable-libass --enable-libfreetype --enable-libfribidi --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libzimg
  libavutil      55. 63.100 / 55. 63.100
  libavcodec     57. 96.101 / 57. 96.101
  libavformat    57. 72.101 / 57. 72.101
  libavdevice    57.  7.100 / 57.  7.100
  libavfilter     6. 89.101 /  6. 89.101
  libswscale      4.  7.101 /  4.  7.101
  libswresample   2.  8.100 /  2.  8.100
  libpostproc    54.  6.100 / 54.  6.100
Splitting the commandline.
Reading option '-v' ... matched as option 'v' (set logging level) with argument 'debug'.
Reading option '-rtsp_transport' ... matched as AVOption 'rtsp_transport' with argument 'tcp'.
Reading option '-thread_queue_size' ... matched as option 'thread_queue_size' (set the maximum number of queued packets from the demuxer) with argument '12'.
Reading option '-i' ... matched as input url with argument 'rtsp://192.168.1.132:554/user=admin&password=mypassword&channel=1&stream=1.sdp'.
Reading option '-i' ... matched as input url with argument 'rtsp://192.168.1.132:554/user=admin&password=mypassword&channel=2&stream=1.sdp'.
Reading option '-filter_complex' ... matched as option 'filter_complex' (create a complex filtergraph) with argument '[0:v][1:v] hstack=inputs=2 [v]'.
Reading option '-map' ... matched as option 'map' (set input stream mapping) with argument '[v]'.
Reading option '-r' ... matched as option 'r' (set frame rate (Hz value, fraction or abbreviation)) with argument '30'.
Reading option 'http://localhost:8090/feed5.ffm' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option v (set logging level) with argument debug.
Applying option filter_complex (create a complex filtergraph) with argument [0:v][1:v] hstack=inputs=2 [v].
Successfully parsed a group of options.
Parsing a group of options: input url rtsp://192.168.1.132:554/user=admin&password=mypassword&channel=1&stream=1.sdp.
Applying option thread_queue_size (set the maximum number of queued packets from the demuxer) with argument 12.
Successfully parsed a group of options.
Opening an input file: rtsp://192.168.1.132:554/user=admin&password=mypassword&channel=1&stream=1.sdp.
[tcp @ 0x58fb5e0] No default whitelist set
[rtsp @ 0x58f9700] SDP:
v=0
o=- 38990265062388 38990265062388 IN IP4 192.168.1.132
a=range:npt=0-
m=video 0 RTP/AVP 96
c=IN IP4 0.0.0.0
a=rtpmap:96 H264/90000
a=framerate:0S
a=fmtp:96 profile-level-id=640014; packetization-mode=1; sprop-parameter-sets=Z2QAFK2EAQwgCGEAQwgCGEAQwgCEK1CwSyA=,aO48sA==
a=control:trackID=3

Failed to parse interval end specification ''
[rtsp @ 0x58f9700] video codec set to: h264
[rtsp @ 0x58f9700] RTP Profile IDC: 64 Profile IOP: 0 Level: 14
[rtsp @ 0x58f9700] RTP Packetization Mode: 1
[rtsp @ 0x58f9700] Extradata set to 0x58fb940 (size: 38)
[rtsp @ 0x58f9700] setting jitter buffer size to 0
[rtsp @ 0x58f9700] hello state=0
[h264 @ 0x58fca00] nal_unit_type: 7, nal_ref_idc: 3
[h264 @ 0x58fca00] nal_unit_type: 8, nal_ref_idc: 3
[h264 @ 0x58fca00] nal_unit_type: 7, nal_ref_idc: 3
[h264 @ 0x58fca00] nal_unit_type: 8, nal_ref_idc: 3
[h264 @ 0x58fca00] unknown SEI type 229
[h264 @ 0x58fca00] nal_unit_type: 7, nal_ref_idc: 3
[h264 @ 0x58fca00] nal_unit_type: 8, nal_ref_idc: 3
[h264 @ 0x58fca00] nal_unit_type: 6, nal_ref_idc: 0
[h264 @ 0x58fca00] nal_unit_type: 5, nal_ref_idc: 3
[h264 @ 0x58fca00] unknown SEI type 229
[h264 @ 0x58fca00] Reinit context to 352x288, pix_fmt: yuv420p
[h264 @ 0x58fca00] nal_unit_type: 1, nal_ref_idc: 3
    Last message repeated 5 times
[h264 @ 0x58fca00] unknown SEI type 229
    Last message repeated 1 times
[rtsp @ 0x58f9700] All info found
[rtsp @ 0x58f9700] Setting avg frame rate based on r frame rate
Input #0, rtsp, from 'rtsp://192.168.1.132:554/user=admin&password=mypassword&channel=1&stream=1.sdp':
  Duration: N/A, start: 0.166667, bitrate: N/A
    Stream #0:0, 28, 1/90000: Video: h264 (High), 1 reference frame, yuv420p(progressive, left), 352x288, 0/1, 6 fps, 6 tbr, 90k tbn, 180k tbc
Successfully opened the file.
Parsing a group of options: input url rtsp://192.168.1.132:554/user=admin&password=mypassword&channel=2&stream=1.sdp.
Successfully parsed a group of options.
Opening an input file: rtsp://192.168.1.132:554/user=admin&password=mypassword&channel=2&stream=1.sdp.
[tcp @ 0x59f4280] No default whitelist set
[rtsp @ 0x59f7620] SDP:
v=0
o=- 38990265062388 38990265062388 IN IP4 192.168.1.132
a=range:npt=0-
m=video 0 RTP/AVP 96
c=IN IP4 0.0.0.0
a=rtpmap:96 H264/90000
a=framerate:0S
a=fmtp:96 profile-level-id=640014; packetization-mode=1; sprop-parameter-sets=Z2QAFK2EAQwgCGEAQwgCGEAQwgCEK1CwSyA=,aO48sA==
a=control:trackID=3

Failed to parse interval end specification ''
[rtsp @ 0x59f7620] video codec set to: h264
[rtsp @ 0x59f7620] RTP Profile IDC: 64 Profile IOP: 0 Level: 14
[rtsp @ 0x59f7620] RTP Packetization Mode: 1
[rtsp @ 0x59f7620] Extradata set to 0x59f3670 (size: 38)
[rtp @ 0x59f62a0] No default whitelist set
[udp @ 0x58fb6a0] No default whitelist set
[udp @ 0x58fb6a0] end receive buffer size reported is 131072
[udp @ 0x591b940] No default whitelist set
[udp @ 0x591b940] end receive buffer size reported is 131072
[rtsp @ 0x59f7620] setting jitter buffer size to 500
[rtsp @ 0x59f7620] hello state=0
[h264 @ 0x59e4b20] nal_unit_type: 7, nal_ref_idc: 3
[h264 @ 0x59e4b20] nal_unit_type: 8, nal_ref_idc: 3
[h264 @ 0x59e4b20] nal_unit_type: 7, nal_ref_idc: 3
[h264 @ 0x59e4b20] nal_unit_type: 8, nal_ref_idc: 3
[h264 @ 0x59e4b20] unknown SEI type 229
[h264 @ 0x59e4b20] nal_unit_type: 7, nal_ref_idc: 3
[h264 @ 0x59e4b20] nal_unit_type: 8, nal_ref_idc: 3
[h264 @ 0x59e4b20] nal_unit_type: 6, nal_ref_idc: 0
[h264 @ 0x59e4b20] nal_unit_type: 5, nal_ref_idc: 3
[h264 @ 0x59e4b20] unknown SEI type 229
[h264 @ 0x59e4b20] Reinit context to 352x288, pix_fmt: yuv420p
[h264 @ 0x59e4b20] nal_unit_type: 1, nal_ref_idc: 3
    Last message repeated 5 times
[h264 @ 0x59e4b20] unknown SEI type 229
    Last message repeated 1 times
[rtsp @ 0x59f7620] All info found
[rtsp @ 0x59f7620] Setting avg frame rate based on r frame rate
Input #1, rtsp, from 'rtsp://192.168.1.132:554/user=admin&password=mypassword&channel=2&stream=1.sdp':
  Duration: N/A, start: 0.166667, bitrate: N/A
    Stream #1:0, 28, 1/90000: Video: h264 (High), 1 reference frame, yuv420p(progressive, left), 352x288, 0/1, 6 fps, 6 tbr, 90k tbn, 180k tbc
Successfully opened the file.
detected 2 logical cores
[Parsed_hstack_0 @ 0x59f7cc0] Setting 'inputs' to value '2'
Parsing a group of options: output url http://localhost:8090/feed5.ffm.
Applying option map (set input stream mapping) with argument [v].
Applying option r (set frame rate (Hz value, fraction or abbreviation)) with argument 30.
Successfully parsed a group of options.
Opening an output file: http://localhost:8090/feed5.ffm.
[http @ 0x59aa700] Setting default whitelist 'http,https,tls,rtp,tcp,udp,crypto,httpproxy'
[http @ 0x59aa700] request: GET /feed5.ffm HTTP/1.1
User-Agent: Lavf/57.72.101
Accept: */*
Range: bytes=0-
Connection: close
Host: localhost:8090
Icy-MetaData: 1


[ffm @ 0x5917d00] Format ffm probed with size=2048 and score=101
[NULL @ 0x5bce3e0] Setting entry with key 'video_size' to value '640x360'
[NULL @ 0x5bce3e0] Setting entry with key 'b' to value '140000'
[NULL @ 0x5bce3e0] Setting entry with key 'time_base' to value '1/5'
[NULL @ 0x5bce3e0] Setting entry with key 'bt' to value '35000'
[NULL @ 0x5bce3e0] Setting entry with key 'rc_eq' to value 'tex^qComp'
[NULL @ 0x5bce3e0] Setting entry with key 'maxrate' to value '280000'
[NULL @ 0x5bce3e0] Setting entry with key 'bufsize' to value '280000'
[AVIOContext @ 0x5915b80] Statistics: 4096 bytes read, 0 seeks
[http @ 0x5915f00] Setting default whitelist 'http,https,tls,rtp,tcp,udp,crypto,httpproxy'
[http @ 0x5915f00] request: POST /feed5.ffm HTTP/1.1
Transfer-Encoding: chunked
User-Agent: Lavf/57.72.101
Accept: */*
Connection: close
Host: localhost:8090
Icy-MetaData: 1


Successfully opened the file.
Filter hstack has an unconnected output
[AVIOContext @ 0x59ab080] Statistics: 0 seeks, 0 writeouts

我很难过 - 任何线索?

提前致谢。

0 个答案:

没有答案