diff options
author | Ivan Kozik <ivan@ludios.org> | 2019-08-30 19:54:08 +0000 |
---|---|---|
committer | Ivan Kozik <ivan@ludios.org> | 2019-09-06 23:18:26 +0000 |
commit | 46cbb8453afa5b74612ffd795cfbcab71e3d141a (patch) | |
tree | 78dadbf2da8360a923eeec3ebd428092463db953 /pkgs | |
parent | 60db597e86e289ef61dcac551060f571fb366f8e (diff) | |
download | nixpkgs-46cbb8453afa5b74612ffd795cfbcab71e3d141a.tar nixpkgs-46cbb8453afa5b74612ffd795cfbcab71e3d141a.tar.gz nixpkgs-46cbb8453afa5b74612ffd795cfbcab71e3d141a.tar.bz2 nixpkgs-46cbb8453afa5b74612ffd795cfbcab71e3d141a.tar.lz nixpkgs-46cbb8453afa5b74612ffd795cfbcab71e3d141a.tar.xz nixpkgs-46cbb8453afa5b74612ffd795cfbcab71e3d141a.tar.zst nixpkgs-46cbb8453afa5b74612ffd795cfbcab71e3d141a.zip |
mpv, ffmpeg: use addOpenGLRunpath to fix CUDA-accelerated playback
This fixes #67780. Currently, using `mpv --hwdec=nvdec --msg-level=vd=debug` on NVIDIA results in: ``` [vd] Opening decoder hevc [vd] Looking at hwdec hevc-nvdec... Cannot load libcuda.so.1 [vd] Could not create device. [vd] No hardware decoding available for this codec. ``` With just mpv patched, ffmpeg cannot load libnvcuvid.so.1: ``` [vd] Opening decoder hevc [vd] Looking at hwdec hevc-nvdec... [vd] Trying hardware decoding via hevc-nvdec. [vd] Selected codec: hevc (HEVC (High Efficiency Video Coding)) [vd] Pixel formats supported by decoder: vaapi_vld cuda yuv420p10le [vd] Codec profile: Main 10 (0x2) [vd] Requesting pixfmt 'cuda' from decoder. [ffmpeg/video] hevc: Cannot load libnvcuvid.so.1 [ffmpeg/video] hevc: Failed loading nvcuvid. [ffmpeg/video] hevc: Failed setup for format cuda: hwaccel initialisation returned error. ``` With both mpv and ffmpeg patched, it works: ``` [vd] Opening decoder hevc [vd] Looking at hwdec hevc-nvdec... [vd] Trying hardware decoding via hevc-nvdec. [vd] Selected codec: hevc (HEVC (High Efficiency Video Coding)) [vd] Pixel formats supported by decoder: vaapi_vld cuda yuv420p10le [vd] Codec profile: Main 10 (0x2) [vd] Requesting pixfmt 'cuda' from decoder. Using hardware decoding (nvdec). [vd] Decoder format: 3840x2160 cuda[p010] bt.2020-ncl/bt.2020/pq/limited/auto SP=10.000000 CL=unknown (auto 0.000000/0.000000/0.000000) ```
Diffstat (limited to 'pkgs')
-rw-r--r-- | pkgs/applications/video/mpv/default.nix | 15 | ||||
-rw-r--r-- | pkgs/development/libraries/ffmpeg/generic.nix | 10 |
2 files changed, 17 insertions, 8 deletions
diff --git a/pkgs/applications/video/mpv/default.nix b/pkgs/applications/video/mpv/default.nix index bb0b92eee03..2a8a0a64274 100644 --- a/pkgs/applications/video/mpv/default.nix +++ b/pkgs/applications/video/mpv/default.nix @@ -1,6 +1,6 @@ { config, stdenv, fetchurl, fetchFromGitHub, makeWrapper -, docutils, perl, pkgconfig, python3, which, ffmpeg_4 -, freefont_ttf, freetype, libass, libpthreadstubs, mujs +, addOpenGLRunpath, docutils, perl, pkgconfig, python3, which +, ffmpeg_4, freefont_ttf, freetype, libass, libpthreadstubs, mujs , nv-codec-headers, lua, libuchardet, libiconv ? null, darwin , waylandSupport ? stdenv.isLinux @@ -135,8 +135,7 @@ in stdenv.mkDerivation rec { ''; nativeBuildInputs = [ - docutils makeWrapper perl - pkgconfig python3 which + addOpenGLRunpath docutils makeWrapper perl pkgconfig python3 which ]; buildInputs = [ @@ -214,11 +213,17 @@ in stdenv.mkDerivation rec { ${wrapperFlags} ''; + # Set RUNPATH so that libcuda in /run/opengl-driver(-32)/lib can be found. + # See the explanation in addOpenGLRunpath. + postFixup = optionalString stdenv.isLinux '' + addOpenGLRunpath $out/bin/.mpv-wrapped + ''; + meta = with stdenv.lib; { description = "A media player that supports many video formats (MPlayer and mplayer2 fork)"; homepage = https://mpv.io; license = licenses.gpl2Plus; - maintainers = with maintainers; [ AndersonTorres fuuzetsu fpletz globin ]; + maintainers = with maintainers; [ AndersonTorres fuuzetsu fpletz globin ivan ]; platforms = platforms.darwin ++ platforms.linux; longDescription = '' diff --git a/pkgs/development/libraries/ffmpeg/generic.nix b/pkgs/development/libraries/ffmpeg/generic.nix index 4c0ca0210cc..b3310e44ae0 100644 --- a/pkgs/development/libraries/ffmpeg/generic.nix +++ b/pkgs/development/libraries/ffmpeg/generic.nix @@ -1,4 +1,4 @@ -{ stdenv, fetchurl, pkgconfig, perl, texinfo, yasm +{ stdenv, fetchurl, pkgconfig, addOpenGLRunpath, perl, texinfo, yasm , alsaLib, bzip2, fontconfig, freetype, gnutls, libiconv, lame, libass, libogg , libssh, libtheora, libva, libdrm, libvorbis, libvpx, lzma, libpulseaudio, soxr , x264, x265, xvidcore, zlib, libopus, speex, nv-codec-headers, dav1d @@ -42,7 +42,7 @@ let inherit (stdenv) isDarwin isFreeBSD isLinux isAarch32; - inherit (stdenv.lib) optional optionals enableFeature; + inherit (stdenv.lib) optional optionals optionalString enableFeature; cmpVer = builtins.compareVersions; reqMin = requiredVersion: (cmpVer requiredVersion branch != 1); @@ -157,7 +157,7 @@ stdenv.mkDerivation rec { "--enable-cross-compile" ] ++ optional stdenv.cc.isClang "--cc=clang"; - nativeBuildInputs = [ perl pkgconfig texinfo yasm ]; + nativeBuildInputs = [ addOpenGLRunpath perl pkgconfig texinfo yasm ]; buildInputs = [ bzip2 fontconfig freetype gnutls libiconv lame libass libogg libssh libtheora @@ -186,6 +186,10 @@ stdenv.mkDerivation rec { substituteInPlace $pc \ --replace "includedir=$out" "includedir=''${!outputInclude}" done + '' + optionalString stdenv.isLinux '' + # Set RUNPATH so that libnvcuvid in /run/opengl-driver(-32)/lib can be found. + # See the explanation in addOpenGLRunpath. + addOpenGLRunpath $out/lib/libavcodec.so* ''; installFlags = [ "install-man" ]; |