Embedded Jetson Nano Video Stream to Qt App

Hey, so for my project I have developed a Qt Quick App.
I’d like to have my camera stream in the background and some UI in front.

Anyone have some experience on whats the best way to do it? I am trying 2 different things right now but I am stuck.

1)

I made a sample program, which uses QML Mediaplayer with a simple custom gstreamer pipeline. It works with videotestsrc.

import QtQuick 2.15
import QtQuick.Window 2.15
import QtQuick.Controls 2.15
import QtMultimedia 5.15

Window {
visible: true
width: 640
height: 480
title: qsTr(“Hello World”)

VideoOutput {
    height: 480
    width: 640
    anchors.fill: parent
    source: mediaplayer

    MediaPlayer {
        id: mediaplayer
        source: "gst-pipeline: videotestsrc ! qtvideosink"
        //source: "gst-pipeline: nvarguscamerasrc !  video/x-raw(memory:NVMM), width=(int)1920, height=(int)1080, format=(string)NV12, framerate=(fraction)30/1 ! videoconvert ! qtvideosink"
        //source: "file_example_MP4_480_1_5MG.mp4"
        autoPlay: true
        onPlaying: {
        bt.text = "mediaplayer";
        }
    }
}
Button{
    height: 500
    width: 500
    id: bt
    text: "Nothing."
    onPressed: {
        bt.text = "Button pressed.";
        mediaplayer.play();
    }
}

}

Now I’d like to have my camerastream displayed instead of videotestsrc.

nvarguscamerasrc ! video/x-raw(memory:NVMM), width=(int)1920, height=(int)1080, format=(string)NV12, framerate=(fraction)30/1 ! qtvideosink

But of course

Now I’d like to have my camerastream displayed instead of videotestsrc.

nvarguscamerasrc ! video/x-raw(memory:NVMM), width=(int)1920, height=(int)1080, format=(string)NV12, framerate=(fraction)30/1 ! qtvideosink

But of course, it is not compatible with qtvideosink right away giving caps error. Anyone has experience in which formats I have to convert and how to make it compatible?

2)
Another way would be to use QCamera and set enviroment variable: QT_GSTREAMER_CAMERABIN_VIDEOSRC to nvarguscamerasrc. But this did not work neither for me. I get this error:

CameraBin error: “GStreamer error: negotiation problem.”

I would be very thankful for any help.
I will post this to Qt Forum too, maybe they can also help.

Thank you very much,
jb

Hi,
We don’t have experience in using qtvideosink. Not sure but if it supports video/x-raw,format=NV12, please try

nvarguscamerasrc ! video/x-raw(memory:NVMM), width=(int)1920, height=(int)1080, format=(string)NV12, framerate=(fraction)30/1 ! nvvidconv ! video/x-raw,format=NV12 ! qtvideosink

Hey, thank you for your fast response. I’ll try that out. But that means images are copied from optimised NVMM memory to normal CPU memory right, which will be slow then?

Another option came to my mind. In Qt it’s possible to define an OpenGL object which is drawn under the scene each time the the scene is rendered. Maybe that would also be an option to draw directly to the OpenGL buffer. If something like this is possible can you point me to the right documentation on this?

Thank you very much!

Hey there. Your suggestion worked right away. Thank you very much! Helped me a lot.

I would still be interested in the memory copy question, but for now it was fluent enough that way so I am fine with that. :)

Best regards,
jb