Topic: OFFICIAL Guide For SVP/NVENC Transcoding On Ubuntu 16.04 - 18.04
1.)Clone the latest git of mpv, which will contain build scripts for libass and ffmpeg.
Follow the instructions on this website, regarding the necessary dependencies to compile mpv.
https://github.com/mpv-player/mpv-build
2.)In order for nvenc to be supported, the option must be enabled in ffmpeg.
cd into /mpv-build and execute the following commands. (The first three are mandatory for encoding to work in general)
echo --enable-libx264 >> ffmpeg_options
echo --enable-libmp3lame >> ffmpeg_options
echo --enable-libfdk-aac >> ffmpeg_options
echo --enable-nvenc >> ffmpeg_options
echo --enable-cuvid >> ffmpeg_options
3.)You must clone the nvenc headers git and make/install
git clone https://git.videolan.org/git/ffmpeg/nv-codec-headers.git
make
sudo make install
4.) Install libvapoursynth-dev from the djcj/vapoursynth repository
https://launchpad.net/~djcj/+archive/ubuntu/vapoursynth
5.)Add vapoursynth support by executing the following:
echo --enable-vapoursynth > mpv_options
6.)Execute the following:
./rebuild -j4
Don't panic, the script might fail because you forgot to install a dependency.
This output will pop up, detailing the options/packages that have been enabled/disabled or not found
Should an essential package not have been found, check which one and it's version number, install it and run ./rebuild -j4 again.
Checking for compiler flags -Werror=implicit-function-declaration : yes
Checking for compiler flags -Wno-error=deprecated-declarations : yes
Checking for compiler flags -Wno-error=unused-function : yes
Checking for compiler flags -Wempty-body : yes
Checking for compiler flags -Wdisabled-optimization : yes
Checking for compiler flags -Wstrict-prototypes : yes
Checking for compiler flags -Wno-format-zero-length : yes
Checking for compiler flags -Werror=format-security : yes
Checking for compiler flags -Wno-redundant-decls : yes
Checking for compiler flags -Wvla : yes
Checking for LGPL (version 2.1 or later) build : disabled
Checking for GPL (version 2 or later) build : yes
Checking for internal audio filter chain : yes
Checking for mpv CLI player : yes
Checking for shared library : disabled
Checking for static library : disabled
Checking for static build : disabled
Checking for whether to include binary compile time : yes
Checking for whether to optimize : yes
Checking for whether to compile-in debugging information : yes
Checking for manpage generation : no (missing RST2MAN)
Checking for html manual generation : disabled
Checking for pdf manual generation : disabled
Checking for dynamic loader : yes
Checking for C plugins : yes
Checking for zsh completion : disabled
Checking for inline assembly (currently without effect) : yes
Checking for test suite (using cmocka) : disabled
Checking for generate a clang compilation database : disabled
Checking for compiler support for noexecstack : yes
Checking for linker support for --nxcompat --no-seh --dynamicbase : no
Checking for -lm : yes
Checking for MinGW : os-win32 not found
Checking for POSIX environment : yes
Checking for Android environment : no
Checking for development environment : yes
Checking for Universal Windows Platform : disabled
Checking for win32 desktop APIs : os-win32 not found
Checking for internal pthread wrapper for win32 (Vista+) : posix found
Checking for POSIX threads : yes
Checking for GNU C extensions : yes
Checking for stdatomic.h : yes
Checking for stdatomic.h support or slow emulation : yes
Checking for linking with -lrt : yes
Checking for iconv : yes
Checking for w32/dos paths : os-win32 not found
Checking for spawnp()/kill() POSIX support : yes
Checking for spawnp()/kill() Android replacement : posix-spawn-native found
Checking for any spawnp()/kill() support : yes
Checking for Windows pipe support : posix found
Checking for glob() POSIX support : yes
Checking for glob() win32 replacement : posix found
Checking for any glob() support : yes
Checking for fchmod() : yes
Checking for vt.h : yes
Checking for gbm.h : no
Checking for GLIBC API for setting thread name : yes
Checking for OSX API for setting thread name : glibc-thread-name found
Checking for BSD API for setting thread name : glibc-thread-name found
Checking for BSD's fstatfs() : no
Checking for Linux's fstatfs() : yes
Checking for Samba support (makes mpv GPLv3) : disabled
Checking for Lua : no ('luajit >= 2.0.0' not found)
Checking for Javascript (MuJS backend) : no ('mujs >= 1.0.0' not found)
Checking for SSA/ASS support : yes
Checking for libass OSD support : yes
Checking for dummy OSD support : libass-osd found
Checking for zlib : yes
Checking for Bluray support : no ('libbluray >= 0.3.0' not found)
Checking for dvdread support : disabled
Checking for dvdnav support : disabled
Checking for DVD/IFO support : dvdread not found
Checking for cdda support (libcdio) : disabled
Checking for uchardet support : no ('uchardet' not found)
Checking for librubberband support : no ('rubberband >= 1.8.0' not found)
Checking for LCMS2 support : no ('lcms2 >= 2.6' not found)
Checking for VapourSynth filter bridge (Python) : yes
Checking for VapourSynth filter bridge (Lazy Lua) : lua not found
Checking for VapourSynth filter bridge (core) : yes
Checking for libarchive wrapper for reading zip files and more : no ('libarchive >= 3.0.0' not found)
Checking for SDL2 : disabled
Checking for OSS : yes
Checking for RSound audio output : no
Checking for sndio audio input/output : disabled
Checking for PulseAudio audio output : no ('libpulse >= 1.0' not found)
Checking for JACK audio output : no ('jack' not found)
Checking for OpenAL audio output : disabled
Checking for OpenSL ES audio output : no
Checking for ALSA audio output : no ('alsa >= 1.0.18' not found)
Checking for CoreAudio audio output : no
Checking for AudioUnit output for iOS : no
Checking for WASAPI audio output : os-win32 not found
Checking for Cocoa : no
Checking for DRM : yes
Checking for DRM Prime ffmpeg support : yes
Checking for GBM : gbm.h not found
Checking for wayland-scanner : yes
Checking for wayland-protocols : no ('wayland-protocols >= 1.14' not found)
Checking for Wayland : wayland-protocols not found
Checking for X11 : no ('x11 >= 1.0.0 xscrnsaver >= 1.0.0 xext >= 1.0.0 xinerama >= 1.0.0 xrandr >= 1.2.0' not found)
Checking for Xv video output : x11 not found
Checking for OpenGL Cocoa Backend : cocoa not found
Checking for OpenGL X11 Backend : x11 not found
Checking for OpenGL X11 EGL Backend : x11 not found
Checking for OpenGL DRM EGL Backend : gbm not found
Checking for OpenGL Wayland Backend : wayland not found
Checking for OpenGL Win32 Backend : win32-desktop not found
Checking for OpenGL/DirectX Interop Backend : gl-win32 not found
Checking for OpenGL ANGLE headers : os-win32 not found
Checking for OpenGL Win32 ANGLE Library : egl-angle not found
Checking for OpenGL Win32 ANGLE Backend : egl-angle not found
Checking for VDPAU acceleration : x11 not found
Checking for VDPAU with OpenGL/X11 : vdpau not found
Checking for VAAPI acceleration : x11 not found
Checking for VAAPI (X11 support) : vaapi not found
Checking for VAAPI (Wayland support) : vaapi not found
Checking for VAAPI (DRM/EGL support) : vaapi not found
Checking for VAAPI GLX : vaapi-x11 not found
Checking for VAAPI EGL on X11 : vaapi-x11 not found
Checking for VAAPI EGL : vaapi-x-egl not found
Checking for CACA : no ('caca >= 0.99.beta18' not found)
Checking for JPEG support : no
Checking for Direct3D support : win32-desktop not found
Checking for libshaderc SPIR-V compiler (shared library) : no
Checking for libshaderc SPIR-V compiler (static library) : no
Checking for libshaderc SPIR-V compiler : shaderc-shared not found
Checking for libcrossc SPIR-V translator : no ('crossc' not found)
Checking for Direct3D 11 video output : win32-desktop not found
Checking for Raspberry Pi support : no
Checking for iOS OpenGL ES hardware decoding interop support : no
Checking for OpenGL without platform-specific code (e.g. for libmpv) : libmpv-shared not found
Checking for MALI via Linux fbdev : no
Checking for OpenGL context support : gl-cocoa not found
7.) Once you have successfully compiled mpv, simply execute the following in order to install it locally, which is not necessary as you can simply copy /mpv-build/build/mpv into /usr/local/bin
sudo ./install
8.) Finally, the SVP command for transcoding with NVENC will cause an error as it uses the option --ofps which has apparently been deprecated with the latest git of mpv.
I have been using this with a script to launch it for now.
mpv /home/donald/Downloads/sintel.mkv -o output --no-audio --no-sub --no-sub-auto --input-ipc-server=mpvencodepipe --vf=vapoursynth:/home/donald/60fps.vpy:4:16 --of=matroska --ovc=h264_nvenc --ovcopts=b=11055051,rc=vbr_hq,preset=slow,profile=high,threads=16
Playing: /home/donald/Downloads/sintel.mkv
(+) Video --vid=1 (h264 1920x818 24.000fps)
Audio --aid=1 --alang=eng 'AC3 5.1 @ 640 Kbps' (ac3 6ch 48000Hz)
VO: [lavc] 1920x818 yuv420p
[vo/lavc] Opening encoder: NVIDIA NVENC H.264 encoder [h264_nvenc]
[encode] Opening output file: output
[encode] Opening muxer: Matroska [matroska]
V: 00:04:36 / 00:14:48 (31%) {5.5min 111.6fps 2349.6MB}
V: 00:04:42 / 00:14:48 (31%) {5.4min 111.6fps 2354.5MB}
V: 00:04:55 / 00:14:48 (33%) {5.3min 111.3fps 2370.3MB}
Cheers!