0

I'm trying to open UDP stream video in Raspberry Pi using this pipeline:

VideoCapture video("udpsrc port=5600 ! application/x-rtp,payload=96,encoding-name=H264 !"
                           "rtpjitterbuffer mode=1 ! rtph264depay ! h264parse ! decodebin ! videoconvert ! appsink emit-signals=true sync=false max-buffers=2 drop=true", cv::CAP_GSTREAMER);
   // Exit if video is not opened
          if(!video.isOpened())
          {
              cout << "Could not read video file" << endl;
              return 1;
          }

However, video.isOpened() return false and I couldn't be able to open with this code. This works on loopback test and another Ubuntu 18.04 PC but RPi 4 (Buster OS) couldn't run it. Also following lines can run upcoming gstream video:

gst-launch-1.0 udpsrc port=5600 caps='application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264' ! rtph264depay ! h264parse ! avdec_h264 ! autovideosink fps-update-interval=1000 sync=false

Furthermore specific code stack (e.g. [video_udp.cpp][1]) can easily handle video but also it's hard to use with opencv.

NOTE: OpenCV version is 4.2.0-pre

Bozkurthan
  • 91
  • 12
  • This link suggests "apt-get update" "apt-get dist-upgrade -y" https://discuss.ardupilot.org/t/apsync-r-pi3-setup-issue/23090 – Yunus Temurlenk Jan 14 '20 at 08:47
  • On that topic the problem doesn't be solved. BTW, I tried update, upgrade etc. before and also seen some mentions about adding '/etc/apt/sources.list' http://vontaene.de to solve missing dependencies. – Bozkurthan Jan 14 '20 at 10:16
  • I found that the version of gstreamer is 1.14.4.1+b1 on raspberry pi while it is 1.14.5 on Ubuntu 18.04. – Bozkurthan Jan 16 '20 at 08:10
  • 1
    The problem is that Raspberry pi 4 doesn't recognize Gstreamer library. Now, I'm trying with '-D WITH_GSTREAMER=ON' flag. If it's ok, I'll try to install all steps by checking carefully. – Bozkurthan Jan 17 '20 at 06:29
  • After you solved ur problem, please answer ur question – Yunus Temurlenk Jan 17 '20 at 06:38

1 Answers1

0

The problem is about using GStreamer library as a plugin of OpenCV. OpenCV doesn't throw exception even you build source code without GStreamer support. (In default, GStreamer library was directly found by Ubuntu, conversely Raspberry Pi 4 couldn't find it.)

Firstly I check build information of OpenCV with std::cout<<cv::getBuildInformation(); in Ubuntu 18.04 machine and found that:

GStreamer: YES (1.14.5)

Also I just check this on Raspberry Pi 4 side and build information was:

GStreamer:NO

Before the build OpenCV I just compare GStreamer plugins with gst-inspect-1.0 command for both of them and I just install some missing plugins like gstreamer1.0-tools . Also I wasn't know the problem, before the checking build information, so I installed some other GStreamer plugins that currently I don't remember.

Lastly, I build system by adding -D WITH_GSTREAMER=ON flag. And now it works well.

I'll edit answer if the problem related to missing plugins those are installed later. For this, I'll check this issue with clean Buster OS image.

Bozkurthan
  • 91
  • 12