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.
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.
I hope this will help some of you when recording or livestreaming games on Linux.
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.
Spoiler, click me
# 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
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
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.
I hope this will help some of you when recording or livestreaming games on Linux.
Some you may have missed, popular articles from the last month:
All posts need to follow our rules. For users logged in: please hit the Report Flag icon on any post that breaks the rules or contains illegal / harmful content. Guest readers can email us for any issues.
So, how can I get this working on Arch Linux?
0 Likes
So, how can I get this working on Arch Linux?
In AUR repos someone already did, the packages is called ffmpeg-nvenc or ffmpeg-full-nvenc :D
0 Likes
So, how can I get this working on Arch Linux?
I tried on Antergos but the install of package ffmpeg-full-nvenc conflicts with Chromaprint. I managed to remove just that package without removing dependencies by pacman -Rdd chromaprint but then the install fails at installing flite do to a compiling error so I think I'm going to have to try doing it as close to this guide as I can get with Arch. I'll post what I did if I get it working. I couldn't find much with the Goog's with Arch users getting it to work.
Last edited by staticx27 on 27 October 2016 at 10:49 pm UTC
0 Likes
liamdawe,
Please add missing dep for the installation guide. You also need install ffmpeg itself, because this command:
will not work.
Please add missing dep for the installation guide. You also need install ffmpeg itself, because this command:
ffmpeg -buildconf
will not work.
0 Likes
Yes, it is very useful, but you will need to replace system's ffmpeg with a custom one, which is a hassle, and the card needs to be no less then GeForce GTX 650.
P.S. Lucky for me, I have exactly GeForce GTX 650!
Dont need GTX 650 minimum, GK208 works and stay present in various models case: GT 630 v2, GT 640 v2, GT 710, GT 720, GT 730
But GM108 dont have any hardware unit for decode or encode video (very annoying nvidia)
https://developer.nvidia.com/nvidia-video-codec-sdk
Except GM108 in the Maxwell generation of GPUs, which does not contain any video encoder or decoder HW.
Without forget download lastest nvenc sdk (7.0) needs stay register on nvidia
However before versions to 7.0 can be downloaded freely for now here
https://developer.nvidia.com/video-codec-sdk-archive
^_^
Last edited by mrdeathjr on 27 October 2016 at 11:34 pm UTC
1 Likes, Who?
please delete double post
Last edited by mrdeathjr on 27 October 2016 at 11:31 pm UTC
Last edited by mrdeathjr on 27 October 2016 at 11:31 pm UTC
0 Likes
Is posible to use a second graphics card for this? You know.. Two graphic cards on the same machine; a GTX 970 for gaming and a GTX 750 for this...
1 Likes, Who?
... and the card needs to be no less then GeForce GTX 650.
P.S. Lucky for me, I have exactly GeForce GTX 650!
OMG! rly?! GeForce GTX 650 TI BOOST here
0 Likes
So, how can I get this working on Arch Linux?
In AUR repos someone already did, the packages is called ffmpeg-nvenc or ffmpeg-full-nvenc :D
I got it working on Antergos (Arch) with a whole lotta work. And by "whole lotta work", I mean I did a lot of learning. Now this might be because of my setup and programs I have installed causing these problems, but for most of the errors I got, it was because the packages in the AUR weren't compiling correctly.. I would suggest trying to install ffmpeg-full-nvenc and see if you get errors about the packages I'm suggesting to install first.. AUR isn't perfect. To the best of my terminal history and brain, here's what I did (from ~/):
Remove chromaprint as it conflicts with chromeprint-fftw. This will remove chromaprint without removing dependencies
sudo pacman -Rdd chromaprint
Remove currently installed ffmpeg
sudo pacman -Rdd ffmpeg
Download and install flite as it does not build properly from AUR
git clone https://aur.archlinux.org/flite.git
cd flite
makepkg -ci
cd ..
Download and install nvidia-sdk as it doesn't build properly from AUR.
git clone https://aur.archlinux.org/nvidia-sdk.git
wget https://developer.nvidia.com/video-sdk-601
You can also download Video_Codec_SDK_7.0.1.zip from Nvidia's developers page. Just make sure you download it or move it to nvidia-sdk/ .You have to create an account or I have it on MegaSync: link .
cd nvidia-sdk
nano pkgbuild
Find "" source=("file://Video_Codec_SDK_${pkgver}.zip" "" and change to "" source=("video-sdk-601" "" #or "" source=("Video_Codec_SDK_7.0.1.zip" "" if you're using updated sdk ..also I'm not sure if .zip has to be at the end of the file...I wouldn't think so, but if it doesn't work, rename video-sdk-601 to video-sdk-601.zip and change in pkgbuild accordingly. I tried with the newer sdk and worked so I didn't get to try with video-sdk-601.
makepkg -ci
sudo pacman -S ffmpeg-full-nvenc
That should have you running. If, like I said, you don't have these problems when trying to install ffmpeg-full-nvenc from pacman, then it's probably either Antergos or programs I have installed conflicting, but by the comments in the AUR for the packages I had to manually install, other people are having these problems too.
Last edited by staticx27 on 28 October 2016 at 5:25 pm UTC
0 Likes
Fully automated script: https://github.com/lutris/ffmpeg-nvencYou don't need to re-compile OBS, I sure didn't. I guess it depends on how you installed OBS originally, mine was from the official PPA, so it's possible they bake support in their official builds already.
FFmpeg + nvenc build script
This script will compile FFmpeg with Nvidia NVENC support enabled. It can also build OBS Studio or Simple Screen Recorder using that FFmpeg build thus providing NVENC for OBS and SSR.
Edit: Actually, I compiled OBS Studio myself when their PPA went out of date using their official instructions, so I really don't think you need to re-compile if you do it using the method I linked to. The reason being, this method uses the same version of FFMPEG your system has right now.
That's correct, you don't need to recompile OBS *if* you install FFmpeg globally. The goal of the script was also to provide an isolated build that could be installed alongside the distribution's package. So in order for OBS to find the FFmpeg build installed in an arbitrary location, it needed to be recompiled. Other than that, it's pretty much a standard build of OBS.
0 Likes
Ah cool, thanks for the guide, was just setting up OBS on my Ubuntu machine to start streaming, and really wondered why I can't use gpu encoder in OBS like on Windows. Thanks Liam!
Now there is only one question left, does anyone know of a software tool which let's me configure the zoom of my webcam? Because my facecam captures a lot of my room and my face is to small. On windows I can just zoom in the capture settings of OBS, on Linux this option is missing, and Video4Linux2 doesn't have a zoom option. Some advice would be cool
Now there is only one question left, does anyone know of a software tool which let's me configure the zoom of my webcam? Because my facecam captures a lot of my room and my face is to small. On windows I can just zoom in the capture settings of OBS, on Linux this option is missing, and Video4Linux2 doesn't have a zoom option. Some advice would be cool
0 Likes
This was rather easy to install for me on Arch. Two AUR packages - nvidia-sdk and ffmpeg-nvenc. A very quick build later and it's working with obs-studio. No audio though as ALSA recording doesn't appear to work for me.
TheDaftRick - same here, I can only use simple mode.
TheDaftRick - same here, I can only use simple mode.
0 Likes
I usually use checkinstall to build my deb files. Should I use this instead:
debuild -us -uc -b
What are the advantages of both methods?
debuild -us -uc -b
What are the advantages of both methods?
0 Likes
<Cut for length>
Seems that neither method works for me. It just refuses to install.
Last edited by Aimela on 28 October 2016 at 4:03 pm UTC
0 Likes
I rebuilt ffmpeg src rpm for magiea so I could use OBS with nvenc, That's what I recorded the Rocket League matches with.
I've found OBS can be a little unstable with it though. Have to be careful what settings you change .
I've found OBS can be a little unstable with it though. Have to be careful what settings you change .
0 Likes
If you set output mode to Advanced and try to select nvenc there, does OBS crash for anyone else?Yes, same here too. So I just use simple mode until this is fixed...
It works fine for me in simple mode, but crashes when selecting nvenc in advanced mode.
0 Likes
If you set output mode to Advanced and try to select nvenc there, does OBS crash for anyone else?Yes, same here too. So I just use simple mode until this is fixed...
It works fine for me in simple mode, but crashes when selecting nvenc in advanced mode.
Unfortunatelly it also crashes for me when selecting it in simple mode. Exactly when I click it. :/
Arch user. Does anyone knows what may be the problem?
0 Likes
Hi Guys,
I hope someone of you can help me. I have tried the Autoscript from the 3 post of the user "kellerkindt". Well and as so often it does not work with me again. What is the problem, and how can I fix it so the script goes through without problems?
![](https://abload.de/img/terminal7doio.png)
Hope you can help me!
I hope someone of you can help me. I have tried the Autoscript from the 3 post of the user "kellerkindt". Well and as so often it does not work with me again. What is the problem, and how can I fix it so the script goes through without problems?
![](https://abload.de/img/terminal7doio.png)
Hope you can help me!
0 Likes
Yeah, just an FYI - if you're on a Debian-derivative (e.g. Ubuntu) and want proper ffmpeg packages?
I second this if the alternative is installing to /usr, although I usually build with pbuilder instead so I'm always building in a somewhat isolated clean environment. For personal use debuild should be fine.
My recording tool of choice is vokoscreen (which is also just a frontend for ffmpeg) and I make any final edits in OpenShot. I've never had the desire to live stream.
0 Likes
You can see it unboxed and tested by Penguin Recordings here:Interesting. The hardware seems to be great -- with OBS, because a software such as Media Express which outputs as MJPEG AVI, and has no keyboard-shortcuts is obviously unusable.
View video on youtube.com
View video on youtube.com
0 Likes
See more from me