Search code examples
pythonopencvudpcondagstreamer

OpenCV GStreamer - no element "udpsrc"


I am currently trying to access the live feed of a drone, send from the rosetta drone app. I have seen it been done before by using the VideoCapture from OpenCV like this:

self.cap_receive = cv2.VideoCapture('udpsrc port=5600 caps = "application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264" ! rtph264depay ! avdec_h264 ! videoconvert ! appsink ', cv2.CAP_GSTREAMER)

I am using Conda and manually compiled OpenCV to include Gstreamer (which I installed beforehand). When I execute my code I get the following Error:

[ WARN:0@2.585] global /home/max/openCV-GS/opencv-4.x/modules/videoio/src/cap_gstreamer.cpp (1127) open OpenCV | GStreamer warning: Error opening bin: no element "udpsrc"
[ WARN:0@2.585] global /home/max/openCV-GS/opencv-4.x/modules/videoio/src/cap_gstreamer.cpp (862) isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created

I checked if Gstreamer was installed properly by typing gst-inspect-1.0 udpsrc into the consoloe (in my conda environment) which at first did not work. It told me that there was no such element or plugin, but after adding sudo (as described here) it showed all of the plugin details. Does it mean that udpsrc for Gstreamer got installed correctly? And if so, why is my Python code not working , do I somehow have to grand sudo permission in there as well (and how would I do that)?

If relevant, that is the result of sudo gst-inspect-1.0 udpsrc

(liveImMapper) max@max-ubuntu:~$ sudo gst-inspect-1.0 udpsrc
Factory Details:
  Rank                     none (0)
  Long-name                UDP packet receiver
  Klass                    Source/Network
  Description              Receive data over the network via UDP
  Author                   Wim Taymans <wim@fluendo.com>, Thijs Vermeir <thijs.vermeir@barco.com>

Plugin Details:
  Name                     udp
  Description              transfer data via UDP
  Filename                 /usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstudp.so
  Version                  1.16.2
  License                  LGPL
  Source module            gst-plugins-good
  Source release date      2019-12-03
  Binary package           GStreamer Good Plugins (Ubuntu)
  Origin URL               https://launchpad.net/distros/ubuntu/+source/gst-plugins-good1.0

GObject
 +----GInitiallyUnowned
       +----GstObject
             +----GstElement
                   +----GstBaseSrc
                         +----GstPushSrc
                               +----GstUDPSrc

Implementierte Schnittstellen:
  GstURIHandler

Pad Templates:
  SRC template: 'src'
    Availability: Always
    Capabilities:
      ANY

Element has no clocking capabilities.

URI handling capabilities:
  Element can act as source.
  Supported URI protocols:
    udp

Pads:
  SRC: 'src'
    Pad Template: 'src'

Element Properties:
  address             : Address to receive packets for. This is equivalent to the multicast-group property for now
                        flags: lesbar, schreibbar
                        String. Default: "0.0.0.0"
  auto-multicast      : Automatically join/leave multicast groups
                        flags: lesbar, schreibbar
                        Boolean. Default: true
:```

Solution

  • I reinstalled everything with a new conda environment and it now works. At some point I may have installed some part of gstreamer inside of my conda environment and now it always tries to use that patrial gstreamer install inside my conda environment. I assume by using sudo it used the version installed outside of the conda env. With everything no reinstalled, opencv compiled in a fresh environment and gstreamer only outside of the conda env everything seems to be working fine (even without using sudo).