Question / Help NVENC in 0.14.1

Boildown

Active Member
2-Pass Encoding in general is for doing VOD transcoding, not Live encoding. Assuming NVEnc 2-Pass does what the name implies it does, at best it will do the first pass only. There's no time to do a second pass because this is live video, not a pre-recorded file. Obviously 2-pass is not intended for live encodes... and it probably shouldn't be pickable in OBS unless OBS becomes a transcoder like Handbrake, or something.
 

Boildown

Active Member
Why wouldn't it have time to do so in 2-pass?

Maxwell Gen 2 cards can do 900fps in 2-pass encoding at 720p.

Because its live? Two-pass encoding means going through the entire recording once, recording some encoding data, then going through the entire recording again and using that data from pass one to encode the second time more efficiently. That can't be done in a live environment, obviously.

https://en.wikipedia.org/wiki/Variable_bitrate#Multi-pass_encoding_and_single-pass_encoding
 
Because its live? Two-pass encoding means going through the entire recording once, recording some encoding data, then going through the entire recording again and using that data from pass one to encode the second time more efficiently. That can't be done in a live environment, obviously.

https://en.wikipedia.org/wiki/Variable_bitrate#Multi-pass_encoding_and_single-pass_encoding

just tested gtx960 720p30 nvenc hq 2 pass on twitch and it worked well, no problems when comparing to nvenc 1 pass and x264, so if its really 2pass its fast enough and doesnt give any troubles imho
 

moriz1

Member
just tested gtx960 720p30 nvenc hq 2 pass on twitch and it worked well, no difference when comparing to nvenc 1 pass and x264, so if its really 2pass it doesnt give any troubles imho

i won't be surprised if the NVENC encoder simply ignores the 2-pass setting if it detects that it is recording live. like Boildown said, 2-pass encoding makes no sense for a live source, and is only used for re-encoding video files.

in fact, the 1st pass of a 2-pass encoding process records no video. instead, it generates a tiny file that only serves to tell the encoder when and where to use additional bitrate to properly encode busy scenes, a roadmap if you will. this allows for more efficient encoding on the second pass, resulting in higher quality and/or lower file size. this obviously won't work for live sources.
 
Unfortunately, NVENC is as much of a black box to developers as it is to end users. There's no documentation about two-pass encoding; it's just a bunch of rate control modes labeled '2_PASS'.

It's not the same as x264's 2-pass encoding. Conceptually, it encodes twice to get closer to the target bitrate, but it works on a per-frame basis and is meant for low-latency applications. By low-latency, I mean things like playing PC games on an NVIDIA SHIELD, where there's virtually no buffering and pictures are displayed as soon as they're received.

Normally, a rate control algorithm doesn't know how big a coded picture will be before it's made, so it makes a guess based on prior frames. For example, if the last frame ended up too large, it lowers the quality. This works fine for most purposes, but with low-latency streaming, it's important that each coded picture doesn't go over a certain size. With 2-pass, the encoder does a mock coding to get an idea of how much the frame costs and then performs the final encode with that information. If a sudden movement in the scene causes the size to increase, rate control must reduce the quality so that it doesn't go over the limit and take too long to transmit.

The 2-pass algorithm also has the ability to detect scene cuts and double the amount of bits for them. The idea is that it's better to delay a scene change by one refresh rather than display it instantly with poor quality.

These features aren't very useful for regular live broadcasting, but there are other differences in this algorithm that are not yet known. Maxwell GPUs are fast enough to do 2-pass encoding at 1080p60, so you should try it out and see if it looks better.

For local recording, you will likely not see any benefit at all.
 

vorob

Member
So, two years passed, any info on two pass encoding? I'm also surprised to see this option in live streaming setting.
 

Boildown

Active Member
So, two years passed, any info on two pass encoding? I'm also surprised to see this option in live streaming setting.
I think Timothy003's response is still the last word on what it does. Someone did some quality tests and I believe it either had no effect or was overall detrimental to quality per bitrate. It would be difficult for me to dig up that post though, I don't remember what to search for. If people have problems, I normally recommend they turn it off.
 
Top