Skip to content

Latest commit

 

History

History
126 lines (100 loc) · 7.24 KB

README.Linux.md

File metadata and controls

126 lines (100 loc) · 7.24 KB

MDK: Multimedia Development Kit

Features

About SDK for Linux

SDK is built by clang 18 with

SDK can be used by any C or C++11 compiler, e.g. g++, clang

dsym files are debug symbols, not required to deploy your programe.

ubuntu>=14.04(maybe 12.04)

  • glibc >= 2.14
  • libc++1, libc++abi1: not using gnu stl because libc++ has better compatibility. previous sdks depend on glibc++ 3.4.22(g++6)
  • libva version 2 or 1: libva2, libva-x11-2, libva-drm2 or libva1, libva-x11-1, libva-drm1. Running apt install vainfo will install these
  • libasound2, libpulse0
  • libwayland-client0
  • libgbm1
  • libgl1-mesa-glx

Optional:

  • libegl1-mesa: egl context
  • libvdpau1: vdpau rendering. (required by ffmpeg decoder)
  • libwayland-egl1: wayland surface and egl context support
  • libass5~9 to support subtitle
  • libopenal1
  • libsdl2: sdlplay example

Environment Vars:

  • GL_EGL: 0 = use glx context, 1 = use egl context (if created by mdk)
  • GL_ES: 0 = use opengl, 1 = use opengl es (if created by mdk)
  • VDPAU_GL: video = interop with video surface, output = interop with output surface, pixmap = interop with x11 pixmap(required by egl from x11)
  • VAAPI_GL: x11 = interop with glx/egl(via x11 pixmap), drm = interop with drm prime, drm2 = interop with drm prime2
  • CUDA_STREAM: 0/1
  • CUDA_PBO: 0/1
  • CUDA_HOST: 0/1
  • CUDA_DEVICE: number
  • OpenGL
  • OpenGL ES2/3: via EGL, GLX, ANGLE or others. the default if EGL is available.
  • Vulkan: broken now
  • FFmpeg, VDPAU, VAAPI, CUDA, QSV(not tested), NVDEC
  • command line: -c:v decodername

DRM Prime

RaspberryPi OS system ffmpeg provides hevc and v4l2m2m drm_prime frame output, you can use system ffmpeg(delete libffmpeg.so.* in sdk package) with OpenGLES(desktop GL does not support hevc) contexts created from EGL to get maximum performance. glfwplay option to test:

  • x11: ./glfwplay -c:v V4L2M2M,FFmpeg:hwcontext=drm:sw_fallback=1 -gl test.mp4
  • wayland: ./glfwplay -c:v V4L2M2M,FFmpeg:hwcontext=drm:sw_fallback=1 -es test.mp4, you have to install glfw sudo apt install libglfw3-wayland

RaspberryPi OS rendering performance is poor, you may have to disable log, log to file or minimize terminal to get higher fps, otherwise rendering log may slow down video rendering. wayland environment has better performance

Examples

GL Context

  • Created by MDK: glfwplay -gl:opengl=1, glfwplay -gl:opengl=1:egl=1, glfwplay -gl, mdkplay, x11win
  • Foreign Context: glfwplay, multiplayers, multiwindows (via glfw), sdlplay(via sdl)

Gapless Playback for Any Media:

  • mdkplay(or glfwplay/window/sdlplay) file file2 ...

N players for 1 video: multiplayers -share -win N url

N videos and N players: multiplayers -share url1 url2 ... urlN

N videos renderers for 1 player: multiwidnows url

Use in CMake Projects

	include(mdk-sdk-dir/lib/cmake/FindMDK.cmake)
	target_link_libraries(your_target PRIVATE mdk)

Qt qmake project

include($$MDK_SDK_DIR/mdk.pri)

Recommended settings

  • Linux:
    // XInitThreads(); // If using x11. before any x11 api call. some gui toolkits already call this, e.g. qt, glfw
    SetGlobalOption("X11Display", DisplayPtr); // If using x11. Requred by VAAPI, VDPAU
    player.setDecoders(MediaType::Video, {"VAAPI", "VDPAU", "CUDA", "hap", "FFmpeg", "dav1d"});
  • Raspberry Pi: use mdk-sdk-linux.tar.xz, delete libffmpeg.so.* to use system ffmpeg to support h264, hevc hardware decoder and 0-copy rendering
    player.setDecoders(MediaType::Video, {"V4L2M2M", "FFmpeg:hwcontext=drm", "FFmpeg"});

Source code:

Copyright (c) 2016-2024 WangBin(the author of QtAV) Free for opensource softwares, non-commercial softwares, flutter, QtAV donors and contributors.