Displaying RTSP Stream Inside QMediaPlayer Window on i.MX6 Device
-
I am currently working on a project using the Toradex Colibri i.MX6DL module. In this setup, I am trying to stream video using GStreamer with integration into a Qt application.
I am using Qt version 5.15.2 and GStreamer version 1.14. The GStreamer pipeline I am using is as follows:
"gst-launch-1.0 rtspsrc location="rtsp://admin:admin123@192.168.1.108/cam/realmonitor?channel=1&subtype=1" latency=50 ! rtph264depay ! h264parse ! imxvpudec ! imxipuvideotransform ! video/x-raw,width=800,height=480 ! autovideosink"Following is the Qt Code:
import QtQuick 2.15 import QtMultimedia 5.15 import QtQuick.Window 2.15 Window { width: 800 height: 480 visible: true title: qsTr("Hello World") Rectangle{ id:cameramainrect visible: true width: parent.width*0.5 height: parent.height*0.5 color: "transparent" MediaPlayer { id: videoPlayer videoOutput: cameraout autoLoad: true autoPlay: true source: "gst-pipeline: rtspsrc location=rtsp://admin:admin123@192.168.1.108/cam/realmonitor?channel=1&subtype=1 latency=50 ! rtph264depay ! h264parse ! imxvpudec ! imxipuvideotransform ! video/x-raw,width=800,height=480 ! autovideosink" } VideoOutput { id: cameraout visible: true anchors.fill:parent fillMode: VideoOutput.PreserveAspectFit } } }```
When I run this pipeline, the video stream plays correctly, but it opens in a new external window created by autovideosink. As a result, the Qt application window moves to the background, and the stream appears in front of it. My goal is to embed this video stream within the QMediaPlayer widget of my application window, rather than having it display in a separate window.
The main objective of this implementation is to reduce CPU utilization. Directly providing the RTSP stream to the player results in high CPU usage. To offload processing from the CPU, we are leveraging hardware-accelerated decoding along with the autovideosink in the GStreamer pipeline. This combination significantly reduces CPU usage to around 20%. However, when using other video sinks instead of autovideosink, CPU utilization tends to be higher.
Could you please advise on how I can render the video stream directly inside the QMediaPlayer area of the application? Any suggestions or changes in pipeline configuration, sink usage, or Qt integration would be greatly appreciated.
Thank you for your support.
-
Take a look at the example here and use gstreamer code directly with qml sink.
https://github.com/GStreamer/gst-plugins-good/tree/master/tests/examples/qt/qmlsinkDo not use QMediaPlayer