cancel
Showing results for 
Search instead for 
Did you mean: 

Black screen using QML code to play a video

nataut
Associate III

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

 

 

      

8 REPLIES 8
Erwan SZYMANSKI
ST Employee

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.

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 

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.

Hello @Erwan SZYMANSKI ,

I have the following import

import QtQuick 2.11
import QtQuick.Window 2.11
import QtQuick.Controls 2.4
import QtQuick.Layouts 1.11
import QtQuick.Controls 2.4 as Controls
import QtMultimedia 5.11

I use a OpenSTLinux 4.19.94 version and it has been generated by means Yocto 2.6 version

Many thanks

Regards   

@nataut ,
Can I ask you to do a test ? Can you turn the autoplay from true to false ? And then try to activate they play manually by another way ? This is just for test purpose, but I ask myself if I did not face something similar in the past, and if it was due to the fact that the play began too early in comparison with the media settings.

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.

@Erwan SZYMANSKI ,

I tried the code below that generate the start/stop video touching any point of the screen 

Item {

    id: idVideo

    visible: true

    width: 1024
    height: 600

    MediaPlayer {
        id: mdpExample
        source: "gst-pipeline: filesrc location=/home/root/media/video_test.mp4 ! decodebin name=dec ! videoconvert ! waylandsink"
        autoPlay: false
    }


    VideoOutput {
        id: videoExample
        anchors.fill: parent
        source: mdpExample
    }


    MouseArea {
        anchors.fill: parent
        focus: true
        onClicked:
        {
            if( mdpExample.playbackState === MediaPlayer.PlayingState ) {
                mdpExample.pause()
            }
            else {
                mdpExample.play()
            }
        }
    }
}

I have always the same error (the following)

GStreamer; Unable to pause - "gst-pipeline: filesrc location=/home/root/media/video_test.mp4 ! decodebin name=dec ! videoconvert ! waylandsink"
Error: "No URI handler implemented for \"gst-pipeline\"."

 

Many thanks

Regards 

 

 

@nataut, As you are on an old baseline not supported anymore, I do not know what is fetched from Qt on the current one on which you are, and if the feature was already supported...

However, when I look at the version of Qt package you take, it does not make me feel we are far from each other. For now I do not have more idea, do you have the possibility to test on a recent distributition ? 

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.

@Erwan SZYMANSKI 

I have Qt Creator 4.8.2 based on Qt 5.12.1

At the moment I have no possibility to test on a recent distribution

Many thanks

Regards