I want to play a Video on a Raspberry Pi 4 running Raspberry Pi OS in a Qt5 Application. I'm currently using QMediaPlayer and QVideoWidget as an output. It works perfectly on Windows, but when I build it for the Pi and run it, it shows a blanc Window.
Does it have something to do with Codecs not installed?
I use an absolute path in Windows ("D:/Projekte/Raspi_Video_Test/small.mp4"). I tried multiple path styles on Linux (for example "/home/pi/small.mp4" or "./small.mp4").
Sadly, QMediaPlayer doesn't show any Error massage. My code in mainwindow.cpp looks like this:
QMediaPlayer *player = new QMediaPlayer;
player->setMedia(QUrl::fromLocalFile(path));
qDebug() << "URL = " << player->media().canonicalUrl();
QVideoWidget *videoWidget = new QVideoWidget;
setCentralWidget(videoWidget);
player->setVideoOutput(videoWidget);
player->play();
This code causes following Debug messages on Windows:
URL = QUrl("file:///D:/Projekte/Raspi_Video_Test/small.mp4")
Pause() {
Pause() }
Run() {
Run() }
Pause() {
Pause() }
Stop() {
Stop() }
Pause() {
Pause() }
and on the Raspberry Pi:
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
URL = QUrl("file:///home/pi/small.mp4")