- Question / Help NVENC Support For Linux
- SolarLune
- Kithop
- Kithop
- Блог начинающего линуксоида.
- Страницы
- четверг, 19 января 2017 г.
- Сборка OBS Studio и FFmpeg с поддержкой кодека Nvidia NVENC
- OBS NVENC Doesn’t work Out of Box on 20.04?
- 3 Answers 3
- Using Nvidia’s NVENC with OBS Studio makes Linux game recording really great
Question / Help NVENC Support For Linux
SolarLune
New Member
I was trying to get NVENC support up and running for Linux, but wasn’t able to do it, when I saw that some of the commits for OBS Studio included NVENC support (or the ability to select NVENC as the encoder). However, on updating to the latest version of OBS Studio, it doesn’t seem like it’s there; can anyone help me out with this?
For information, I’m running Ubuntu Gnome 16.04, and OBS Studio 0.14.1. I did compile a version of FFMPEG with NVENC support. When I run «ffmpeg» in a terminal, I get «configuration: —enable-non-free —enable-nvenc»; do I need to enable other things, as well? Or is OBS Studio maybe looking at a different version of FFMPEG?
Kithop
New Member
I’ve got the exact same issue. I managed to even build .debs (that no, I’m not allowed to redistribute because of the non-free — this is why we won’t see PPAs). ‘ffmpeg —codecs’ shows nvenc as an option, but OBS still mocks me with ‘Software (x264)’ as the only dropdown option. 🙁 I’d understand if I built it into a weird location, but I went through the Debian way on my Ubuntu system using debuild in the stock paths, to replace my system ffmpeg with the latest clone from master. (v3.0.1).
I’m hoping we don’t have to also build OBS from source once the ffmpeg install is in place before it will detect. because I have no idea how to get the requisite ‘-dev’ bundles out of the build I just did. I’m not a developer or Debian packager, and it took long enough to get this far. ;/
Kithop
New Member
Figured it out! Quick-and-dirty build instructions from memory here:
Under the ‘CONFIG’ list with all the build options, add:
(don’t forget to add a \ to the end of —enable-x11grab to keep it all on one virtual line)
I also had to create a file here to work around a depenency bug later:
$ echo ‘libva 1 libva1’ > ffmpeg/debian/shlibs.local
Then you should be able to build ffmpeg:
$ cd ffmpeg
$ debuild -us -uc -b
Whole bunch of config & compile stuff later. we have everything we need, BUT, it seems that blindly installing *all* the .debs is bad, as there’s a conflict if you do. So you should be fine to remove the one extra and install the rest:
$ cd ..
$ rm libavcodec57_3.0.1-3_amd64.deb
$ sudo dpkg -i *.deb
Hopefully, no conflicts there, so try running:
$ ffmpeg -codecs | grep nvenc
And you should see:
DEV.LS h264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (decoders: h264 h264_crystalhd h264_vdpau ) (encoders: libx264 libx264rgb nvenc nvenc_h264 )
DEV.L. hevc H.265 / HEVC (High Efficiency Video Coding) (encoders: libx265 nvenc_hevc )
Get back up to your temp folder and now grab OBS:
$ cd ..
$ apt-get source obs-studio
$ sudo apt-get build-dep obs-studio
(don’t worry that a bunch of stuff is missing — try to install what you can by hand, ignore all the ‘-ffmpeg-dev’ stuff)
Note: If you can’t seem to pull the source despite having added the OBS PPA, check /etc/apt/sources.list.d — there’ll be an OBS related .list file in there. Uncomment the ‘deb-src’ line, re-run apt-get update, and try again!
Now, OBS is still depending on virtual packages from 15.10 and earlier that appear to have been removed in Xenial/16.04! — thankfully, our ffmpeg build + install does actually have those dependencies, but the packages are named:
libavformat-dev
libavcodec-dev
etc.
All we have to do is tweak OBS’ build rules:
$ vim debian/control
Then find-and-replace out all the ‘-ffmpeg’ instances (e.g. :%s/-ffmpeg//g)
Time to build OBS:
$ debuild -us -uc -b
$ cd ..
$ dpkg -i obs-studio_0.14.1.1-358
If all went well, you should now see NVENC in the Output settings!
Note: You probably also want to run ‘sudo apt-mark hold obs-studio’ here to stop your newly-installed build from being clobbered by the binary package from the PPA. However, you’ll need to keep an eye on the OBS site for updates manually, pull the sources when they do occur, and recompile as above!
One thing I’ve noticed: I did a quick test recording and then played it back with VLC: The first
10 seconds or so tend to be mangled, until it hits a keyframe or something, and then it snaps back into focus. Could just be VLC, though, and it’s relatively minor.
Also, I did this using the old v5.0.1 of the nVidia SDK I had installed from previous experiments. If someone wants to try this with their relatively newly released v6.0.1 instead and report back, it would be awesome! Best of luck! 🙂
Источник
Блог начинающего линуксоида.
советы, руководства, инструкции.
Страницы
четверг, 19 января 2017 г.
Сборка OBS Studio и FFmpeg с поддержкой кодека Nvidia NVENC
Приветствую! Если вы любите делать игровые стримы или просто снимать хорошие летсплеи в Windows, то наверняка знаете о таком потрясающем кодеке, как Nvidia NVENC. На базе этого кодека создана целая утилита для высококачественной записи игрового процесса на видеокартах Nvidia — Shadow Play. Плюс этот кодек может применяться и в других программах для записи происходящего на экране (к примеру Bandicam). К сожалению, ни Shadow Play, ни Bandicam не доступны (пока?) в Linux, но возможность использовать кодек NVENC существует. К примеру в не менее известной программе для создания стримов и записи игр OBS Studio, или в Simple Screen Recorder — лучшей утилите для записи происходящего на экране в Linux. Однако для этого необходим мультимедиа пакет FFmpeg, в котором включена возможность использования NVENC. Но так как кодек проприетарный — в большинстве дистрибутивов Linux FFmpeg собран без поддержки NVENC. Поэтому сейчас мы будем это исправлять в своей любимой системе. Внимание: данное руководство актуально только для Ubuntu 16.04 и основанных на ней дистрибутивов. В системах с FFmpeg 3.1.1 и новее, кодек NVENC доступен по умолчанию.
Кодек NVENC используется специальным аппаратным блоком в новых видеокартах Nvidia, в результате ни процессор, ни видеокарта, никак не нагружаются и не садят FPS в играх. Это также позволяет кодировать видео в невероятно высоких битрейтах.
Итак, что нам для этого потребуется:
- Любой дистрибутив Linux (я буду использовать Debian 8);
- Компьютер с видеокартой Nvidia архитектуры Kepler, Maxwell или Pascal (600, 700, 900 и 1000 серии видеокарт);
- Свежие проприетарные драйверы на видеокарту (для Debian можно взять в бэкпортах, для Ubuntu/Mint есть PPA).
Также для сборки с NVENC необходимы заголовчные файлы из официального Nvidia Video SDK. Разумеется — они несвободны, более того, для 7 версии SDK необходима регистрация на сайте Nvidia и принятие лицензионного соглашения. Однако эти файлы нужны только для сборки. Они не нужны на каждом компьютере.
Изначально я хотел писать длинный и нудный гайд по статической сборке FFmpeg и его зависимостей, описания ключей и прочего, пока не наткнулся на один потрясающий скрипт, который позволяет в полностью автоматическом режиме собрать FFmpeg с NVENC, а также — OBS Studio, с его поддержкой. Поэтому мы пойдём более лёгким способом. Такая сборка будет храниться в отдельном каталоге и не принесёт никаких проблем работающей системе, не заменит системный FFmpeg и не сломает никаких зависимостей. Плюс (если вы будете собирать и OBS) — у вас автоматически появится ярлык в меню приложений. Итак, первым делом нам нужно установить Git:
sudo apt install git
Далее клонируем репозиторий со скриптом, переходим в его директорию и выполняем. По умолчанию сборка будет производиться в каталоге ./ffmpeg-nvenc, с помощью ключа -d вы можете указать путь к другому каталогу. Ключ -o позволит собрать OBS Studio:
git clone https://github.com/Sunderland93/ffmpeg-nvenc.git
cd ffmpeg-nvenc
./build.sh -d /home/username/ffmpeg-nvenc-obs -o
Замените «username» на имя своего пользователя. Далее скрипт всё сделает за вас 🙂 Сборка займёт некоторое время, в зависимости от мощности вашего процессора. После сборки в меню приложений появится ярлык OBS. В работоспособности всей операции можно убедиться зайдя в настройки вывода:
Альтернативный вариант для Debian 8: в моём репозитории есть FFmpeg собранный с NVENC. При установке он заменит собой обычный. А так как в репозитории есть и OBS, и Simple Screen Recorder — после установки они буду сразу иметь поддержку кодека Nvenc. Пользователи Arch Linux могут установить FFmpeg собранный с NVENC из AUR. В будущем планируется добавить всё это в репозиторий для Ubuntu.
Источник
OBS NVENC Doesn’t work Out of Box on 20.04?
I just installed Kubuntu 20.04 and OBS,but NVENC doesn’t seem to work for some reason even though I have nvidia-driver-390 installed and configured via System Settings .
Settings:
Error on Start Recording :
System Settings:
How can I restore OBS’s hardware NVENC support?
3 Answers 3
I installed Ubuntu 20.04 on a fresh machine last night. I did not install an NVidia driver from the NVidia website but rather used the one provided as additional drivers like you did
The OBS installation was done as outlined in the installation steps on the wiki, which means first installing FFmpeg and then adding the obs ppa. Here, NVENC is working out of the box.
In the past on Ubuntu 16.04, I had to compile everything myself (FFmpeg and all its dependencies and then obs) to get NVENC working. The versions I’m using right now are
The difference I notice is that I’m using a more recent NVidia driver. Maybe this helps you to debug the issue.
Источник
Using Nvidia’s NVENC with OBS Studio makes Linux game recording really great
I had been meaning to try out Nvidia’s NVENC for a while, but I never really bothered as I didn’t think it would make such a drastic difference in recording gaming videos, but wow does it ever!
I was trying to record a game recently and all other methods I tried made the game performance utterly dive, making it impossible to record it. So I asked for advice and eventually came to this way.
What is NVENC?
It essentially takes away video encoding from the CPU and does it on the GPU instead, and it’s supported on Nvidia Kepler (600) and above.
Pairing up the awesome open source OBS Studio [Official Site] and compiling FFMPEG with support for Nvidia’s NVENC is actually pretty amazing.
Note: While I have fully tested it myself, I am not responsible if you manage to break anything doing it.
After following this guide (copied below in case it vanishes, thanks Dan).
I’ve done a minor edit to the start, as the filename wget downloads is different to what the guide said.
# Download and unzip the NVIDIA Video Codec SDK from https://developer.nvidia.com/nvidia-video-codec-sdk
wget https://developer.nvidia.com/video-sdk-601
unzip unzip video-sdk-601
# Copy the headers files from the SDK so FFmpeg can find them
sudo cp nvidia_video_sdk_6.0.1/Samples/common/inc/*.h /usr/local/include/
# Make sure «Source code» is enabled in System Settings. -> Software & Updates
# Download the build dependencies for FFmpeg
sudo apt-get build-dep ffmpeg
# Install libfdk_aac
sudo apt-get install libfdk-aac-dev
# Download the source for the exact version of FFmpeg you already have installed (not as root)
apt-get source ffmpeg
# Go into the ffmpeg source you just downloaded
cd ffmpeg-2.8.6
# Find out the exact command the ffmpeg was originally built with
ffmpeg -buildconf
# Copy the single line «configuration:» and pass it to «.configure» but add «—enable-nonfree —enable-nvenc —enable-libfdk-aac» on the end
# Mine looks like this:
./configure —prefix=/usr —extra-version=1ubuntu2 —build-suffix=-ffmpeg —toolchain=hardened —libdir=/usr/lib/x86_64-linux-gnu —incdir=/usr/include/x86_64-linux-gnu —cc=cc —cxx=g++ —enable-gpl —enable-shared —disable-stripping —disable-decoder=libopenjpeg —disable-decoder=libschroedinger —enable-avresample —enable-avisynth —enable-gnutls —enable-ladspa —enable-libass —enable-libbluray —enable-libbs2b —enable-libcaca —enable-libcdio —enable-libflite —enable-libfontconfig —enable-libfreetype —enable-libfribidi —enable-libgme —enable-libgsm —enable-libmodplug —enable-libmp3lame —enable-libopenjpeg —enable-libopus —enable-libpulse —enable-librtmp —enable-libschroedinger —enable-libshine —enable-libsnappy —enable-libsoxr —enable-libspeex —enable-libssh —enable-libtheora —enable-libtwolame —enable-libvorbis —enable-libvpx —enable-libwavpack —enable-libwebp —enable-libx265 —enable-libxvid —enable-libzvbi —enable-openal —enable-opengl —enable-x11grab —enable-libdc1394 —enable-libiec61883 —enable-libzmq —enable-frei0r —enable-libx264 —enable-libopencv —enable-nonfree —enable-nvenc —enable-libfdk-aac
# Now build it
make
# And finally install it over the original
sudo make install
It will take a few minutes to compile, but once that’s done, you’re pretty much set.
I was able to quite easily get FFMPEG sorted with NVENC and hook it into OBS Studio. I’m sure there’s probably better guides (share them in the comments!), but I have yet to find one that makes it so damn simple to do. You don’t even need to do much with OBS Studio, other than change the «Encoder» dropdown once this is sorted:
Note: You shouldn’t need to re-compile OBS Studio, as the guide above uses the same version of FFMPEG as you have already.
What I love about OBS Studio, is it also has custom hotkeys you can set yourself like so:
I have it set so pressing «=» will start or stop recording, which is damn handy as practically no games use that button, if they do, i can simply go back and quickly change the key again.
OBS Studio also has profile support, so you can have one profile for recording and one for livestreaming, which is really useful. They ideally need to roll more of the settings into profiles, as currently the amount that’s stored per-profile is limited.
Источник