I am working on ubuntu 14.04 with Qt 5.8 and trying to play video in my application using Qt multimedia module. I put "QT += quick multimedia" in ".pro".
ContentVideo.qml
import QtQuick 2.1
import QtMultimedia 5.0
Rectangle {
width: 400
height: 400
color:"black"
MediaPlayer {
id: mediaPlayer
autoPlay: true
autoLoad: true
source:"/home/macos/Desktop/FroggerHighway.mp4"
}
VideoOutput {
id:videoOutput
source:mediaPlayer
anchors.fill: parent
}
}
main.qml
import QtQuick 2.1
import QtQuick.Window 2.1
Window {
id: root
color: "black"
width: 400
height: 400
visible: true
ContentVideo {
anchors.fill: parent
}
}
My video is not running and I am getting black screen without any error. QT QML EXAMPLES video is working on my PC. Any help will appreciated, Thank you.
MediaPlayer.source is a URI and I don't think the value you are specifying is a valid URI. Try adding "file://" in front of the path the the mp4 file.
I had just met the same issue as yours, it seems that QtMultimedia will looking for decoders from gstreamer in system at run time, so I install video codec package:
sudo apt-get install gstreamer1.0-libav gstreamer1.0-vaapi
Then qml video player works correctly now
If the QML video examples work without any issues it's probably a problem that comes from the lack of codecs to encode your video. Check if you have all the Multimedia Dependencies. My guess is that the provided video samples are encoded in a open format the support for which is provided by default by your distro.
Add QT+= multimedia
to your .pro
file.
I faced the same problem on Arch and Debian. After installing the following packages, everything works fine.
ARCH:
Installed with yay
:
yay -S gstreamer gstreamer0.10 gst-plugins-base-libs gst-plugins-good gst-libav qt5-tools
Debian:
Installed with apt
:
apt install libqt5multimedia5-plugins
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With