h265ize icon indicating copy to clipboard operation
h265ize copied to clipboard

Add support for Nvidia gpu encoding

Open FallingSnow opened this issue 9 years ago • 20 comments
trafficstars

This requires the user to have a self compiled ffmpeg with nvenc enabled.

FallingSnow avatar Oct 30 '16 18:10 FallingSnow

[https://ffmpeg.zeranoe.com/builds/](Zeranoe builds) for Windows are compiled with NVENC support.

aschereT avatar Nov 01 '16 04:11 aschereT

I got it working on Windows. Add the following line into processVideo: command.videoCodec('hevc_nvenc');. Incidentally, there's also hevc_qsv for Intel iGPUs. There doesn't seem to be any encoder for AMD though.

Performance went from 12fps to 344fps (i7-6700HQ, GTX 1060).

aschereT avatar Nov 01 '16 04:11 aschereT

What rate control method have you been using?

FallingSnow avatar Nov 01 '16 05:11 FallingSnow

I didn't really change any other settings than the encoder used. Sorry bout the late response, I forgot about it!

aschereT avatar Nov 13 '16 04:11 aschereT

Oh yeah, about the NVIDIA card detection... not all NVIDIA GPUs have HEVC encoder. Second generation Maxwells and Pascals.

Let me see, all GTX 10xx works. Desktop GT 9xx works. GTX 965M and above works, basically all the GM20x cards from here.

aschereT avatar Nov 13 '16 04:11 aschereT

For Intel iGPUs, Skylake models (6xxx) can encode 8-bit HEVC. If 10-bits, Kaby Lake (7xxx) is needed.

AMD GPUs do support HEVC encoding, but most ffmpeg builds don't have VCE support.

  • Tonga: Radeon R9 285, Radeon R9 380, Radeon R9 380X / Mobile Radeon R9 M390X / R9 M395 / R9 M395X / Radeon R9 M485X
  • Tonga XT: FirePro W7100 / S7100X / S7150 / S7150 X2
  • Fiji: Radeon R9 Fury / R9 Fury X / R9 Nano / Radeon Pro Duo / FirePro S9300 / W7170M
  • Polaris: RX 460 / 470 / 480

aschereT avatar Nov 13 '16 05:11 aschereT

I forgot too lol.

I will be leaving it up to the user to make sure their hardware and ffmpeg build supports nvenc_hevc or hevc_qsv. h265ize will simply detect the possibility of hardware encoding support.

I have never come across a ffmpeg build that supports AMD hardware encoding. Perhaps you can point me in the right direction on that.

FallingSnow avatar Nov 27 '16 21:11 FallingSnow

I see that AMD only started working with VCE recently, so no builds.

aschereT avatar Nov 28 '16 17:11 aschereT

I see, hopefully we will get VCE support for ffmpeg soon.

FallingSnow avatar Nov 28 '16 18:11 FallingSnow

Is there any way we could have nvenc_hevc support for Linux as well?

Daniel-Tyler-Farmer avatar Apr 02 '17 01:04 Daniel-Tyler-Farmer

No. Hardware acceleration still hasn't even been added for windows.

FallingSnow avatar Apr 02 '17 17:04 FallingSnow

+1 for nvenc_hevc support on Linux.

The current build of ffmpeg at the ffmpeg-3 ppa supports it out of the box: https://launchpad.net/~jonathonf/+archive/ubuntu/ffmpeg-3

jonathanhoskin avatar Aug 09 '17 01:08 jonathanhoskin

The dirty change suggested by aschereT work like a charmed on Windows with Zeranoe builds.

~340fps with my 1080GTX.

xiaodoudou avatar Aug 09 '17 05:08 xiaodoudou

For a quick reference for @FallingSnow: The command to get the GPU Informations:

// Mac OS:
system_profiler | grep GeForce

// Windows:
wmic path win32_VideoController get name

// Linux:
sudo lshw -C display

On windows the command will result like that:

$ wmic path win32_VideoController get name
Name
NVIDIA GeForce GTX 1080
Intel(R) HD Graphics 4000

xiaodoudou avatar Aug 09 '17 05:08 xiaodoudou

I wish I had found this earlier, I tinkered with the source code in order to support the nvenc codec, the speed is incredible !

I'm going to compare the quality between a file encoded with libx265 and nvenc and see if it is worth the speed gain.

azsde avatar Nov 19 '19 13:11 azsde

I wish I had found this earlier, I tinkered with the source code in order to support the nvenc codec, the speed is incredible !

I'm going to compare the quality between a file encoded with libx265 and nvenc and see if it is worth the speed gain.

Is this code uploaded somewhere, or could you share. I tried to figure it out, no luck, sadly.

I would love to use nvenc with h265ize

ncl2fth avatar Jan 04 '20 00:01 ncl2fth

+1

ghzgod avatar Aug 28 '21 09:08 ghzgod

Hi, This can be added in the latest bleeding edge version by editing lib/classes/video.js and replacing .videoCodec('libx265') with .videoCodec('hevc_nvenc'). Make sure you are on the bleeding edge version, the stable version bundles a ffmpeg binary that doesn't have support compiled in. Needs a working CUDA setup beforehand, on Ubuntu 20.04 with an NVIDIA quadro P400. Went from 36 fps to 365.

jmilette avatar Dec 02 '21 18:12 jmilette

Hi, This can be added in the latest bleeding edge version by editing lib/classes/video.js and replacing .videoCodec('libx265') with .videoCodec('hevc_nvenc'). Make sure you are on the bleeding edge version, the stable version bundles a ffmpeg binary that doesn't have support compiled in. Needs a working CUDA setup beforehand, on Ubuntu 20.04 with an NVIDIA quadro P400. Went from 36 fps to 365.

Tried this and still not seeing any GPU usage. Could you do a step by step?

tyriem avatar Dec 22 '21 13:12 tyriem

For AMD GPU in the latest bleeding edge version by edit lib/classes/video.js and replace .videoCodec('libx265') with .videoCodec('hevc_amf')

rutalreja-deloitte avatar Nov 06 '22 20:11 rutalreja-deloitte