【发布时间】:2016-03-22 20:44:21
【问题描述】:
这是我的 GstRtspServer 代码,现在应该只是流式传输 mp4 文件:
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”,然后输入命令行:
C:\gstreamer\1.0\x86_64\bin>gst-launch-1.0 rtspsrc location=rtsp://192.168.1.15:8554/video latency=0 ! decodebin ! autovideosink
然后收到这个:
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 中收到“客户端已连接”,视频的第一帧打开,然后在片刻后关闭。
- Gst.parse_launch('playbin uri=file:///E://...sample_video.mp4') 工作正常 - (带有完整地址)
- VLC说无法打开rtsp://192.168.1.15:8554/video
- 我已尝试在本地网络中的另一台计算机上启动它
- 127.0.0.1 也是如此
- 并且接收没有延迟的流=0!解码器!自动视频接收器
有什么问题?我期待您的帮助!
【问题讨论】:
标签: python server video-streaming gstreamer rtsp