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:
Yep, I have been using this for a while and it works wonders.
I have recorded this just yesterday using OBS and the NVENC encoder.
View video on youtube.com
As you can see, really nice fullHD at 60 fps.
I am on a i5-4670K clocked at 3.9GHz with a 2GB GTX760.
The only other thing I did "specially" was that I was recording this to RAM, rather than my HDD which seems to help random freezups through the video.
You can achieve that on ubuntu like distros by simply using file browser in OBS and recording to /dev/shm but keep in mind that IS your ram right there, and if you overfill it, you WILL run out of ram, and will have an ugly time (And people kept trying to tell me that 16GB of ram is unnecessary :] ). Also, it obviously doesn't survive reboot.
I have recorded this just yesterday using OBS and the NVENC encoder.
View video on youtube.com
As you can see, really nice fullHD at 60 fps.
I am on a i5-4670K clocked at 3.9GHz with a 2GB GTX760.
The only other thing I did "specially" was that I was recording this to RAM, rather than my HDD which seems to help random freezups through the video.
You can achieve that on ubuntu like distros by simply using file browser in OBS and recording to /dev/shm but keep in mind that IS your ram right there, and if you overfill it, you WILL run out of ram, and will have an ugly time (And people kept trying to tell me that 16GB of ram is unnecessary :] ). Also, it obviously doesn't survive reboot.
0 Likes
Quoting: KithopYeah, just an FYI - if you're on a Debian-derivative (e.g. Ubuntu) and want proper ffmpeg packages?
apt-get source ffmpeg
tells you you should instead run:
git clone https://anonscm.debian.org/git/pkg-multimedia/ffmpeg.git
Then you just add '--enable-nonfree' and '--enable-nvenc' to the debian/rules file, and run:
debuild -us -uc -b
optionally, you can also add -j4 or -j8 for a multithreaded build
That will give you nice .deb packages in the parent directory you can just dpkg -i :) None of this clobbering system packages with manual ./configure && make && sudo make install ... that way lies pain. Lots and lots of pain.
Similarly, while their repo is out-of-date, after you've added OBS Studio's PPA, it's just:
apt-get source obs-studio
cd into folder
debuild -us -uc -b
And voila, obs-studio.deb - their other install instructions however have a bit different method, but in the end they do actually properly build and register a package in apt, so whatever, it's all good.
(and don't forget toapt-mark hold obs-studio
!)
Neat, did not know that
Last edited by kellerkindt on 27 October 2016 at 7:31 pm UTC
0 Likes
Nice and all but I really can't believe there's no other way to get this other than put lots of commands in the terminal...
I have no problem with that as I am a technical user, but for other people, this is a real put-off.
Last edited by 1mHfoksd1Z on 27 October 2016 at 7:42 pm UTC
I have no problem with that as I am a technical user, but for other people, this is a real put-off.
Last edited by 1mHfoksd1Z on 27 October 2016 at 7:42 pm UTC
0 Likes
Quoting: liamdaweYeah, I've heard that too initially. There were some reports about them overheating and being too noisy, but is not true (or it was with initial models?). Is an excellent card, I am using it extensively for a while now and never had any problem with it. As for the image quality that it can provide there's nothing coming close to it in its category.Quoting: dubigrasuHeh, I've heard the opposite, seen a fair amount of complaints about not just the experience with them on Linux, but the build quality of their cards is apparently bad.Quoting: liamdawe....Both of which are a bit iffy under Linux with hardware support.I guess it depends on what card you're thinking about. My only experience with such cards is with a Blackmagic card that can be used both internally or externally without any performance penalties, and its software/hardware support is excellent.
You can see it unboxed and tested by Penguin Recordings here:
View video on youtube.com
View video on youtube.com
Last edited by dubigrasu on 27 October 2016 at 7:51 pm UTC
0 Likes
Quoting: HoriNice and all but I really can't believe there's no other way to get this other than put lots of commands in the terminal...
I have no problem with that as I am a technical user, but for other people, this is a real put-off.
Shame on Nvidia that always provides us with non Open Source software..
0 Likes
Someone can always build ffmpeg with nvenc and put it into a repository. Most don't do that because not everyone has NVIDIA cards.
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!
P.S. Lucky for me, I have exactly GeForce GTX 650!
1 Likes, Who?
Quoting: KithopYeah, just an FYI - if you're on a Debian-derivative (e.g. Ubuntu) and want proper ffmpeg packages?
apt-get source ffmpeg
tells you you should instead run:
git clone https://anonscm.debian.org/git/pkg-multimedia/ffmpeg.git
Then you just add '--enable-nonfree' and '--enable-nvenc' to the debian/rules file, and run:
debuild -us -uc -b
optionally, you can also add -j4 or -j8 for a multithreaded build
That will give you nice .deb packages in the parent directory you can just dpkg -i :) None of this clobbering system packages with manual ./configure && make && sudo make install ... that way lies pain. Lots and lots of pain.
Similarly, while their repo is out-of-date, after you've added OBS Studio's PPA, it's just:
apt-get source obs-studio
cd into folder
debuild -us -uc -b
And voila, obs-studio.deb - their other install instructions however have a bit different method, but in the end they do actually properly build and register a package in apt, so whatever, it's all good.
(and don't forget toapt-mark hold obs-studio
!)
I also had to download the NVIDIA SDK I remember:
https://developer.nvidia.com/nvidia-video-codec-sdk
I need some header files from the SDK. But maybe they are come from other sources on your system.
0 Likes
Quoting: cxphergmailcomSomeone can always build ffmpeg with nvenc and put it into a repository. Most don't do that because not everyone has NVIDIA cards.
Quoting: PixelPiI also had to download the NVIDIA SDK I remember:
https://developer.nvidia.com/nvidia-video-codec-sdk
I need some header files from the SDK. But maybe they are come from other sources on your system.
This is exactly the problem, FYI - the required headers from nVidia are non-free and thus the resulting ffmpeg packages are legally non-redistributable.
However, --enable-vaapi for Intel QuickSync is free, and just needs OBS to support it, and presumably I'm hoping with AMD's 'open source all the things' bent lately, we might see VCE support the same way.
1 Likes, Who?
Quoting: KithopThat will give you nice .deb packages in the parent directory you can just dpkg -i :) None of this clobbering system packages with manual ./configure && make && sudo make install ... that way lies pain. Lots and lots of pain.
pacman, pacman, where are thou?
1 Likes, Who?
See more from me