Gstreamer RTSP服务器不工作(SDP不包含流)

2024-04-25 21:29:15 发布

您现在位置:Python中文网/ 问答频道 /正文

下面是我的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”,然后输入命令行:

^{pr2}$

收到这个:

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_启动('playbin uri=file:///E://…示例_视频.mp4'工作正常-(带完整地址)
  • VLC说不可能打开rtsp://192.168.1.15:8554/视频
  • 我试过在本地网络的另一台计算机上启动它
  • 以及127.0.0.1
  • 无延迟接收流=0!解码箱!自动视频接收器

怎么了?我期待着你的帮助!在


Tags: tofromself视频pipelineserverfactorysetting
1条回答
网友
1楼 · 发布于 2024-04-25 21:29:15

您的服务器正在监听:

self.port = '554'

当您尝试播放端口8554时:

VLC says that it is impossible to open rtsp://192.168.1.15:8554/video

相关问题 更多 >

    热门问题