[HELP/REQ] 2-pass QSV a

HandBrake for Windows support
Forum rules
An Activity Log is required for support requests. Please read How-to get an activity log? for details on how and why this should be provided.
Post Reply
forart.eu
Posts: 17
Joined: Tue Feb 27, 2007 4:05 pm

[HELP/REQ] 2-pass QSV a

Post by forart.eu »

According to the 1.5.0 changelog the issue #4026 (potential crash when encoding using Intel QSV in 2-pass mode) has been fixed.

The queston is: how to set 2-pass QSV inside GUI ?

Second: since hw encoding is known to produce not-so-good results, do you think is possible to perform an "hybrid-encoding" by hw-accelerate the 1st pass only ?
(question posted here too)

Thanks in advance.
User avatar
Ritsuka
HandBrake Team
Posts: 1390
Joined: Fri Jan 12, 2007 11:29 am

Re: [HELP/REQ] 2-pass QSV a

Post by Ritsuka »

The fix was related to the QSV decoder, not the encoder, there is no 2-pass in the encoder.
forart.eu
Posts: 17
Joined: Tue Feb 27, 2007 4:05 pm

Re: [HELP/REQ] 2-pass QSV a

Post by forart.eu »

Ritsuka wrote: Mon Jan 10, 2022 3:47 pmThe fix was related to the QSV decoder, not the encoder, there is no 2-pass in the encoder.
OK, now clearer.

What about "hybrid-encode" idea instead ? Do you think it's achievable ?
User avatar
s55
HandBrake Team
Posts: 10169
Joined: Sun Dec 24, 2006 1:05 pm

Re: [HELP/REQ] 2-pass QSV a

Post by s55 »

Nope, the hardware is not useful for that purpose.

If your using software encoding, Your better off using quality mode anyway and not having to worry about 2-pass.
forart.eu
Posts: 17
Joined: Tue Feb 27, 2007 4:05 pm

Re: [HELP/REQ] 2-pass QSV a

Post by forart.eu »

s55 wrote: Mon Jan 10, 2022 7:20 pmIf your using software encoding, Your better off using quality mode anyway and not having to worry about 2-pass.
You're right, but someone (like me) needs to trade quality and/for space.

For example I do need to encode sources at the best possible quality within 6000kbps for 4K and 2000kbps for 1080p.

And sometime specific sizes targeting could be needed too.
User avatar
Rodeo
HandBrake Team
Posts: 12943
Joined: Tue Mar 03, 2009 8:55 pm

Re: [HELP/REQ] 2-pass QSV a

Post by Rodeo »

2 Mbps for 1080p with a hardware-accelerated encoder? That's ambitious…
rollin_eng
Veteran User
Posts: 4351
Joined: Wed May 04, 2011 11:06 pm

Re: [HELP/REQ] 2-pass QSV a

Post by rollin_eng »

forart.eu wrote: Tue Jan 11, 2022 7:20 am
s55 wrote: Mon Jan 10, 2022 7:20 pmIf your using software encoding, Your better off using quality mode anyway and not having to worry about 2-pass.
You're right, but someone (like me) needs to trade quality and/for space.

For example I do need to encode sources at the best possible quality within 6000kbps for 4K and 2000kbps for 1080p.

And sometime specific sizes targeting could be needed too.
If you want the best quality and size then QSV is the wrong encoder to use.

QSV is best at speed. Try x264/5 for better quality/size encodes.
forart.eu
Posts: 17
Joined: Tue Feb 27, 2007 4:05 pm

Re: [HELP/REQ] 2-pass QSV a

Post by forart.eu »

Rodeo wrote: Tue Jan 11, 2022 3:38 pm2 Mbps for 1080p with a hardware-accelerated encoder? That's ambitious…
You're right, that's why I want understand if is possible to mixup the speed of the hw-encoder (for the 1st pass only) and the quality of the sw-encoder (for the 2nd).
forart.eu
Posts: 17
Joined: Tue Feb 27, 2007 4:05 pm

Re: [HELP/REQ] 2-pass QSV a

Post by forart.eu »

rollin_eng wrote: Tue Jan 11, 2022 3:45 pmQSV is best at speed. Try x264/5 for better quality/size encodes.
I know.
But the idea is to combine the hw-encoder speed and the sw-encoder quality, each used in different pass.

Another question: if bitrate is chosen, which QSV-encoding mode does Handbrake uses ?
QSVEnc wrote: Encode mode of QuickSyncVideo
  • CQP (Fixed Quantization)
  • CBR (Constant bitrate)
  • VBR (Variable bitrate)
  • AVBR (Adaptive Variable bitrate)
  • QVBR (Quality based Variable bitrate)
  • LA (Lookahead mode)
  • LA-HRD (HRD compatible Lookahead mode)
  • ICQ (Constant Quality)
  • LA-ICQ (Constant Quality with Lookahead)
  • VCM (Video Conference mode)
User avatar
Rodeo
HandBrake Team
Posts: 12943
Joined: Tue Mar 03, 2009 8:55 pm

Re: [HELP/REQ] 2-pass QSV a

Post by Rodeo »

Either VBR or AVBR, cannot remember off the top of my head.
rollin_eng
Veteran User
Posts: 4351
Joined: Wed May 04, 2011 11:06 pm

Re: [HELP/REQ] 2-pass QSV a

Post by rollin_eng »

Unfortunately there's no such thing as a free lunch.

Speed.Quality.Size.

Pick 2
forart.eu
Posts: 17
Joined: Tue Feb 27, 2007 4:05 pm

Re: [HELP/REQ] 2-pass QSV a

Post by forart.eu »

rollin_eng wrote: Wed Jan 12, 2022 2:39 pmUnfortunately there's no such thing as a free lunch.
I know, anyway I'm pretty happy for 4K @ 6Mbps 2-pass HEVC / 10bit encodings trough x265.

BUT my i7-7700 takes loooong to encode (~6fps per pass).

In QSV mode I got acceptable results - but obviously worst than x265 ones - in only 1-pass (~17fps)

The above idea was just to obtain "the best of both worlds" by speeding up as mutch as possible the 1st pass.

In other words, it could be an addiction/alternative to the option "turbo 1st pass".

Thanks anyway to all for your interest in my questions.

Last but not least: why HB won't allow x265 @ 10bits encodings ?
rollin_eng
Veteran User
Posts: 4351
Joined: Wed May 04, 2011 11:06 pm

Re: [HELP/REQ] 2-pass QSV a

Post by rollin_eng »

Again, Speed.Quality.Size.

You can really only have 2.

It does have 10 bit encoding.

https://handbrake.fr/docs/en/latest/tec ... depth.html
JustEncode
Posts: 14
Joined: Wed Aug 11, 2021 9:59 am

Re: [HELP/REQ] 2-pass QSV a

Post by JustEncode »

If you want quality + size + speed you can use QSV with custom settings BUT!!! that depends on your hardware.
What exactly does that mean?

In the past time I've been busy with QSV and searched all forums for information. Finally I arrived at my goal and encoded different samples with different hardware. I have tried every possibility with a UHD 630 in every respect and in the end you will not achieve good quality with this hardware without wasting an extremely large amount of bitrate.
The solution was the new Surface Pro 8 with a Gen 12 IGPU. The secret is to use Low Power Quicksync as it gives you extreme speeds. In order to generate quality based on this speed, you have to set tu=1 in the parameter, which is not even activated with "quality". Next you should leave ICQ and switch to CQP instead, which offers better results with the same bitrate. The next step is to use H265 10bit even if the source is only 8bit. The last important step to get details in dark areas is to deactivate b-pyramid. You can reach speeds between 180 - 240 fps with 1080p content. At 2160p content 70-90fps. It is important here that you activate the Quicksync decoder, otherwise you will lose a lot of fps.

With these options you can achieve a similar quality as with software Encode x265 10bit with the Medium settings.
If you want to improve the quality even further, you have to deactivate the low power mode, but your fps drop from 240 to around 40-42fps. This means that results can be achieved as with software x265 10bit between medium and slow.

But what you have to know is that QSV activates certain filters and features that cannot be deactivated with Handbrake. One of the filters is SAO. "SAO tends to lose sharpness on tiny details, but improves visual quality by preventing artifacts from forming by smoothening/blending".
These are some of the reasons why you can never achieve the sharpness that would be possible with pure software. But you are already heading in the right direction.

So if you want to get the best quality with QSV, you have to use the latest generation of Intel. Since I will soon be able to test the i9 12900k (UHD 770), which is newer than the XE Iris from the Surface pro 8, I can test whether there are further improvements between Gen 11 and Gen 12 in the next few months. I'm sure GPU Encode is the future as even with the latest Intel CPU or AMD CPU the performance doesn't get much better. With an overclocked AMD 5950x are possible with x265 medium approx. 62 fps. If you run two jobs at the same time maybe 80-82fps in total. I'm sure that in 4-5 years you won't be able to reach 200fps with pure software, because the clock rates will eventually reach their limits and using multiple CPUs/threads is not performant.
Maybe the quality isn't better with Gen 12 iGpu's than with Gen 11 iGpu's, but I'm sure we'll see improvements again with Gen 13 or 14. At the latest when AV1 Encode via QSV is possible, the CPU can dress warmly.

I'm sure no CPU will be able to convert AV1 at such high speeds that it's worth it for the private person.
At the latest when the first iGPU is able to encode AV1, the quality will be better than with software encode x265. It doesn't matter if AV1 QSV is worse than AV1 with the CPU, because at some point we reach a level where the visual difference to the source is no longer there and the file size is still significantly smaller.

Anyone who has managed to read the entire text will receive a cookie from me :)
rollin_eng
Veteran User
Posts: 4351
Joined: Wed May 04, 2011 11:06 pm

Re: [HELP/REQ] 2-pass QSV a

Post by rollin_eng »

Can you post your logs as it would be nice to see what the bitrates are when you compare x265 to QSV.
forart.eu
Posts: 17
Joined: Tue Feb 27, 2007 4:05 pm

Re: [HELP/REQ] 2-pass QSV a

Post by forart.eu »

JustEncode wrote: Mon Jan 17, 2022 5:43 pmIf you want quality + size + speed you can use QSV with custom settings
Can you share your custom settings, please ?

Anyway the idea behind this REQ is "just" to mixup QSV (1st pass) and x265 (2nd) to obtain best (possible) quality at fastest speed.
User avatar
Rodeo
HandBrake Team
Posts: 12943
Joined: Tue Mar 03, 2009 8:55 pm

Re: [HELP/REQ] 2-pass QSV a

Post by Rodeo »

It cannot be done. Be it QSV + x265 or any combination of two different video encoders, ever.
forart.eu
Posts: 17
Joined: Tue Feb 27, 2007 4:05 pm

Re: [HELP/REQ] 2-pass QSV a

Post by forart.eu »

Why not ?
Isn't the 1stpass a mere "estimation" of the content?
Or, in other words, isn't QSV able to produce a compatible "report" for x265 2nd pass ?

Anyway, if this is not technically possible, can QSV be configured for 2pass ?
(from what I've readed on the web no because QSV 2nd pass don't consider the 1st pass estimation)

In the end, if all these "approaches" were precluded, will HB let users to choose the QSV encode mode at least ?
User avatar
Rodeo
HandBrake Team
Posts: 12943
Joined: Tue Mar 03, 2009 8:55 pm

Re: [HELP/REQ] 2-pass QSV a

Post by Rodeo »

forart.eu wrote: Tue Jan 18, 2022 7:58 am Why not ?
Isn't the 1stpass a mere "estimation" of the content?
Or, in other words, isn't QSV able to produce a compatible "report" for x265 2nd pass ?
No, it cannot. Nor could it be modified to do so.
gmb
Bright Spark User
Posts: 350
Joined: Thu Mar 28, 2013 12:49 pm

Re: [HELP/REQ] 2-pass QSV a

Post by gmb »

JustEncode wrote: Mon Jan 17, 2022 5:43 pm In the past time I've been busy with QSV and searched all forums for information. Finally I arrived at my goal and encoded different samples with different hardware. I have tried every possibility with a UHD 630 in every respect and in the end you will not achieve good quality with this hardware without wasting an extremely large amount of bitrate.
The solution was the new Surface Pro 8 with a Gen 12 IGPU. The secret is to use Low Power Quicksync as it gives you extreme speeds. In order to generate quality based on this speed, you have to set tu=1 in the parameter, which is not even activated with "quality". Next you should leave ICQ and switch to CQP instead, which offers better results with the same bitrate. The next step is to use H265 10bit even if the source is only 8bit. The last important step to get details in dark areas is to deactivate b-pyramid. You can reach speeds between 180 - 240 fps with 1080p content. At 2160p content 70-90fps. It is important here that you activate the Quicksync decoder, otherwise you will lose a lot of fps.

In h265 CQP is by far the best bitrate mode on Iris Xe for sure. Bitrate efficiency is much worse when I disable bpyramid, I don't think this is good. bframes+bpyramid is very effective in CQP mode but you have to use 14-16 bframes. Handbrake default uses 4 bframes which is not so good. Also the 1s gop from Handbrake is subpar with the strict gop, I think fps*5 is a better tradeoff.
gmb
Bright Spark User
Posts: 350
Joined: Thu Mar 28, 2013 12:49 pm

Re: [HELP/REQ] 2-pass QSV a

Post by gmb »

rollin_eng wrote: Mon Jan 17, 2022 5:58 pm Can you post your logs as it would be nice to see what the bitrates are when you compare x265 to QSV.

I made several tests 1 year ago. Overall I would say CQP FF is a bit under x265 medium and CQP GPU a bit over x265 medium at the same bitrate, fully cranked up CQP of course and this is a rough estimate. CBR/VBR/ICQ on the other side have no chance against x265.

https://forum.doom9.org/showpost.php?p= ... tcount=450
https://forum.doom9.org/showpost.php?p= ... tcount=451

However I think there are cases where QSV might struggle more, noisy content for example maybe. And QSV image tends to be a bit softer compared to x265, although with the CQP P/B quantization parameter there is some room for tweaks towards a sharper output.
Post Reply