QMediaPlayer does not work on NixOS
-
wrote 17 days ago last edited by
I tried building a video player like this:
example.pro
:QT += core gui widgets multimedia multimediawidgets CONFIG += c++17 SOURCES += main.cpp
main.cpp
:#include <QApplication> #include <QWidget> #include <QPushButton> #include <QVBoxLayout> #include <QMediaPlayer> #include <QVideoWidget> #include <QUrl> int main(int argc, char *argv[]) { QApplication app(argc, argv); QWidget window; window.resize(640, 480); QVideoWidget *videoWidget = new QVideoWidget; QMediaPlayer *player = new QMediaPlayer; player->setVideoOutput(videoWidget); //player->setMedia(QUrl::fromLocalFile("/home/user/Downloads/sample-5s.mp4")); // also works player->setMedia(QUrl("https://file-examples.com/storage/feaa6a7f0468517af9bc02d/2017/04/file_example_MP4_480_1_5MG.mp4")); QVBoxLayout *layout = new QVBoxLayout; layout->addWidget(videoWidget); window.setLayout(layout); window.show(); player->play(); return app.exec(); }
If I build and run this under ArchLinux with the packages
qt5-base
andqt5-multimedia
installed, it works fine (except for a segmentation fault on exit, but that is a different topic). If however, I build and run this in nixos withnix-shell -p qt5Full libsForQt5.qt5.qtmultimedia
I get an empty window, with nothing in stdout or stderr. If I run it withQT_DEBUG_PLUGINS=1
I cannot spot anything suspicious in the output.Any idea how to make progress here? Is that a bug in the nixos package of Qt?
-
Hi and welcome to devnet,
Which exact version of Qt are you using ?
Which window manager are running with ?
Which desktop environment are you using ? -
wrote 17 days ago last edited by
Hello SGaist,
Im using QtVersion: 5.15.16 and sway (a wayland compositor).
-
And for the desktop environment ?
-
wrote 16 days ago last edited by
@SGaist said in QMediaPlayer does not work on NixOS:
And for the desktop environment ?
Sway. Nothing else.
I installed it like this:
programs.sway = { enable = true; wrapperFeatures.gtk = true; };
-
wrote 16 days ago last edited by JoeCFD
run
strace your_app
you may be able to find some clues -
wrote 16 days ago last edited by
@JoeCFD said in QMediaPlayer does not work on NixOS:
run
strace your_app
you may be able to find some cluesJust did that.
Here is the result:
https://weissmann.pm/2025-qt5-nixos-bug-strace.txt -
wrote 15 days ago last edited by JoeCFD
openat(AT_FDCWD, "/home/unpriv/.Xdefaults-nichts", O_RDONLY) = -1 ENOENT (No such file or directory)
<====X11 Fallback Attempts. Are your env settings correct for Wayland? Not familiar with your OS.
-
wrote 15 days ago last edited by JoeCFD
setenv( "DISPLAY", ":0", 1 ); setenv( "GDK_BACKEND", "wayland", 1 ); setenv( "QT_QPA_PLATFORM", "wayland", 1 ); setenv( "XDG_RUNTIME_DIR", "/run/user/1000", 1 ); setenv( "WAYLAND_DISPLAY", "wayland-1", 1 ); setenv( "QT_QPA_FONTDIR", "/usr/share/fonts/truetype", 1 );
I need these settings in my Qt code on Yocto wayland .
-
wrote 11 days ago last edited by
Xeyes shows that the application is using X11.
Once I'll find time, I try to force it to use Wayland.
1/10