Gstreamer RTSP Server not working (SDP contains no streams)
这是我的 GstRtspServer 代码,现在应该只流式传输 mp4 文件:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | import gi gi.require_version('Gst', '1.0') gi.require_version('GstRtspServer', '1.0') from gi.repository import Gst, GObject, GstRtspServer GObject.threads_init() Gst.init(None) class RTSP_Server: def __init__(self): self.server = GstRtspServer.RTSPServer.new() self.address = '192.168.1.15' self.port = '8554' self.launch_description = '( playbin uri=file:///E://...sample_video.mp4 )' self.server.set_address(self.address) self.server.set_service(self.port) self.server.connect("client-connected",self.client_connected) self.factory = GstRtspServer.RTSPMediaFactory.new() self.factory.set_launch(self.launch_description) self.factory.set_shared(True) self.factory.set_transport_mode(GstRtspServer.RTSPTransportMode.PLAY) self.mount_points = self.server.get_mount_points() self.mount_points.add_factory('/video', self.factory) self.server.attach(None) print('Stream ready') GObject.MainLoop().run() def client_connected(self, arg1, arg2): print('Client connected') server = RTSP_Server() |
我运行它,得到 \\'Stream ready\\' 然后在命令行中输入:
1 | C:\\gstreamer\\1.0\\x86_64\\bin>gst-launch-1.0 rtspsrc location=rtsp://192.168.1.15:8554/video latency=0 ! decodebin ! autovideosink |
并收到这个:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | Setting pipeline to PAUSED ... Pipeline is live and does not need PREROLL ... Progress: (open) Opening Stream Progress: (connect) Connecting to rtsp://192.168.1.15:8554/video Progress: (open) Retrieving server options Progress: (open) Retrieving media info ERROR: from element /GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0: Could not get/set settings from/on resource. Additional debug info: gstrtspsrc.c(6845): gst_rtspsrc_setup_streams (): /GstPipeline:pipeline0/GstRTSP Src:rtspsrc0: SDP contains no streams ERROR: pipeline doesn't want to preroll. Setting pipeline to PAUSED ... Setting pipeline to READY ... Setting pipeline to NULL ... Freeing pipeline ... C:\\gstreamer\\1.0\\x86_64\\bin> |
此外,我在 Python 中收到了 \\'Client connected\\',视频的第一帧打开,片刻后关闭。
- Gst.parse_launch(\\'playbin uri=file:///E:/??/...sample_video.mp4\\') 工作正常 - (带有完整地址)
- VLC说无法打开rtsp://192.168.1.15:8554/video
- 我已经尝试在本地网络中的另一台计算机上启动它
- 也有 127.0.0.1
- 并无延迟地接收流=0!解码器!自动视频接收器
有什么问题?我期待着您的帮助!
您的服务器正在监听:
self.port = '554'
当您尝试播放端口 8554 时:
VLC says that it is impossible to open rtsp://192.168.1.15:8554/video