Skip to main content
nataut
Associate III
July 16, 2023
Question

Black screen using QML code to play a video

  • July 16, 2023
  • 1 reply
  • 5365 views

Hi all.

I'm developing a QT/QML application for my embedded openSTLinux project. This application has to play some videos with relative audio. I'm trying to play a mp4 file. If I use the following

 

gst-launch-1.0 playbin uri=file:///home/root/media/my_video.mp4 video-sink="waylandsink sync=false"

audio and video are played correctly. Instead, if I use QML code, for example this  

Item {

 id: idVideo

 visible: true

 width: 1024
 height: 600

 Video {
 id: videoExample
 anchors.fill: parent
 source: "file:///home/root/media/my_video.mp4"
 autoPlay: true
 
 focus: true
 }
}

or this

Item {

 id: idVideo

 visible: true

 width: 1024
 height: 600

 MediaPlayer {
 id: mdpExample
 source: "file:///home/root/media/my_video.mp4"
 autoPlay: true
 }
 
 
 VideoOutput {
 id: videoExample
 anchors.fill: parent
 source: mdpExample
 }
}

the display shows nothing (black screen) but the audio is played correctly.

Below the "gstreamer" plugins I have installed in my openSTLinux image

gstreamer1.0 \
gstreamer1.0-plugins-good \
gstreamer1.0-plugins-base \
gstreamer1.0-plugins-bad \
gstreamer1.0-plugins-ugly \
gstreamer1.0-rtsp-server \
gstreamer1.0-omx \
gstreamer1.0-libav \
gstreamer1.0-dev \
gst-validate \
gst-examples \

How can I solve the problem?

Thanks

Regards

 

 

      

This topic has been closed for replies.

1 reply

Erwan SZYMANSKI
Technical Moderator
July 17, 2023

Hello @nataut ,
I think your issue is related to the way you code your QML app to play the video.
I made a such kind of demonstration, and please see below the way I use Video Player:

 MediaPlayer {
 id: mediaPlayerVideos
 source: "gst-pipeline: filesrc location=/home/weston/database/videos/" + video_src + " ! avidemux ! jpegdec ! qtvideosink"
 autoLoad: false
 autoPlay: false
 loops: MediaPlayer.Infinite
 // loops: 1 /* Play only once */
 }

 VideoOutput {
 id: videosOutput

 width : videoPlayer.width
 height : videoPlayer.height * 0.8
 opacity: 0.9
 anchors.top: parent.top
 source: mediaPlayerVideos
 focus: true
 visible: true
 }


Of course, you will have to adapt the Gstreamer pipeline to your case, but what is important is to also use the "qtvideosink" at the end, to well integrate the video inside your Qt UI.

Please try to get inspire by this example and tell me your feedback if you can.

Kind regards,
Erwan.

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
nataut
natautAuthor
Associate III
October 20, 2023

Hello @Erwan SZYMANSKI ,

I'm sorry but I only noticed your response today

I tried your suggestion. I used the following pipelines

"gst-pipeline: filesrc location=/home/root/media/video_test.avi ! avidemux ! jpegdec ! qtvideosink"
"gst-pipeline: filesrc location=/home/root/media/video_test.avi ! decodebin name=dec ! videoconvert ! qtvideosink"
"gst-pipeline: filesrc location=/home/root/media/video_test.avi ! decodebin name=dec ! videoconvert ! waylandsink"
"gst-pipeline: filesrc location=/home/root/media/video_test.mp4 ! avidemux ! jpegdec ! qtvideosink"
"gst-pipeline: filesrc location=/home/root/media/video_test.mp4 ! decodebin name=dec ! videoconvert ! qtvideosink"
"gst-pipeline: filesrc location=/home/root/media/video_test.mp4 ! decodebin name=dec ! videoconvert ! waylandsink"

but I have always the following error

Error: "No URI handler implemented for \"gst-pipeline\"."

Thanks

Best regards 

Erwan SZYMANSKI
Technical Moderator
October 20, 2023

Hello @nataut ,
No problem for the delay, we know we had a little issue with mail notification and we apologize for that :)

Hmm I see. Which version of QtMultimedia do you import in your QML code ? In mine where things are working fine, I have followings imports :

import QtQuick 2.9
import QtQuick.Window 2.9
import QtQuick.Controls 2.9
import QtMultimedia 5.11
import QtQuick.Controls 1.4 as QQC1
import QtQuick.Controls.Styles 1.4

If it changes nothing, can you tell me which OpenSTLinux do you use, and how did you generate your main SW image (Yocto, Starter image ?).

Rgs,
Erwan.

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.