lisamelton/other_video_transcoding

Low bitrates, nvidia driver version culprit

vasuvasu opened this issue · 11 comments

tl;dr there's something up with the latest nvidia drivers that causes low bitrates regardless of a specified bitrate.

I recently updated ffmpeg to the latest release build (7.0.1) and nvidia drivers to the latest version (555.99 from June 2024) and noticed my hevc_nvenc encodes have much lower bitrates than specified now.

It doesn't matter if I specify a 1080p target bitrate of 3000k or 6000k or 12000k, the encodes average out to 2000-3000k, sometimes even a bit lower.

I tried downgrading ffmpeg back down to what I had before, v5.1.2 and that didn't do it.

I rolled back to nvidia drivers from December 2023, v546.33 and that restored the bitrate behavior!

Then I tried re-installing ffmpeg 7.0.1 but got a ffmpeg or nvenc warning that the driver was too old, so then I tried the last version of ffmpeg 6.x (6.1.1) and that error went away and I'm getting the target bitrate behavior I expect.

So then for fun I started installing newer and newer drivers between December 2023 and June 2024 until I found the offending version, v555.85, just 1 minor version back from the v555.99 version I updated to last week. So something in the v555.x branch is changing the bitrate behavior of nvenc. Not sure if this is a bug or new expected behavior.

The last version with expected behavior is the v552.22 (Studio) or v552.44 (Game Ready). Luckily v552.x works with with ffmpeg 7.0.1.

So if anyone else decides to do some spring cleaning software updates, avoid the latest nvidia drivers and stick to 552.x from April 2024.

So does anyone know what changed or have you run into this? I looked at the Release Notes for v555.85 and don't see anything interesting in there.

@vasuvasu Thanks for the heads up and sorry I'm taking so long to get back to you on it. I'll investigate later today and also ask my crew to take a look.

seeing this as well - it seems to encode 4k at 8000 but 1080ps are variably lower

googling this, it seems to be mentioned in an open issue in the (buried) release notes for 556.12

[NVENC] Quality and bitrate settings are ignored at 10-bit encoding [4697900]

@vasuvasu OK, I can reproduce the lowered bitrate behavior with Nvidia driver version 556.12 which was released at the end of June. This is the latest version, as near as I can tell.

I will continue to investigate. Stay tuned...

@vasuvasu Update: Using the --nvenc-cq option, I am able to adjust the bitrate of HEVC output. But I cannot seem to affect the bitrate in ABR mode.

I'll take a look at the source code to the FFmpeg codec and see what I can figure out. This could take awhile, but stay tuned...

@vasuvasu Ugh. It appears that the FFmpeg NVENC codec has been substantially re-written since the last time I looked at it. Which was a loooong time ago.

What's weird is that H.264 encoding works just fine with a target average bitrate. Just not HEVC.

@vasuvasu As near as I can tell by looking at the source, the FFmpeg NVENC codec is passing the correct average bitrate target to the Nvidia driver. So, it's likely that your suspicion is correct and the problem is with the driver. Which means, at this point, I'm not sure what to do about it except explicitly force constant quality mode when using NVENC for HEVC output since that's what you're getting anyway. Or we could wait and see if Nvidia fixes this. I just don't know how long that could take.

@vasuvasu I don't know why this didn't occur to me to try last night, but the same happens with HandBrake. IOW, this is definitely not a problem with FFmpeg. Something is broken in the newer Nvidia drivers. Or, who knows, maybe Nvidia thinks this is a feature?

@vasuvasu BTW, I added a warning in the "README.md" document about the Nvidia driver issue. That's really about all I can do at this point. Do you want to close this bug or shall I?

@lisamelton you can close it! I was just posting this as an FYI/warning to anyone else that runs into the issue. This is all on nvidia, so 🤷🏾🤷🏾🤷🏾

@vasuvasu Thanks and yet!