Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x GStreamer rtsp管道在cv2.VideoCapture中冻结,可能与音频通道有关_Python 3.x_Gstreamer_Rtsp - Fatal编程技术网

Python 3.x GStreamer rtsp管道在cv2.VideoCapture中冻结,可能与音频通道有关

Python 3.x GStreamer rtsp管道在cv2.VideoCapture中冻结,可能与音频通道有关,python-3.x,gstreamer,rtsp,Python 3.x,Gstreamer,Rtsp,我正在使用python+gstreamer连接到DVR rtsp提要,以便使用opencv2进行图像处理。 在cv2.VideoCapture上使用gstreamer管道时,连接会冻结(可能在等待信号)。rtsp提要由h264视频(我要处理)+pcma音频(我要丢弃)组成 以下是功能-它在cv2.VideoCapture线上冻结: def simple_test2(): rtsp_path = 'rtsp://admin:XXXX@10.0.0.50:554/cam/realmonito

我正在使用python+gstreamer连接到DVR rtsp提要,以便使用opencv2进行图像处理。 在cv2.VideoCapture上使用gstreamer管道时,连接会冻结(可能在等待信号)。rtsp提要由h264视频(我要处理)+pcma音频(我要丢弃)组成

以下是功能-它在cv2.VideoCapture线上冻结:

def simple_test2():
    rtsp_path = 'rtsp://admin:XXXX@10.0.0.50:554/cam/realmonitor?channel=1&subtype=0'
    rtsp_path2 = 'rtspsrc location="{}" ! decodebin name=dcd dcd. ! videoconvert ! appsink max-buffers=1 drop=true dcd. ! audioconvert ! fakesink '.format(rtsp_path)
    logging.info('connecting to {} : {} '.format(cc['name'],rtsp_path2))
    vcap = cv2.VideoCapture(rtsp_path2)
    for i in range(2):
        logging.info('read frame #%s' % i )
        succ, frame = vcap.read()
        if succ:
            logging.info('%s  got frame %d : %s open? %s' % (cc['name'], i, str(frame.shape[0:2]),str(vcap.isOpened())))
        else:
            logging.info('%s fail frame %d open? %s' % (cc['name'], i,str(vcap.isOpened())))
        time.sleep(1)
    vcap.release()
进一步调查:

1) 奇怪的是,在gst启动中运行相同的管道可以正常工作

   gst-launch-1.0 -v rtspsrc location="rtsp://admin:XXXX@10.0.0.50:554/cam/realmonitor?channel=2&subtype=0" ! decodebin name=dcd dcd. ! videoconvert ! appsink max-buffers=1 drop=true dcd. ! audioconvert ! fakesink
返回源源不断的日志消息

2) 如果我使用更简单的管道,在代码中,例如:

rtspsrc location="{}" ! decodebin ! videoconvert ! appsink max-buffers=1 drop=true 
我最终得到的连接错误与音频垫无法链接有关,这就是为什么我尝试使用fakesink丢弃音频。其他办法将不胜感激

3) 我还试着添加!队列插件在不同的地方和组合。没什么帮助