Qengineering / GStreamer-1.18.4-RPi_64-bits

GStreamer 1.18.4 with OpenCV example on a Raspberry Pi 4
BSD 3-Clause "New" or "Revised" License
9 stars 5 forks source link

GStreamer: unable to start pipeline #3

Open sobczakDev opened 2 weeks ago

sobczakDev commented 2 weeks ago

Hi,

First of all, I would like to greet the entire Qengineering team! You are doing an amazing job, and the fact that you make everything open-source is incredibly valuable!

Recently, I bought a Raspberry Pi 5 with 8GB of RAM, and I wanted to set up a stream using the Raspberry Pi Camera HD v3 12MPx. Of course, I would like to do this in C++.

I cloned your repository using: git clone git@github.com:Qengineering/GStreamer-1.18.4-RPi_64-bits.git

I opened it in Code::Blocks and followed all the instructions you provided in Readme Unfortunately, after compilation, I encountered the following error:

Using pipeline: 
     v4l2src device=/dev/video0 ! video/x-raw, width=(int)1280, height=(int)720, framerate=(fraction)30/1 ! videoconvert ! videoscale ! video/x-raw, width=(int)640, height=(int)360 ! appsink

[ WARN:0@0.039] global cap_gstreamer.cpp:2838 handleMessage OpenCV | GStreamer warning: Embedded video playback halted; module v4l2src0 reported: Failed to allocate required memory.
[ WARN:0@0.039] global cap_gstreamer.cpp:1698 open OpenCV | GStreamer warning: unable to start pipeline
[ WARN:0@0.039] global cap_gstreamer.cpp:1173 isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created
[ WARN:0@0.040] global cap.cpp:204 open VIDEOIO(GSTREAMER): backend is generally available but can't be used to capture by name
Failed to open camera.

I am a bit surprised by the Failed to allocate required memory error, considering I have the 8GB version of the Raspberry Pi 5.

I would be grateful if someone could help me with this issue 🙏

===== I'm using OpenCV 4.9.0 installed from here My stack:

pi@raspberrypi:~ $ dpkg -l | grep gstream*
ii  gir1.2-gstreamer-1.0:arm64           1.22.0-2                            arm64        GObject introspection data for the GStreamer library
ii  gstreamer1.0-alsa:arm64              1.22.0-3+deb12u2+rpt1               arm64        GStreamer plugin for ALSA
ii  gstreamer1.0-gl:arm64                1.22.0-3+deb12u2+rpt1               arm64        GStreamer plugins for GL
ii  gstreamer1.0-gtk3:arm64              1.22.0-5+rpt1+deb12u1               arm64        GStreamer plugin for GTK+3
ii  gstreamer1.0-libav:arm64             1.22.0-2                            arm64        ffmpeg plugin for GStreamer
ii  gstreamer1.0-plugins-bad:arm64       1.22.0-4+deb12u5                    arm64        GStreamer plugins from the "bad" set
ii  gstreamer1.0-plugins-base:arm64      1.22.0-3+deb12u2+rpt1               arm64        GStreamer plugins from the "base" set
ii  gstreamer1.0-plugins-good:arm64      1.22.0-5+rpt1+deb12u1               arm64        GStreamer plugins from the "good" set
ii  gstreamer1.0-x:arm64                 1.22.0-3+deb12u2+rpt1               arm64        GStreamer plugins for X11 and Pango
ii  libgstreamer-gl1.0-0:arm64           1.22.0-3+deb12u2+rpt1               arm64        GStreamer GL libraries
ii  libgstreamer-plugins-bad1.0-0:arm64  1.22.0-4+deb12u5                    arm64        GStreamer libraries from the "bad" set
ii  libgstreamer-plugins-base1.0-0:arm64 1.22.0-3+deb12u2+rpt1               arm64        GStreamer libraries from the "base" set
ii  libgstreamer-plugins-base1.0-dev     1.22.0-3+deb12u2+rpt1               arm64        GStreamer development files for libraries from the "base" set
ii  libgstreamer1.0-0:arm64              1.22.0-2                            arm64        Core GStreamer libraries and elements
ii  libgstreamer1.0-dev:arm64            1.22.0-2                            arm64        GStreamer core development files
pi@raspberrypi:~ $ cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
pi@raspberrypi:~ $ getconf LONG_BIT
64
Qengineering commented 2 weeks ago

Try replacing v4l2src device=/dev/video0 with libcamerasrc.

sobczakDev commented 2 weeks ago

Thanks for quick response. I changed v4l2src device=/dev/video0 to libcamerasrc and now the error is different:

pi@raspberrypi:~/GStreamer-1.18.4-RPi_64-bits $ ./main 
Using pipeline: 
     libcamerasrc0 ! video/x-raw, width=(int)1280, height=(int)720, framerate=(fraction)30/1 ! videoconvert ! videoscale ! video/x-raw, width=(int)640, height=(int)360 ! appsink

(main:3095): GStreamer-CRITICAL **: 10:50:17.727: gst_caps_get_structure: assertion 'GST_IS_CAPS (caps)' failed

(main:3095): GStreamer-CRITICAL **: 10:50:17.727: gst_structure_get_int: assertion 'structure != NULL' failed
[ WARN:0@30.021] global cap_gstreamer.cpp:1714 open OpenCV | GStreamer warning: cannot query video width/height

(main:3095): GStreamer-CRITICAL **: 10:50:17.727: gst_structure_get_fraction: assertion 'structure != NULL' failed
[ WARN:0@30.021] global cap_gstreamer.cpp:1722 open OpenCV | GStreamer warning: cannot query video fps
[ WARN:0@30.021] global cap_gstreamer.cpp:1777 open OpenCV | GStreamer warning: Cannot query video position: status=0, value=-1, duration=-1
Hit ESC to exit

(main:3095): GStreamer-CRITICAL **: 10:51:22.833: gst_sample_get_caps: assertion 'GST_IS_SAMPLE (sample)' failed
[ERROR:0@95.127] global cap_gstreamer.cpp:934 retrieveVideoFrame GStreamer: gst_sample_get_caps() returns NULL
Capture read error

Maybe I need to downgrade GStreamer? Because I'm using 1.22 but your code requires 1.18 🤔


I just checked whether the default rpicam-hello works on my RPi 5, and it works as expected:

pi@raspberrypi:~/GStreamer-1.18.4-RPi_64-bits $ rpicam-hello
[0:15:34.108728668] [3646]  INFO Camera camera_manager.cpp:325 libcamera v0.3.2+27-7330f29b
[0:15:34.119938437] [3652]  INFO RPI pisp.cpp:695 libpisp version v1.0.7 28196ed6edcf 29-08-2024 (16:33:32)
[0:15:34.144413149] [3652]  INFO RPI pisp.cpp:1154 Registered camera /base/axi/pcie@120000/rp1/i2c@88000/imx708@1a to CFE device /dev/media0 and ISP device /dev/media1 using PiSP variant BCM2712_C0
Made X/EGL preview window
Mode selection for 2304:1296:12:P
    SRGGB10_CSI2P,1536x864/0 - Score: 3400
    SRGGB10_CSI2P,2304x1296/0 - Score: 1000
    SRGGB10_CSI2P,4608x2592/0 - Score: 1900
Stream configuration adjusted
[0:15:35.279229067] [3646]  INFO Camera camera.cpp:1197 configuring streams: (0) 2304x1296-YUV420 (1) 2304x1296-BGGR_PISP_COMP1
[0:15:35.279361511] [3652]  INFO RPI pisp.cpp:1450 Sensor: /base/axi/pcie@120000/rp1/i2c@88000/imx708@1a - Selected sensor format: 2304x1296-SBGGR10_1X10 - Selected CFE format: 2304x1296-PC1B
Qengineering commented 2 weeks ago

I've tested the libcamerasrc on my Rpi 4. On the Rpi 5, I'm running into issues also. A quick google scan reveals that it a common issue, the Rpi5 + 12 Mp Raspicam + Gstreamer. I have to spend more time to the issue. Hopefully in the weekend. Right now, I'm too busy.