Gstreamer rstpsrc 错误:Option not supported (551) 原因及解决办法

发布时间 2023-11-13 16:53:40作者: zhouyuchong

错误产生条件 How to reproduce:

Gstreamer中使用rtspsrc作为输入源播放时,如果摄像头(rtsp server)是如海康(HiKVision)之类的,在尝试断流时,Gstreamer会发送一个GST.PAUSE信号。但是此类摄像头并不支持该操作(没有暂停状态),正确的操作应该是TearDown,参考官方issue

解决方法目前发现两个。

Solution 1:

重写Bus_call回调函数,在遇到这类错误码时忽略。

Solution 2:

使用before_send信号,并在回调函数中直接返回。

source_bin.connect("before-send", self._drop_send_signal)
def _drop_send_signal(self, message, data):
    '''
    Emitted before each RTSP request is sent, in order to allow the application to modify send parameters or to skip the message entirely.
    '''
    print("Delete rtsp source, drop the PAUSE signal to avoid error.")
    return False

该方法确实能避免报错,但是实测中发现,这样的话并不能断流。抓包工具可以看到rtsp server仍然在源源不断得传输数据过来


慎用!!!


Solution 3

修改源码并编译,笔者并未实践验证此方法,来源。不过好像高版本的Gstreamer已经修复这个bug。不过因为项目开发需求,无法使用最新版本的Gstreamer,所以愿读者实践出真知。