我正在尝试使用 RTSP 从无线摄像头接收实时 H264 流。相机IP是192.168.150.1,不需要认证。
由于我是在Windows下开发,所以我安装了Gstreamer 1.0 - 1.8.3,完整安装,所有插件以及安装过程中选择的所有内容。
当我尝试管道时
gst-launch-1.0 rtspsrc location="rtsp://192.168.150.1" latency=100 ! rtph264depay ! avdec_h264 ! autovideosink
我收到此输出:
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Progress: (open) Opening Stream
Progress: (connect) Connecting to rtsp://192.168.150.1
Progress: (open) Retrieving server options
Progress: (open) Retrieving media info
ERROR: from element /GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0: No supported stream was found. You might need to allow more transport protocols or may otherwise be missing the right GStreamer RTSP extension plugin.
Additional debug info:
gstrtspsrc.c(6421): gst_rtspsrc_setup_streams (): /GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0
ERROR: pipeline doesn't want to preroll.
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...
我还尝试了以下命令:
gst-play-1.0 rtsp://192.168.150.1
得到这个输出:
Interactive keyboard handling in terminal not available.
Now playing rtsp://192.168.150.1
Pipeline is live.
ERROR Your GStreamer installation is missing a plug-in. for rtsp://192.168.150.1
ERROR debug information: gsturidecodebin.c(1006): no_more_pads_full (): /GstPlayBin:playbin/GstURIDecodeBin:uridecodebin0:
no suitable plugins found:
gstrtspsrc.c(6421): gst_rtspsrc_setup_streams (): /GstPlayBin:playbin/GstURIDecodeBin:uridecodebin0/GstRTSPSrc:source
Reached end of play list.
当我在 VLC 中尝试相同的 URL (rtsp://192.168.150.1) 时,我可以看到该流。所以我的猜测是我缺少“正确的 GStreamer RTSP 扩展插件”
inspect-1.0 | grep 264
的输出为:
File STDIN:
x264: x264enc: x264enc
videoparsersbad: h264parse: H.264 parser
typefindfunctions: video/x-h264: h264, x264, 264
rtp: rtph264depay: RTP H264 depayloader
rtp: rtph264pay: RTP H264 payloader
openh264: openh264dec: OpenH264 video decoder
openh264: openh264enc: OpenH264 video encoder
libav: avdec_h264: libav H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 decoder
libav: avmux_ipod: libav iPod H.264 MP4 (MPEG-4 Part 14) muxer
我也尝试过使用 FFmpeg 并且可以看到视频,但我更喜欢使用 Gstreamer,因为我将在 Android 设备上使用相同的配置(相机、管道、gstreamer 库...),在我看来 Gstreamer 似乎成为最好的选择。
从 FFmpeg 我得到了有关流的信息
Stream #0:0: Video: h264 (Constrained Baseline), yuv420p, 640x352, 29.92 tbr, 90k tbn, 180k tbc
有人有一些建议来解决这个问题吗? 我缺少哪个插件?我如何添加到我的安装中?
编辑:
gst-launch-1.0.exe -v playbin uri=rtsp://192.168.150.1
的输出
Setting pipeline to PAUSED ...
/GstPlayBin:playbin0/GstURIDecodeBin:uridecodebin0: ring-buffer-max-size = 0
/GstPlayBin:playbin0/GstURIDecodeBin:uridecodebin0: buffer-size = -1
/GstPlayBin:playbin0/GstURIDecodeBin:uridecodebin0: buffer-duration = -1
/GstPlayBin:playbin0/GstURIDecodeBin:uridecodebin0: use-buffering = false
/GstPlayBin:playbin0/GstURIDecodeBin:uridecodebin0: download = false
/GstPlayBin:playbin0/GstURIDecodeBin:uridecodebin0: uri = rtsp://192.168.150.1
/GstPlayBin:playbin0/GstURIDecodeBin:uridecodebin0: connection-speed = 0
/GstPlayBin:playbin0/GstURIDecodeBin:uridecodebin0: source = "\(GstRTSPSrc\)\ source"
Pipeline is live and does not need PREROLL ...
Progress: (open) Opening Stream
Progress: (connect) Connecting to rtsp://192.168.150.1
Progress: (open) Retrieving server options
Progress: (open) Retrieving media info
ERROR: from element /GstPlayBin:playbin0/GstURIDecodeBin:uridecodebin0: Your GStreamer installation is missing a plug-in.
Additional debug info:
gsturidecodebin.c(1006): no_more_pads_full (): /GstPlayBin:playbin0/GstURIDecodeBin:uridecodebin0:
no suitable plugins found:
gstrtspsrc.c(6421): gst_rtspsrc_setup_streams (): /GstPlayBin:playbin0/GstURIDecodeBin:uridecodebin0/GstRTSPSrc:source
ERROR: pipeline doesn't want to preroll.
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...
我在 GStreamer/1.8.3 上遇到了完全相同的问题。
原因是我的相机在其会话描述中没有提供“控制 URL”属性,而 GStreamer 不够智能,无法在这种情况下回退到基本 URL(就像其他播放器一样)。
因此,我运行以下命令来从 GStreamer 获取详细日志:
gst-play-1.0 rtsp://camera_ip:port/ --gst-debug-level=9 --gst-debug-no-color &> GSTREAMER_LOGS.txt
在日志中我发现了这一行:
DEBUG rtspsrc gstrtspsrc.c:6109:gst_rtspsrc_setup_streams:<source> skipping stream 0x7f01b402c140, no setup
然后查看 Kurento 的 gst-plugins-good 包中当前的 gstrtspsrc.c 代码,我发现“跳过流...,没有设置”错误仅在
stream->conninfo.location == NULL
时发生。正如我所说,发生这种情况是因为我的相机没有在 SDP 中提供“控制 URL”属性。将以下行添加到我的相机 SDP 会话描述中解决了我的问题:
a=control:*
但是,一般来说,这可能需要在 GStreamer 代码中修复。
我相信这是 GStreamer 的一个限制,VLC 和 ffmpeg 没有共享。我这里也遇到了类似的情况,我有三个不同的 RTSP 摄像头,其中两个可以与 GStreamer 配合使用,另一个则不能。这三个都可以与 VLC 和 ffmpeg 配合使用。
我用Wireshark查看了原始RTSP协议,发现与GStreamer配合使用的两个摄像头都包含一个sprop-parameter-sets参数字段,而不起作用的则没有这个字段。
sprop-parameter-sets 中编码的信息(SPS 和 PPS 数据)通常存在于来自相机的 RTP 流中。显然,VLC 和 ffmpeg 足够聪明,可以识别这一点,但 GStreamer 却不然。
我尝试使用 caps 命令行参数手动插入 sprop-parameter-sets 数据,但没有成功。