Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nvenc troubles #330

Open
TheSashmo opened this issue Jul 12, 2023 · 11 comments
Open

Nvenc troubles #330

TheSashmo opened this issue Jul 12, 2023 · 11 comments
Assignees

Comments

@TheSashmo
Copy link

TheSashmo commented Jul 12, 2023

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
Copy link

What is the decoding GPU?

@TheSashmo
Copy link
Author

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

@alatteri
Copy link

What model?

@TheSashmo
Copy link
Author

Quadro RTX 4000

@alatteri
Copy link

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

@TheSashmo
Copy link
Author

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

@MartinPulec
Copy link
Collaborator

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
Copy link
Collaborator

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

@TheSashmo
Copy link
Author

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
Copy link

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

e457ab8

MartinPulec added a commit that referenced this issue Jul 24, 2023
Current libavcodec version is still 60.22.100 so intra-refresh has been
disabled since e457ab8 because the version is still not strictly greater
(is equal). Using non-strict equality breaks the compilation with version
60.22.100 prior to FFmpeg commit e457ab8 (perhaps not a big deal).

refer to GH-330
MartinPulec added a commit that referenced this issue Jul 25, 2023
This reverts commit e457ab8 but the
patch is updated to match current FFmpeg.

The FFmpeg commit that seemed to do the same (7eeef72c6) is not working
correctly because it assigns idrPeriod cc->gopLength, which was set to
NVENC_INFINITE_GOPLENGTH above in case of intra-refresh.

refer to GH-330
@MartinPulec
Copy link
Collaborator

MartinPulec commented Jul 25, 2023

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. e457ab8

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 10c2809 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).

MartinPulec added a commit that referenced this issue Aug 21, 2023
This reverts commit e457ab8 but the
patch is updated to match current FFmpeg.

The FFmpeg commit that seemed to do the same (7eeef72c6) is not working
correctly because it assigns idrPeriod cc->gopLength, which was set to
NVENC_INFINITE_GOPLENGTH above in case of intra-refresh.

refer to GH-330
@MartinPulec MartinPulec self-assigned this Sep 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants