ffmpeg icon indicating copy to clipboard operation
ffmpeg copied to clipboard

{Request} Include nvenc/nvdec support

Open BobOkisama opened this issue 6 years ago • 11 comments

Can you also bake in nvenc and nvdec support into this? I have been searching all over trying to find a 4.x with those baked in, and have even tried multiple times to compile my own with nothing but failure all round.

BobOkisama avatar Jan 22 '19 13:01 BobOkisama

Hook us poor fools up jrottenberg! You're my only hope.

BobOkisama avatar Jan 29 '19 21:01 BobOkisama

;-p

Might have to run another variant, it doesn't seem straightforward : https://trac.ffmpeg.org/wiki/HWAccelIntro#NVENC

Is it that critical, comparing to vaapi ?

jrottenberg avatar Feb 01 '19 23:02 jrottenberg

So vaapi is just cpu.. it is spotty AT BEST in it's transcoding (IMO) and introduces artifacts. Now, on the other hand, you can buy an official Quadro P2000 for $300 and it will handle a ridiculous amount of transcodes at once with zero artifacts. There is a github project out there to allow you to use GTX variants as quadro and the driver they are releasing allows you to remove the transcode restriction on them. You can buy a 1050 gtx for next to nothing and it is as good as a P2000 or better.

Currently in Plex I can easily support 5+ 4k transcodes on my P2000 and it is not even using but like 50% of the gpu (it has caching and all so yeah) you put something like a 1080 ti and that is like a P6000 which costs 6000+. Right now, with the QUALITY it produces, I think GPU with nvidia xcodes are going to the "the thing" here soon, and if you can capitalize on that now I think your build might be the one that gets used by many projects (like Jellyfin).

BobOkisama avatar Feb 01 '19 23:02 BobOkisama

Would be useful for the jellyfin project https://github.com/jellyfin/jellyfin/issues/482

andrewrabert avatar Feb 09 '19 22:02 andrewrabert

Could someone with a nvidia GPU please test my fork: https://github.com/WeekendWarrior1/ffmpeg

You'll need to cd into the repo and then run

docker image build -t ffmpegnvenc docker-images/4.1/nvenc/

Some things to note: I haven't included cuda because apparently it isn't required for transcoding unless you're using specific filters, see here: https://gist.github.com/Brainiarc7/988473b79fd5c8f0db54b92ebb47387a

@jrottenberg I think it makes sense to have this set up as another variant, although does that add challenges for projects like jellyfin? Seems like they would want a build that offered both vaapi and nvenc.

PS. I'd like to try this with nvidia-headless-*** instead of nvidia-driver-*** but I'll wait for confirmation that my fork works first.

WeekendWarrior1 avatar Feb 17 '19 00:02 WeekendWarrior1

paging @GnaphronG I believe he has a build with nvidia libs

jrottenberg avatar Feb 17 '19 00:02 jrottenberg

So to assist anyone who could possibly test the nvenc fork ( @BobOkisama ?) After running and successfully building the docker image using this line:

docker image build -t ffmpegnvenc docker-images/4.1/nvenc/

You should be able to test nvenc inside the container using this:

docker run --device /dev/dri:/dev/dri -v $PWD:/tmp ffmpegnvenc \
        -stats -loglevel debug -hwaccel cuvid\
        -i http://www.jell.yfish.us/media/jellyfish-3-mbps-hd-h264.mkv \
        -c:v h264_nvenc \
        -t 5 -f mp4 /tmp/test.mp4

I'm only going by what I know about vaapi, which includes needing to mount the GPU hardware into the container. In the past I've also needed to add my docker user to the video group.

Please let me know if you need anymore assistance

WeekendWarrior1 avatar Feb 18 '19 12:02 WeekendWarrior1

Sure boss, be happy to do so. docker image build -t ffmpegnvenc docker-images/4.1/nvenc/

produces the error: "unable to prepare context: path "docker-images/4.1/nvenc/" not found "

BobOkisama avatar Feb 18 '19 12:02 BobOkisama

thanks @BobOkisama Can you confirm that you've pulled the repository using:

git clone https://github.com/WeekendWarrior1/ffmpeg.git

And the entered the directory,

cd ffmpeg

You should now be able to build the image using the command above (and sorry, totally forgot to mention these steps)

WeekendWarrior1 avatar Feb 18 '19 12:02 WeekendWarrior1

Looks like it compiled.... but when I run it I get error: [h264 @ 0x5650d6afe680] Initializing cuvid hwaccel [AVHWDeviceContext @ 0x7fead804f280] Cannot load libcuda.so.1 [AVHWDeviceContext @ 0x7fead804f280] Could not dynamically load CUDA [h264 @ 0x5650d6afe680] Error creating a CUDA device cuvid hwaccel requested for input stream #0:0, but cannot be initialized. [h264 @ 0x5650d6afe680] decode_slice_header error [h264 @ 0x5650d6afe680] no frame! Error while decoding stream #0:0: Invalid data found when processing input cur_dts is invalid (this is harmless if it occurs once at the start per stream) [h264 @ 0x5650d6b1ae00] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 0

BobOkisama avatar Feb 18 '19 13:02 BobOkisama

It's generally recommended to use nvidia-docker, https://devblogs.nvidia.com/nvidia-docker-gpu-server-application-deployment-made-easy/

cvium avatar Feb 19 '19 11:02 cvium