QtMultimedia (Qt 6.2.3): Camera example shows a green screen on Linux
-
Hi there,
I have an issue when running the camera example, https://doc-snapshots.qt.io/qt6-6.2/qtmultimedia-multimediawidgets-camera-example.html, on a Linux OS. I don't get any video from the cameras, I am getting only a green screen.
Some more details regarding my setup. I have an Ubuntu Mate 20.04.3 OS running as a Guest OS using VirtualBox. The Host OS is Windows 11. I have installed the Qt 6.2.3 using the Online Installer from here, https://www.qt.io/download-thank-you?os=linux&hsLang=en. I installed it in
/opt/Qt
. There are 2 cameras, an integrated one and a USB. Both cameras are available to the Guest OS using the Webcam Passthrough functionality of VirtualBox, https://docs.oracle.com/en/virtualization/virtualbox/6.0/admin/webcam-passthrough.html.I got the source for the examples from here, https://code.qt.io/cgit/qt/qtmultimedia.git/tree/examples/multimediawidgets/camera?h=6.2 and build with no issue. When I run the
./camera
application I get the followingWhen I try to capture an image or a video, everything is working fine.
In order to verify that both cameras are working as expected, I used VLC and checked that I got video for both devices. I know that Qt Multimedia is using Gstreamer, so I used the command line tool
playbin
to verify that both cameras are working. I used the following commands$ gst-launch-1.0 playbin uri=v4l2:///dev/video0 Setting pipeline to PAUSED ... Pipeline is live and does not need PREROLL ... Setting pipeline to PLAYING ... New clock: GstSystemClock ERROR: from element /GstPlayBin:playbin0/GstPlaySink:playsink/GstBin:vbin/GstXvImageSink:xvimagesink0: Output window was closed Additional debug info: xvimagesink.c(554): gst_xv_image_sink_handle_xevents (): /GstPlayBin:playbin0/GstPlaySink:playsink/GstBin:vbin/GstXvImageSink:xvimagesink0 Execution ended after 0:00:05.394707645 Setting pipeline to PAUSED ... Setting pipeline to READY ... Setting pipeline to NULL ... Freeing pipeline ... $ gst-launch-1.0 playbin uri=v4l2:///dev/video2 Setting pipeline to PAUSED ... Pipeline is live and does not need PREROLL ... Setting pipeline to PLAYING ... New clock: GstSystemClock ERROR: from element /GstPlayBin:playbin0/GstPlaySink:playsink/GstBin:vbin/GstXvImageSink:xvimagesink0: Output window was closed Additional debug info: xvimagesink.c(554): gst_xv_image_sink_handle_xevents (): /GstPlayBin:playbin0/GstPlaySink:playsink/GstBin:vbin/GstXvImageSink:xvimagesink0 Execution ended after 0:00:06.981935305 Setting pipeline to PAUSED ... Setting pipeline to READY ... Setting pipeline to NULL ... Freeing pipeline ...
I could see video for both cameras without any issue.
Next following the video device information using the
gst-device-monitor-1.0
.Device found: name : Video Capture 3 class : Video/Source caps : image/jpeg, width=(int)1280, height=(int)720, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction){ 30/1, 25/1, 20/1, 15/1, 10/1, 5/1 }; image/jpeg, width=(int)1184, height=(int)656, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction){ 30/1, 25/1, 20/1, 15/1, 10/1, 5/1 }; image/jpeg, width=(int)960, height=(int)720, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction){ 30/1, 25/1, 20/1, 15/1, 10/1, 5/1 }; image/jpeg, width=(int)1024, height=(int)576, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction){ 30/1, 25/1, 20/1, 15/1, 10/1, 5/1 }; image/jpeg, width=(int)960, height=(int)544, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction){ 30/1, 25/1, 20/1, 15/1, 10/1, 5/1 }; image/jpeg, width=(int)800, height=(int)600, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction){ 30/1, 25/1, 20/1, 15/1, 10/1, 5/1 }; image/jpeg, width=(int)864, height=(int)480, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction){ 30/1, 25/1, 20/1, 15/1, 10/1, 5/1 }; image/jpeg, width=(int)800, height=(int)448, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction){ 30/1, 25/1, 20/1, 15/1, 10/1, 5/1 }; image/jpeg, width=(int)752, height=(int)416, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction){ 30/1, 25/1, 20/1, 15/1, 10/1, 5/1 }; image/jpeg, width=(int)640, height=(int)480, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction){ 30/1, 25/1, 20/1, 15/1, 10/1, 5/1 }; image/jpeg, width=(int)640, height=(int)360, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction){ 30/1, 25/1, 20/1, 15/1, 10/1, 5/1 }; image/jpeg, width=(int)544, height=(int)288, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction){ 30/1, 25/1, 20/1, 15/1, 10/1, 5/1 }; image/jpeg, width=(int)432, height=(int)240, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction){ 30/1, 25/1, 20/1, 15/1, 10/1, 5/1 }; image/jpeg, width=(int)352, height=(int)288, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction){ 30/1, 25/1, 20/1, 15/1, 10/1, 5/1 }; image/jpeg, width=(int)320, height=(int)240, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction){ 30/1, 25/1, 20/1, 15/1, 10/1, 5/1 }; image/jpeg, width=(int)320, height=(int)176, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction){ 30/1, 25/1, 20/1, 15/1, 10/1, 5/1 }; image/jpeg, width=(int)160, height=(int)120, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction){ 30/1, 25/1, 20/1, 15/1, 10/1, 5/1 }; properties: udev-probed = true device.bus_path = pci-0000:00:0c.0-usb-0:2:1.0 sysfs.path = /sys/devices/pci0000:00/0000:00:0c.0/usb1/1-2/1-2:1.0/video4linux/video0 device.bus = usb device.subsystem = video4linux device.vendor.id = 80ee device.vendor.name = VirtualBox device.product.id = 0030 device.product.name = "Video\ Capture\ 3" device.serial = VirtualBox_VirtualBox_Webcam_-_HD_720P_Webcam_2a05b46fd0033864 device.capabilities = :capture: device.api = v4l2 device.path = /dev/video0 v4l2.device.driver = uvcvideo v4l2.device.card = "Video\ Capture\ 3" v4l2.device.bus_info = usb-0000:00:0c.0-2 v4l2.device.version = 331027 (0x00050d13) v4l2.device.capabilities = 2225078273 (0x84a00001) v4l2.device.device_caps = 69206017 (0x04200001) gst-launch-1.0 v4l2src ! ... Device found: name : Video Capture 3 class : Video/Source caps : image/jpeg, width=(int)1280, height=(int)720, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction){ 30/1, 25/1, 20/1, 15/1, 10/1, 5/1 }; image/jpeg, width=(int)960, height=(int)540, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction){ 30/1, 25/1, 20/1, 15/1, 10/1, 5/1 }; image/jpeg, width=(int)848, height=(int)480, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction){ 30/1, 25/1, 20/1, 15/1, 10/1, 5/1 }; image/jpeg, width=(int)640, height=(int)480, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction){ 30/1, 25/1, 20/1, 15/1, 10/1, 5/1 }; image/jpeg, width=(int)640, height=(int)360, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction){ 30/1, 25/1, 20/1, 15/1, 10/1, 5/1 }; image/jpeg, width=(int)424, height=(int)240, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction){ 30/1, 25/1, 20/1, 15/1, 10/1, 5/1 }; image/jpeg, width=(int)320, height=(int)240, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction){ 30/1, 25/1, 20/1, 15/1, 10/1, 5/1 }; image/jpeg, width=(int)320, height=(int)180, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction){ 30/1, 25/1, 20/1, 15/1, 10/1, 5/1 }; image/jpeg, width=(int)160, height=(int)120, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction){ 30/1, 25/1, 20/1, 15/1, 10/1, 5/1 }; properties: udev-probed = true device.bus_path = pci-0000:00:0c.0-usb-0:3:1.0 sysfs.path = /sys/devices/pci0000:00/0000:00:0c.0/usb1/1-3/1-3:1.0/video4linux/video2 device.bus = usb device.subsystem = video4linux device.vendor.id = 80ee device.vendor.name = VirtualBox device.product.id = 0030 device.product.name = "Video\ Capture\ 3" device.serial = VirtualBox_VirtualBox_Webcam_-_Integrated_Webcam_e7077a0dbf9f51b8 device.capabilities = :capture: device.api = v4l2 device.path = /dev/video2 v4l2.device.driver = uvcvideo v4l2.device.card = "Video\ Capture\ 3" v4l2.device.bus_info = usb-0000:00:0c.0-3 v4l2.device.version = 331027 (0x00050d13) v4l2.device.capabilities = 2225078273 (0x84a00001) v4l2.device.device_caps = 69206017 (0x04200001) gst-launch-1.0 v4l2src device=/dev/video2 ! ...
I am not really sure what's going on here. Is there something else that I can do in order to find more information regarding the issue? I am new to Qt and Gstreamer, so any help is appreciated.
Kind regards,
Stavros
-
Hi and welcome to devnet,
Can you check if you have the same issue with the QtQuick Camera example ?
-
Hi @SGaist,
Thank you for your prompt reply. I suppose when you say to run the QtQuick Camera example you mean the Declarative Camera example here, https://code.qt.io/cgit/qt/qtmultimedia.git/tree/examples/multimedia/declarative-camera?h=6.2.
I run this example but I get the same problem. Next following a screenshot from this example
Kind regards,
Stavros
-
I did more investigation using the debugging tools for Gstreamer, https://gstreamer.freedesktop.org/documentation/tutorials/basic/debugging-tools.html?gi-language=c.
I enabled more debug information, as described here, https://gstreamer.freedesktop.org/documentation/tutorials/basic/debugging-tools.html?gi-language=c#the-debug-log, for both examples, QtWidget and QtQuick. The output is the following
$ GST_DEBUG=3 ./camera 0:00:00.277196220 10040 0x137e6a0 WARN GST_ELEMENT_FACTORY gstelementfactory.c:456:gst_element_factory_make: no such element factory "imxvideoconvert_g2d"! 0:00:00.282197494 10040 0x13d3920 FIXME default gstutils.c:3980:gst_pad_create_stream_id_internal:<audiosrc:src> Creating random stream-id, consider implementing a deterministic way of creating a stream-id 0:00:00.331335937 10040 0x14d8a40 FIXME videodecoder gstvideodecoder.c:944:gst_video_decoder_drain_out:<jpegdec0> Sub-class should implement drain() 0:00:00.339970343 10040 0x15c7000 WARN v4l2src gstv4l2src.c:695:gst_v4l2src_query:<camerasrc> Can't give latency since framerate isn't fixated ! 0:00:00.340200394 10040 0x15c7000 WARN v4l2src gstv4l2src.c:695:gst_v4l2src_query:<camerasrc> Can't give latency since framerate isn't fixated ! 0:00:00.340307325 10040 0x15c7000 WARN v4l2src gstv4l2src.c:695:gst_v4l2src_query:<camerasrc> Can't give latency since framerate isn't fixated ! 0:00:00.340396672 10040 0x15c7000 WARN v4l2src gstv4l2src.c:695:gst_v4l2src_query:<camerasrc> Can't give latency since framerate isn't fixated ! 0:00:00.340482062 10040 0x15c7000 WARN v4l2src gstv4l2src.c:695:gst_v4l2src_query:<camerasrc> Can't give latency since framerate isn't fixated ! 0:00:00.340564978 10040 0x15c7000 WARN v4l2src gstv4l2src.c:695:gst_v4l2src_query:<camerasrc> Can't give latency since framerate isn't fixated ! 0:00:00.340662320 10040 0x15c7000 WARN v4l2src gstv4l2src.c:695:gst_v4l2src_query:<camerasrc> Can't give latency since framerate isn't fixated ! 0:00:00.340732111 10040 0x15c7000 WARN v4l2src gstv4l2src.c:695:gst_v4l2src_query:<camerasrc> Can't give latency since framerate isn't fixated ! 0:00:00.340798956 10040 0x15c7000 WARN v4l2src gstv4l2src.c:695:gst_v4l2src_query:<camerasrc> Can't give latency since framerate isn't fixated ! 0:00:00.340869649 10040 0x15c7000 WARN v4l2src gstv4l2src.c:695:gst_v4l2src_query:<camerasrc> Can't give latency since framerate isn't fixated ! 0:00:00.340936484 10040 0x15c7000 WARN v4l2src gstv4l2src.c:695:gst_v4l2src_query:<camerasrc> Can't give latency since framerate isn't fixated ! 0:00:00.341002919 10040 0x15c7000 WARN v4l2src gstv4l2src.c:695:gst_v4l2src_query:<camerasrc> Can't give latency since framerate isn't fixated ! 0:00:00.341070606 10040 0x15c7000 WARN v4l2src gstv4l2src.c:695:gst_v4l2src_query:<camerasrc> Can't give latency since framerate isn't fixated ! 0:00:00.341159562 10040 0x15c7000 WARN v4l2src gstv4l2src.c:695:gst_v4l2src_query:<camerasrc> Can't give latency since framerate isn't fixated ! 0:00:00.341231768 10040 0x15c7000 WARN v4l2src gstv4l2src.c:695:gst_v4l2src_query:<camerasrc> Can't give latency since framerate isn't fixated ! 0:00:00.341322418 10040 0x15c7000 WARN v4l2src gstv4l2src.c:695:gst_v4l2src_query:<camerasrc> Can't give latency since framerate isn't fixated ! 0:00:00.341395695 10040 0x15c7000 WARN v4l2src gstv4l2src.c:695:gst_v4l2src_query:<camerasrc> Can't give latency since framerate isn't fixated ! 0:00:00.341517363 10040 0x15c7000 WARN v4l2src gstv4l2src.c:695:gst_v4l2src_query:<camerasrc> Can't give latency since framerate isn't fixated ! 0:00:00.341614666 10040 0x15c7000 WARN v4l2src gstv4l2src.c:695:gst_v4l2src_query:<camerasrc> Can't give latency since framerate isn't fixated ! 0:00:00.341685899 10040 0x15c7000 WARN v4l2src gstv4l2src.c:695:gst_v4l2src_query:<camerasrc> Can't give latency since framerate isn't fixated ! 0:00:00.341751292 10040 0x15c7000 WARN v4l2src gstv4l2src.c:695:gst_v4l2src_query:<camerasrc> Can't give latency since framerate isn't fixated ! 0:00:00.341825821 10040 0x15c7000 WARN v4l2src gstv4l2src.c:695:gst_v4l2src_query:<camerasrc> Can't give latency since framerate isn't fixated ! 0:00:00.341894109 10040 0x15c7000 WARN v4l2src gstv4l2src.c:695:gst_v4l2src_query:<camerasrc> Can't give latency since framerate isn't fixated ! 0:00:00.341967297 10040 0x15c7000 WARN v4l2src gstv4l2src.c:695:gst_v4l2src_query:<camerasrc> Can't give latency since framerate isn't fixated ! 0:00:00.342054570 10040 0x15c7000 WARN v4l2src gstv4l2src.c:695:gst_v4l2src_query:<camerasrc> Can't give latency since framerate isn't fixated ! 0:00:00.342129891 10040 0x15c7000 WARN v4l2src gstv4l2src.c:695:gst_v4l2src_query:<camerasrc> Can't give latency since framerate isn't fixated ! 0:00:00.342202217 10040 0x15c7000 WARN v4l2src gstv4l2src.c:695:gst_v4l2src_query:<camerasrc> Can't give latency since framerate isn't fixated ! 0:00:00.342297516 10040 0x15c7000 WARN v4l2src gstv4l2src.c:695:gst_v4l2src_query:<camerasrc> Can't give latency since framerate isn't fixated ! 0:00:00.342373368 10040 0x15c7000 WARN v4l2src gstv4l2src.c:695:gst_v4l2src_query:<camerasrc> Can't give latency since framerate isn't fixated ! 0:00:00.342454400 10040 0x15c7000 WARN v4l2src gstv4l2src.c:695:gst_v4l2src_query:<camerasrc> Can't give latency since framerate isn't fixated ! 0:00:00.342526475 10040 0x15c7000 WARN v4l2src gstv4l2src.c:695:gst_v4l2src_query:<camerasrc> Can't give latency since framerate isn't fixated ! 0:00:00.344930236 10040 0x14d8a40 WARN v4l2bufferpool gstv4l2bufferpool.c:809:gst_v4l2_buffer_pool_start:<camerasrc:pool:src> Uncertain or not enough buffers, enabling copy threshold 0:00:01.706614059 10040 0x14d8a40 FIXME videodecoder gstvideodecoder.c:944:gst_video_decoder_drain_out:<jpegdec1> Sub-class should implement drain() 0:00:07.772488662 10040 0x16160c0 WARN audiosrc gstaudiosrc.c:226:audioringbuffer_thread_func:<audiosrc> error reading data -1 (reason: Success), skipping segment $ GST_DEBUG=3 ./declarative-camera 0:00:00.321779679 10077 0x17e1760 FIXME videodecoder gstvideodecoder.c:944:gst_video_decoder_drain_out:<jpegdec0> Sub-class should implement drain() 0:00:00.328812318 10077 0x1542ea0 WARN GST_ELEMENT_FACTORY gstelementfactory.c:456:gst_element_factory_make: no such element factory "imxvideoconvert_g2d"! 0:00:00.329006762 10077 0x1542ea0 WARN GST_ELEMENT_FACTORY gstelementfactory.c:456:gst_element_factory_make: no such element factory "imxvideoconvert_g2d"! qml: State: Other 0:00:00.332348957 10077 0x17e1760 WARN v4l2bufferpool gstv4l2bufferpool.c:809:gst_v4l2_buffer_pool_start:<camerasrc:pool:src> Uncertain or not enough buffers, enabling copy threshold
I don't see any errors from the above output. I also used the
GST_DEBUG=4
which is a lot more verbose, but I didn't see any errors there as well.The next thing I did was to get the pipeline graph of both examples as described here, https://gstreamer.freedesktop.org/documentation/tutorials/basic/debugging-tools.html#getting-pipeline-graphs.
The Update Video Sink pipeline for the QtWidget camera example:
The Update Video Sink pipeline for the QtQuick camera example:
Are the above pipelines, the expected pipelines?
I will try to create the above pipelines using the
gstlaunch
tool, https://gstreamer.freedesktop.org/documentation/tutorials/basic/gstreamer-tools.html?gi-language=c#gstlaunch10.Kind regards,
Stavros
-
I also tried the player example, https://code.qt.io/cgit/qt/qtmultimedia.git/tree/examples/multimediawidgets/player?h=6.2.3 which I got the same error. Next following a screenshot of the
player
exampleI also created the pipeline from the
player
example. The pipeline can be seen belowI can see for all the pipelines that I have created, for both camera and player examples, the final sink for the video output is
qgstvideorenderersink
.Using the
gst-inspect-1.0
, I could not find theqgstvideorenderersink
in order to try to re-create the pipeline usinggst-launch-1.0
, so I suppose this sink is located somewhere in thelibQt6Multimedia.so
and it's not a proper GStreamer plugin.So I have 2 questions
- Is there a way to change the
qgstvideorenderersink
toxvimagesink
programmatically or any other related sink? - What can I do in order to debug the
qgstvideorenderersink
?
Kind regards,
Stavros
- Is there a way to change the
-
After some debugging checking the logs of the system using
journalctl -f
, the culprit was the VirtualBox and more specifically the 3D acceleration option in display settings. The 3D acceleration option was enabled, when I disabled it the problem was fixed.In more detail, when I was running one of the Qt example applications, I could see in the logs the error
[drm:vmw_msg_ioctl [vmwgfx]] *ERROR* Failed to open channel.
. After searching around, I found out this article, https://nemoz.info/ubuntu-20-04-system-hangs-in-virtualbox-6-1-18/. So when I disabled the 3D acceleration, the problem solved.Kind regards,
Stavros
-
Thanks for the detailed feedback !
Virtualization is tricky...
-
This is because of virtualbox 3d acceleration support opengl version 2.0
it looks like qt multimedia(6.2) need opengl at least 3.0 versionBelow was how to know it.
mesa log enable and log like belowMesa: glGenTextures 1
Mesa: glBindTexture GL_TEXTURE_2D 2
Mesa: FLUSH_VERTICES in bind_texture_object
Mesa: FLUSH_VERTICES in teximage
Mesa: glTexImage2D GL_TEXTURE_2D 0 GL_R8 960 360 1 0 GL_RED GL_UNSIGNED_BYTE (nil)
Mesa debug output: GL_INVALID_VALUE in glTexImage2D(internalFormat=GL_R8)GL_R8 variable is available upper than opengl 3.0
That's why we have to see green screen in virtualbox 3d acceleration