Hi,
I’m trying to deploy RTSP streming server with OpenCv and Gstreamer. I have follow the instructions of this link to build from source with Gstreamer
.
I’m trying to do that with a simple example.
import os
os.add_dll_directory("C:\\gstreamer\\1.0\\msvc_x86_64\\bin")
os.add_dll_directory("C:\\gstreamer\\1.0\\msvc_x86_64\\lib\\gstreamer-1.0")
import cv2 as cv
import numpy
sourceUrl = "http://pendelcam.kip.uni-heidelberg.de/mjpg/video.mjpg"
#command = "appsrc ! videoconvert ! x264enc ! rtph264pay ! udpsink port=5004 host=127.0.0.1 "
command = "appsrc ! video/x-raw, format=BGR ! queue ! videoconvert ! video/x-raw, format=BGRx ! videoconvert ! x264enc speed-preset=veryfast tune=zerolatency bitrate=800 insert-vui=1 ! h264parse ! rtph264pay name=pay0 pt=96 config-interval=1 ! udpsink port=5004 host=127.0.0.1 auto-multicast=0"
cap = cv.VideoCapture(sourceUrl)
if not cap.isOpened():
print("Capture Not Opened")
writer = cv.VideoWriter(command, cv.CAP_GSTREAMER, 0, 30, (1280, 720), True)
if not writer.isOpened():
print("WRITER NOT OPENED!!!!!")
if cap.isOpened() and writer.isOpened():
while True:
ret, frame = cap.read()
if not ret:
print("Not Fram received")
break
cv.imshow("frame", frame)
if cv.waitKey(1) > 0:
break
cap.release()
writer.release()
And I have the following output. It seems that Gstreamer cant find dependencies event that I have added dll directories of Gstreamer.
Any idea on how to solve that? At this moment I can’t difference from gstreamer errors on pipeline syntax and gstreamer dependency errors.
(python.exe:6512): GStreamer-WARNING **: 17:18:56.512: Failed to load plugin 'C:\gstreamer\1.0\msvc_x86_64\lib\gstreamer-1.0\gstx264.dll': The specified module could not be found.
This usually means Windows was unable to find a DLL dependency of the plugin. Please check that PATH is correct.
You can run 'dumpbin -dependents' (provided by the Visual Studio developer prompt) to list the DLL deps of any DLL.
There are also some third-party GUIs to list and debug DLL dependencies recursively.
(python.exe:6512): GStreamer-CRITICAL **: 17:18:56.512: gst_element_factory_get_element_type: assertion 'GST_IS_ELEMENT_FACTORY (factory)' failed
(python.exe:6512): GLib-GObject-WARNING **: 17:18:56.512: cannot retrieve class for invalid (unclassed) type '<invalid>'
(python.exe:6512): GStreamer-CRITICAL **: 17:18:56.512: gst_element_factory_get_element_type: assertion 'GST_IS_ELEMENT_FACTORY (factory)' failed
(python.exe:6512): GStreamer-CRITICAL **: 17:18:56.512: gst_element_factory_get_element_type: assertion 'GST_IS_ELEMENT_FACTORY (factory)' failed
(python.exe:6512): GLib-GObject-CRITICAL **: 17:18:56.512: g_object_class_find_property: assertion 'G_IS_OBJECT_CLASS (class)' failed
(python.exe:6512): GStreamer-CRITICAL **: 17:18:56.512: gst_object_unref: assertion 'object != NULL' failed
(python.exe:6512): GLib-GObject-CRITICAL **: 17:18:56.512: g_type_class_unref: assertion 'g_class != NULL' failed
(python.exe:6512): GStreamer-WARNING **: 17:18:56.512: Failed to load plugin 'C:\gstreamer\1.0\msvc_x86_64\lib\gstreamer-1.0\gstvideoparsersbad.dll': The specified module could not be found.
This usually means Windows was unable to find a DLL dependency of the plugin. Please check that PATH is correct.
You can run 'dumpbin -dependents' (provided by the Visual Studio developer prompt) to list the DLL deps of any DLL.
There are also some third-party GUIs to list and debug DLL dependencies recursively.
(python.exe:6512): GStreamer-CRITICAL **: 17:18:56.512: gst_element_factory_get_element_type: assertion 'GST_IS_ELEMENT_FACTORY (factory)' failed
(python.exe:6512): GLib-GObject-WARNING **: 17:18:56.525: cannot retrieve class for invalid (unclassed) type '<invalid>'
(python.exe:6512): GStreamer-CRITICAL **: 17:18:56.526: gst_element_factory_get_element_type: assertion 'GST_IS_ELEMENT_FACTORY (factory)' failed
(python.exe:6512): GStreamer-CRITICAL **: 17:18:56.526: gst_element_factory_get_element_type: assertion 'GST_IS_ELEMENT_FACTORY (factory)' failed
(python.exe:6512): GStreamer-WARNING **: 17:18:56.530: Failed to load plugin 'C:\gstreamer\1.0\msvc_x86_64\lib\gstreamer-1.0\gstvideoparsersbad.dll': The specified module could not be found.
This usually means Windows was unable to find a DLL dependency of the plugin. Please check that PATH is correct.
You can run 'dumpbin -dependents' (provided by the Visual Studio developer prompt) to list the DLL deps of any DLL.
There are also some third-party GUIs to list and debug DLL dependencies recursively.
(python.exe:6512): GStreamer-CRITICAL **: 17:18:56.531: gst_object_unref: assertion 'object != NULL' failed
(python.exe:6512): GLib-GObject-CRITICAL **: 17:18:56.532: g_type_class_unref: assertion 'g_class != NULL' failed
(python.exe:6512): GStreamer-WARNING **: 17:18:56.535: Failed to load plugin 'C:\gstreamer\1.0\msvc_x86_64\lib\gstreamer-1.0\gstrtp.dll': The specified module could not be found.
This usually means Windows was unable to find a DLL dependency of the plugin. Please check that PATH is correct.
You can run 'dumpbin -dependents' (provided by the Visual Studio developer prompt) to list the DLL deps of any DLL.
There are also some third-party GUIs to list and debug DLL dependencies recursively.
(python.exe:6512): GStreamer-CRITICAL **: 17:18:56.537: gst_element_factory_get_element_type: assertion 'GST_IS_ELEMENT_FACTORY (factory)' failed
(python.exe:6512): GLib-GObject-WARNING **: 17:18:56.537: cannot retrieve class for invalid (unclassed) type '<invalid>'
(python.exe:6512): GStreamer-CRITICAL **: 17:18:56.539: gst_element_factory_get_element_type: assertion 'GST_IS_ELEMENT_FACTORY (factory)' failed
(python.exe:6512): GStreamer-CRITICAL **: 17:18:56.540: gst_element_factory_get_element_type: assertion 'GST_IS_ELEMENT_FACTORY (factory)' failed
(python.exe:6512): GLib-GObject-CRITICAL **: 17:18:56.540: g_object_class_find_property: assertion 'G_IS_OBJECT_CLASS (class)' failed
(python.exe:6512): GStreamer-CRITICAL **: 17:18:56.541: gst_object_unref: assertion 'object != NULL' failed
(python.exe:6512): GLib-GObject-CRITICAL **: 17:18:56.541: g_type_class_unref: assertion 'g_class != NULL' failed
(python.exe:6512): GStreamer-WARNING **: 17:18:56.545: Failed to load plugin 'C:\gstreamer\1.0\msvc_x86_64\lib\gstreamer-1.0\gstudp.dll': The specified module could not be found.
This usually means Windows was unable to find a DLL dependency of the plugin. Please check that PATH is correct.
You can run 'dumpbin -dependents' (provided by the Visual Studio developer prompt) to list the DLL deps of any DLL.
There are also some third-party GUIs to list and debug DLL dependencies recursively.
(python.exe:6512): GStreamer-CRITICAL **: 17:18:56.546: gst_element_factory_get_element_type: assertion 'GST_IS_ELEMENT_FACTORY (factory)' failed
(python.exe:6512): GLib-GObject-WARNING **: 17:18:56.547: cannot retrieve class for invalid (unclassed) type '<invalid>'
(python.exe:6512): GStreamer-CRITICAL **: 17:18:56.548: gst_element_factory_get_element_type: assertion 'GST_IS_ELEMENT_FACTORY (factory)' failed
(python.exe:6512): GStreamer-CRITICAL **: 17:18:56.549: gst_element_factory_get_element_type: assertion 'GST_IS_ELEMENT_FACTORY (factory)' failed
(python.exe:6512): GLib-GObject-CRITICAL **: 17:18:56.551: g_object_class_find_property: assertion 'G_IS_OBJECT_CLASS (class)' failed
(python.exe:6512): GStreamer-CRITICAL **: 17:18:56.552: gst_object_unref: assertion 'object != NULL' failed
(python.exe:6512): GLib-GObject-CRITICAL **: 17:18:56.553: g_type_class_unref: assertion 'g_class != NULL' failed
[ WARN:0@1.151] global cap_gstreamer.cpp:2436 cv::CvVideoWriter_GStreamer::open OpenCV | GStreamer warning: error opening writer pipeline: no property "speed-preset" in element "x264enc"