Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Changing gstreamer pipeline to opencv in python

Trying to change this gstreamer pipline to python for opencv but having a few issues

gst-launch-1.0 -v playbin uri=rtsp://admin:[email protected]:554/Streaming/Channels/400 uridecodebin0::source::latency=10

This is the script I've referenced and managed to write, however I keep on getting this error

import cv2
import numpy as np

pipe = '"rtspsrc location=\"rtsp://admin:[email protected]:554/Streaming/Channels/400" latency=10 ! appsink'

cap = cv2.VideoCapture(pipe)

if not cap.isOpened():
    print('VideoCapture not opened')
    exit(0)

while True:
    ret, frame = cap.read()

    if not ret:
        print('empty frame')
        break

    cv2.imshow('display', frame)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break
    cap.release()

cv2.destroyAllWindows()

Error:

GStreamer-CRITICAL **: 09:06:55.638: gst_element_get_state: assertion 'GST_IS_ELEMENT (element)' failed

Changing gstreamer pipeline to opencv in python

Trying to change this gstreamer pipline to python for opencv but having a few issues

gst-launch-1.0 -v playbin uri=rtsp://admin:[email protected]:554/Streaming/Channels/400 uridecodebin0::source::latency=10

This is the script I've referenced and managed to write, however I keep on getting this error

import cv2
import numpy as np

pipe = '"rtspsrc location=\"rtsp://admin:[email protected]:554/Streaming/Channels/400" latency=10 ! appsink'

cap = cv2.VideoCapture(pipe)

if not cap.isOpened():
    print('VideoCapture not opened')
    exit(0)

while True:
    ret, frame = cap.read()

    if not ret:
        print('empty frame')
        break

    cv2.imshow('display', frame)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break
    cap.release()

cv2.destroyAllWindows()

Error:

GStreamer-CRITICAL **: 09:06:55.638: gst_element_get_state: assertion 'GST_IS_ELEMENT (element)' failed