CESNET / UltraGrid

UltraGrid low-latency audio and video network transmission system
http://www.ultragrid.cz
Other
489 stars 55 forks source link

Nvenc troubles #330

Open TheSashmo opened 1 year ago

TheSashmo commented 1 year ago

Trying to figure out Nvenc encode and decode:

Encode: ./UltraGrid-1.8.3-x86_64.AppImage -t decklink:4:4k29:UYVY -s embedded -c libavcodec:encoder=hevc_nvenc:bitrate=15000k:subsampling=420:disable_intra_refresh:delay=2 --audio-codec=opus:sample_rate=48000:bitrate=256k --audio-capture-format channels=16 -m 1316 -P 10000 192.168.99.241 --control-port 1234 or ./UltraGrid-1.8.3-x86_64.AppImage -t decklink:4 -s embedded -c libavcodec:encoder=hevc_nvenc:bitrate=15000k:disable_intra_refresh:delay=2 --audio-codec=opus:sample_rate=48000:bitrate=256k --audio-capture-format channels=16 -m 1316 -P 10000 192.168.99.241 --control-port 1234

Decode ./UltraGrid-continuous-x86_64.AppImage -d decklink:5 -r embedded --param force-lavd-decoder=hevc_cuvid 192.168.99.241 -P 10000 --control-port 12345 or ./UltraGrid-continuous-x86_64.AppImage -d decklink:5 -r embedded --param use-hw-accel,force-lavd-decoder=hevc_cuvid 192.168.99.241 -P 10000 --control-port 12345

Just gives me black screen. Either 420 or v210 its all the same. The only way I can get anything on the screen is by removing the force decoder param.

I can see with nvidia-smi that decode is using 10% but still nothing on the output, and yes my display supports the resolution. Using Quadro RTX 4000

alatteri commented 1 year ago

What is the decoding GPU?

TheSashmo commented 1 year ago

Its same, its all on the same box, testing encode/decode on the same box.

alatteri commented 1 year ago

What model?

TheSashmo commented 1 year ago

Quadro RTX 4000

alatteri commented 1 year ago

That should support HEVC. Try only --param use-hw-accel, I think they added native CUVID into UG app image.

TheSashmo commented 1 year ago

Tried that one too, still nothing. Too many combinations ends up locking up the output, and I need to reboot.

MartinPulec commented 1 year ago

Hi, what is the minimal broken example?

UltraGrid-continuous-x86_64.AppImage -t testcard -c libavcodec:encoder=libx265:subsampling=420 --param force-lavd-decoder=hevc_cuvid -d gl

works? If so, does it with -c libavcodec:encoder=hevc_nvenc:subsampling=420 as well? If both do, which parameters breaks the operability? Would it also be possible to provide the console output of the problematic run? (Using -V parameter when generating the log would be great.)

MartinPulec commented 1 year ago

or as Alan proposed, use just --param use-hw-accel without enforcing the decoder

TheSashmo commented 1 year ago

So just to update this, I've been testing and was able to get things working right using the continuous build.

However, I can see macro blocking, but the logs output is clean and the same signal being pushed to another machine (mac) and doing hardware decoding without any problem, only on the local host. For fun I checked the relase version and it does not have the same issue running the same comands:

./UltraGrid-continuous-x86_64.AppImage -t decklink:4 -s embedded -c libavcodec:encoder=hevc_nvenc:bitrate=20000k:subsampling=420 --audio-codec=opus:sample_rate=48000:bitrate=256k --audio-capture-format channels=16 -m 1316 239.1.2.58 -T 64 --control-port 1234 -f a:rs:150:200 -f v:rs:150:200

./UltraGrid-1.8.3-x86_64.AppImage -d decklink:6 --param force-lavd-decoder=hevc_cuvid -r embedded 239.1.2.58

alatteri commented 1 year ago

Continuous is using the latest FFmpeg, which added some NVENC patches, could be that.

e457ab87f74b9f1cd784b289300c34f59d5591eb

MartinPulec commented 1 year ago

I can see macro blocking

can you produce some working example demonstrating the problem? I've tried (with last week's last version):

UltraGrid-continuous-x86_64.AppImage -t testcard:pattern=uv_plane:mode=cif \
 -c  libavcodec:encoder=hevc_nvenc:subsampling=420 -d gl

And it looked OK. Of course it is just a simple example. If it needs more complex source, what about (-t file:) Sintel or Elephants Dream?

Continuous is using the latest FFmpeg, which added some NVENC patches, could be that. e457ab87

Well, yes and no. The relevant FFmpeg commit actually does nothing, I've misinterpreted the commit message so that it doesn't set NVENC_INFINITE_GOPLENGTH so that I've removed UG FFmpeg patch but it isn't true. As the result, intra refresh was disabled... which may be the problem for @TheSashmo if it induces network loss. Anyways, I've updated your patch to match FFmpeg changed code in 10c28095 so that NVENC produces Intra Refresh).

UPDATE: This or another sample from fiesamples.com can also work as a reference (and those are significantly shorter than the movies).