安装Qt环境
参考:Qt 使用指南 | Bianbu | 进迭时空开发者社区
安装libmpv
apt install libmpv2 libmpv-dev
example
下载mpv-examples
下载地址:https://github.com/mpv-player/mpv-examples/tree/master/libmpv
修改example
使用硬件解码及GPU:
diff --git a/qtexample.cpp b/qtexample.cpp
index 219d12a..0418235 100755
--- a/qtexample.cpp
+++ b/qtexample.cpp
@@ -85,6 +85,8 @@ MainWindow::MainWindow(QWidget *parent) :
// Enable keyboard input on the X11 window. For the messy details, see
// --input-vo-keyboard on the manpage.
mpv_set_option_string(mpv, "input-vo-keyboard", "yes");
+ mpv_set_option_string(mpv, "vd", "h264_stcodec"); // h264硬解
+ mpv_set_option_string(mpv, "gpu-context", "x11egl");
// Let us receive property change events with MPV_EVENT_PROPERTY_CHANGE if
// this property changes.
编译
cd libmpv/qt
qmake
make
配置环境变量
开启Xwayland硬件渲染
注释/etc/environment中XWAYLAND_NO_GLAMOR环境变量,重启生效。
GDK_GL=gles
#XWAYLAND_NO_GLAMOR=1
SDL_VIDEODRIVER=wayland
MESA_LOADER_DRIVER_OVERRIDE=pvr
指定应用程序窗口系统
export QT_QPA_PLATFORM=xcb
运行
./qtexample