woehrl
Posts: 8
Joined: Wed Oct 28, 2015 2:46 pm

Raspberry Pi 2 + Qt 5.5 + USB Video Grabber

Wed Oct 28, 2015 3:19 pm

Hello,

I spent several days now trying to get an Qt 5.5 compiled for Raspberry Pi 2 to play AND record video that is available by V4L2 from a Sensoray s2253 USB grabber card (https://www.sensoray.com/USB_H.264_Vide ... e_2253.htm).
I'm using Luca's Build: http://thebugfreeblog.blogspot.de/

1) I managed to get the "camera" example to work showing live video, but when pressing "Record" a MessageBox pops up with Message "Service has not been started". Adding a debug message gave me:
GLib-GObject-CRITICAL **: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
2) Using Quick (QML) I get a live camera video, too. But when trying to call "camera.videoRecorder.record()" there's the same error:
QMediaRecorder error: "Service has not been started"
qrc:///qml/ContentCamera.qml:43: ReferenceError: recorderStatus is not defined
Does anyone know what this is telling me?
Does anyone have a working application with Qt5+ on Raspberry Pi 2 that does show AND record a video?

Thanks a lot in advance for any hint!!

Best regards,
Florian

woehrl
Posts: 8
Joined: Wed Oct 28, 2015 2:46 pm

Re: Raspberry Pi 2 + Qt 5.5 + USB Video Grabber

Wed Nov 11, 2015 11:21 am

Obviously Qt's implementation of GStreamer is still buggy. In my case I want to have an H.264 Stream coming from the USB Grabber stored to a file AND shown in a Qt (Quick) Widget. Qt can't handle this by now. And I don't see a way of piping the right options through to GStreamer.

Nevertheless, GStreamer implementation itself (1.0) ist working perfectly. Examples for gst-launch to store the stream as file:

Code: Select all

$ gst-launch-1.0 v4l2src device=/dev/video0 ! 'video/x-h264,format=MP42,width=704,height=576,framerate=25/1,pixelformat=uyvy' ! filesink location=test_h264.mp4
Or with MPEG4 codec:

Code: Select all

$ gst-launch-1.0 v4l2src device=/dev/video0 ! 'video/mpeg,mpegversion=4,format=MP42,width=704,height=576,framerate=25/1,pixelformat=uyvy' ! filesink location=test_mpeg4.mp4
Even showing the stream on the HDMI Display with HW acceleration works great (5% ARM CPU usage):

Code: Select all

$ gst-launch-1.0 v4l2src device=/dev/video0 ! 'video/x-h264,format=MP42,width=704,height=576,framerate=25/1,pixelformat=uyvy,profile=constrained-baseline' ! h264parse ! omxh264dec ! autovideosink
Combing these with the "tee" element should work also.

But cross-compiling a simple application (GStreamer 1.4 hello world example) against the gstreamer libraries fails right now - and Google didn't help me, yet.

Code: Select all

/opt/rpi/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/../../../../arm-linux-gnueabihf/bin/ld: main.o: undefined reference to symbol 'g_print'
/opt/rpi/sysroot/lib/arm-linux-gnueabihf/libglib-2.0.so.0: error adding symbols: DSO missing from command line
My INCLUDEPATH variable looks as follows:

Code: Select all

INCLUDEPATH += "/opt/rpi/sysroot/opt/vc/lib/" \     # libGLESv2
    "/opt/rpi/sysroot/usr/include/gstreamer-1.0/" \ # GStreamer-1.0
    "/opt/rpi/sysroot/usr/include/glib-2.0/" \      # GLib-2.0
    "/opt/rpi/sysroot/usr/lib/arm-linux-gnueabihf/glib-2.0/include/" \  # GLib-2.0 Includes
Anybody out there who can point me in the right direction?
Include path order, missing libraries?

Best regards,
Florian

User avatar
topguy
Posts: 6886
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Raspberry Pi 2 + Qt 5.5 + USB Video Grabber

Wed Nov 11, 2015 12:12 pm

Your include-path is not relevant for a linker error.
You need to find the variable that decides what is behind "-L" argument to gcc.

woehrl
Posts: 8
Joined: Wed Oct 28, 2015 2:46 pm

Re: Raspberry Pi 2 + Qt 5.5 + USB Video Grabber

Wed Nov 11, 2015 4:55 pm

Thanks, but I still don't know what's the problem.
What does the error message say exactly? What's wrong with glib-2.0?

If I knew the desired result in the Makefile I could find a way to have it generated that way.
Currently the "-L" seems to be filled with:

Code: Select all

LIBS          = $(SUBLIBS) -L/opt/rpi/sysroot/opt/vc/lib -L/opt/rpi/sysroot/usr/local/Qt-rasp2-5.5.0/lib -lQt5MultimediaWidgets -L/opt/rpi/sysroot/home/pi/qtdeps/lib -lQt5Multimedia -lQt5Quick -lQt5Widgets -lQt5Gui -lQt5Qml -lQt5Network -lQt5Core -lGLESv2 -lpthread
I attach the Makefile generated by qmake - maybe you could give me a hint on the wrong order/missing Library...

Thanks!
Last edited by woehrl on Thu Nov 12, 2015 7:39 am, edited 1 time in total.

User avatar
topguy
Posts: 6886
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Raspberry Pi 2 + Qt 5.5 + USB Video Grabber

Wed Nov 11, 2015 5:39 pm

Seeing the final "gcc" command would show more and not only the $LIBS could tell us more.
But a general observation is that there is no "-lglib2" (or maybe "-lglib-2.0") there.

woehrl
Posts: 8
Joined: Wed Oct 28, 2015 2:46 pm

Re: Raspberry Pi 2 + Qt 5.5 + USB Video Grabber

Thu Nov 12, 2015 7:36 am

YES! The Makefile did not have my LIBS variable set correctly. When I added " -lglib-2.0 -lgobject-2.0 -lgstreamer-1.0" compile did fine.
But the real mistake was, that I had commented some lines in my Qt Project file above the "LIBS += ..." line. And I forgot to remove the trailing "\" at the last active line. :?

Ok, another step forward. Thanks!

woehrl
Posts: 8
Joined: Wed Oct 28, 2015 2:46 pm

Re: Raspberry Pi 2 + Qt 5.5 + USB Video Grabber

Thu Nov 12, 2015 7:42 am

Ok, the initial problem stays. Qt is not capable - at the moment - to show live image of an H.264 encoded USB grabber stream.
I filed a bug report - would be glad if someone voted it up:
https://bugreports.qt.io/browse/QTBUG-49357

woehrl
Posts: 8
Joined: Wed Oct 28, 2015 2:46 pm

Re: Raspberry Pi 2 + Qt 5.5 + USB Video Grabber

Thu Nov 19, 2015 7:56 am

Ok, I managed to have a GStreamer pipeline that
- receives an h.264 encoded stream from the usb grabber (using caps)
- decodes that stream hw accelerated with RPis GPU (omxh264dec)
- shows the stream in an GL window (glimagesink) or on the fbdevsink

Code: Select all

$ gst-launch-1.0 v4l2src device=/dev/video0 ! 'video/x-h264,format=MP42,width=720,height=576,framerate=25/1,pixelformat=h264,profile=high' ! h264parse ! omxh264dec ! glimagesink sync=false
BUT - I'm not able to tell glimagesink to be rendered within a previously created Qt Widget.

There are samples to use the glimagesink without Qt:
https://gist.github.com/sphaero/eac4d01013bd2b0e2205

I tried the following example to set a target Qt window id for glimagesink:
http://code.metager.de/source/xref/free ... verlay.cpp
But the window stays default gray - no video shown.

I found this post about the three methods currently available to show the gstreamer result on Qt:
http://gstreamer-devel.966125.n4.nabble ... 74177.html
But no answers still.

I know, that qmlsink is available with gstreamer-1.6. But gstreamer source currently does not compile with gst-omx:
http://gstreamer-devel.966125.n4.nabble ... 73594.html
So I'm stuck with gstreamer 1.4.4 from the raspbian jessie repo.

So - is there anybody out there that has a running example to show gstreamer output within Qt? Either Widget/GL or QML?

Return to “Graphics, sound and multimedia”