View Full Version : 2-pass vs. Quality mode
dvd_maniac
28th December 2014, 07:31
I have been encoding my movie captures using 2-pass in Staxrip for a while now. I have to open the video, run compressibility check and then I set the size to 1280x720 and increase the filesize to hit 40% quality.
I would like to move to 1-pass CRF and create a profile that accurately sets the settings so that I can automate the encoding.
How do I set the quality in Quality Mode (which defaults to 21.0) to mimic 40% in 2-pass Mode?
LoRd_MuldeR
28th December 2014, 14:10
1. CRF is not actually a "quality" mode. Yes, the same CRF value gives roughly the same visual quality for different sources - as long as you don't change any of the other options. But that's pretty much it.
2. CRF and 2-Pass actually use the same rate-control algorithm, so the quality of a 2-Pass and a CRF encode of the same file size (same average bitrate) is the same too. Only with CRF you can't know the resulting file size (bitrate) beforehand.
3. What is that "40% magic" supposed to do? Either, you want to hit a specific file size (or a specific average bitrate), in which case you use 2-Pass mode and set the target bitrate accordingly. Otherwise you use CRF mode. End of story.
feisty2
28th December 2014, 14:25
what's 40% quality?
here's some of my personal experience
qp0 = 100% quality (mathematically lossless)
0< qp <= 8 is transparent (visually lossless, but actually lossy) to me
qp 16 is bluray like quality, some very delicate details like subpixel film grain start to fade away
qp > 18, DCT artifacts (ringing) becomes visible but not quiet obvious
qp > 21, more detail loss and compression artifacts becomes obvious (check frame by frame)
I never used qp>21 cuz that's crazy to quality freak like me
maybe 40% quality is around qp 22-24? I don't know
hope it helps
dvd_maniac
28th December 2014, 16:24
@ LoRd_MuldeR:
I know that you use 2-pass to get specific filesize but I always just set the 2-pass quality to 40% which is acceptable to me for most movies. It seems very inefficient to me that I use 2-pass when I'm just setting the quality to a specific target.
@feisty2:
I will use 23 and do a couple of quality and 2-pass tests.
I think I should get roughly the same filesize for both encodes once I get the equal 1-pass setting for 40%...
feisty2
28th December 2014, 16:43
Okay, how do you know the encoded video quality is 40%, there's no such quality parameter in x264
And how do you define 40% quality, psnr, ssim, or something else?
dvd_maniac
28th December 2014, 16:56
Ahhh. I see how I caused the confusion...
I guess that this should have went into the Staxrip forum...
When I use 2-pass encoding mode there is a setting called "Quality" which is % based.
It does not display a value until after the compressibility check is run. So I usually input a video, run the check and set the bitrate to whatever gives me 40%...
I will run a couple of tests where I use 1-pass and see what the resulting filesize is, then I will input the same video in 2-pass mode and run the compressibility check and set the filesize to the same as the 1-pass and see what the quality states.
I will probably have to do this several times until the 1-pass filesize matches the 40% quality in 2-pass mode.
I guess my only remaining question is if I do a 1-pass and 2-pass encode, with all other settings being equal and the resulting filesizes are the same... will the actual video quality be almost identical?
feisty2
28th December 2014, 17:08
If you don't have specific need for a fixed file size, crf should be possibly always better than 2 pass
2 pass or multi pass are modes to match the given file size while keep the rate factor constant as possible (mimic crf mode but the result can't be completely equal to crf due to the file size limit)
The ultimate goal of multi pass is to achieve crf with a known file size, but it could never be done
feisty2
28th December 2014, 17:30
Sure, if the file sizes of crf and 2 pass are exactly the same, the results of crf and 2 pass should be identical too, only 2 pass wastes a lot more time, but you can never know the file size before you crf encode something so it's kinda pointless
dvd_maniac
28th December 2014, 19:03
Did a couple of quick tests and Quality Mode 22.4 is giving me the same filesize as 2-pass 40%.
I was doing the 2-pass because I wanted to run the compressibility check to determine the 40% values and do not really care about the actual filesize... So I think I was just wasting a lot of time.
I will run a few more tests on different video sources to make sure that the Quality value of 22.4 gives me the same results...
Thanks for all your input. :)
LoRd_MuldeR
28th December 2014, 19:33
Did a couple of quick tests and Quality Mode 22.4 is giving me the same filesize as 2-pass 40%.
Be aware that this is totally source-dependent. Try the same CRF value with an pretty noisy source and you can easily get twice or thrice (or even more) the size, compared to a half-way "clean" source.
Again: If your goal is to hit a specific file size (or, equally, a specific average bitrate), just use 2-Pass mode, instead of doing "trial and error" with CRF mode.
And if you decide to use CRF mode, then pick a specific CRF value because it gives the desired level of quality. Not because - by chance - it hit a certain file size (bitrate) with one particular source.
hello_hello
28th December 2014, 20:17
Once you've used CRF encoding for a while you'll settle on a CRF value (or maybe different CRF values for different resolutions) that give you the file sizes you're after.... on average. They'll vary all over the place, but on average......
Okay, how do you know the encoded video quality is 40%, there's no such quality parameter in x264
And how do you define 40% quality, psnr, ssim, or something else?
If I remember correctly, StaxRiip lets you set a CRF value as 100% quality and the quality it reports as a percentage is relative to that. How the percentage is calculated, I have no idea. By default, I think CRF18 is 100% quality, but don't quote me on that.
dvd_maniac
28th December 2014, 22:31
By default, I think CRF18 is 100% quality, but don't quote me on that....
This is what I have to figure out.
I really do not care about final filesize, I just want what Staxrip deems to be 40% Quality while using 1-pass instead of 2.
It's just that I do not know how to get the 40% without using 2-pass and compressibility check.
I've been reading that there is virtually no difference between 1-pass and 2-pass quality if the filesize ends up the same and all other parameters are the same...
LoRd_MuldeR
28th December 2014, 22:57
By default, I think CRF18 is 100% quality, but don't quote me on that....
100% of what please? 100% of your personal definition of "transparent quality" or what? And, if so, how exactly would you define 50% then? :confused:
Also, as pointed out before: The same CRF value only gives (roughly) the same quality,as long as you don't change other options. E.g., the same CRF value can produce quite different results between "veryfast", "medium" and "veryslow" presets.
hello_hello
28th December 2014, 23:16
I seem to have remembered correctly. If you click on the x264 encoder configuration and look under the "StaxRip" tab, you'll see the CRF value considered to be 100% quality. I have StaxRip on a second PC here and in that case it's CRF18, but I can't remember if that's the default setting or if I changed it. I've never quite got my head around the "aimed quality" setting, but I rarely use StaxRip myself.
Any idea where StaxRip gets the "compressibility' value it displays? It changes if you change the target CRF value. For example I ran a compression check on a video with 100% quality set to CRF18 and the compressibility was 0.49. I changed the 100% quality setting to CRF21 and ran the compression test again and compressibility changed to 0.29. I think it's the output size relative to the source size, ie 29% and 49% in my case, but I'm not sure if it's that simple.
I've been reading that there is virtually no difference between 1-pass and 2-pass quality if the filesize ends up the same and all other parameters are the same...
I've run comparison encodes. First a CRF encode, then again using the resulting bitrate for a 2 pass encode. I ran each side by side while using a program to display the bitrates. If anything, 2 pass might be a little less consistent quality-wise than CRF as it appeares the encoder has to continually adjust the bitrate for 2 pass in order to hit the target bitrate. Mind you the difference is so tiny it's nothing you'd see, but I found (for example) the bitrate for the 2 pass encode would be very slightly higher than the CRF bitrate for a period, then it'd change and it'd be very slightly lower for a while, then a little higher again. Very small differences, but it was an interesting experiment. I did notice the bitrate for one 2 pass encode increased quite a bit near the end compared to the CRF encode. I guess the encoder had saved a little too much bitrate and was bust spending it near the end. I guess the credits should have looked pretty good. ;)
Those small differences aside, 2 pass and CRF are basically identical.
hello_hello
28th December 2014, 23:31
100% of what please? 100% of your personal definition of "transparent quality" or what? And, if so, how exactly would you define 50% then?
That just seems to be how it works. Set CRf18 (or whatever CRF value you choose) is 100% quality and I assume after running a compression test and adjusting the bitrate for 100% quality, you should effectively get a CRF18 encode..... give or take the inaccuracy of the compression test. StaxRip runs a compression test using whatever CRF value is set as 100% quality at the time.
I think the percentage calculation is as simple as "compressibility" was for Xvid. Run a compression test and maximum quality is 100%. 50% quality is exactly half the bitrate, and 75% quality is 75% of the bitrate etc (well I'm pretty sure that's how AutoGK did it). StaxRip appears to calculate the quality percentage the same way using your preferred CRF value as 100% quality. If you change encoder settings, I assume you'd need to run the compression test again.
It seems to make sense. Given maximum x264 quality is lossless it probably forces a choice of CRF value to represent 100% instead.
One thing I've never known..... AutoGK always ran it's compression test at a width of 640. Obviously working out "compressibility" wouldn't be hard if the resolution doesn't change, but I've never known how to work out the quality as AutoGK did while also factoring in any change in resolution. StaxRip also recalculates it when you change the resolution. There must be a formula.
LoRd_MuldeR
29th December 2014, 00:06
@hello_hello:
Okay, now I better understand what he was referring too. Anyway, I'm still not convinced of the usefulness of those so-called "compression tests". First of all, assuming that CRF=18 equals "100% quality" is dubious! That's because CRF=18 can have a quite different meaning, depending on all your other settings and depending on the nature of your source. Secondly, the assumption that perceived quality scales linearly with bitrate, i.e. half the bitrate results in half the perceived quaility (whatever "half the quality" is anyway), is dubious too! That's because I'm pretty sure that increasing/decreasing the bitrate by a certain amount can make a huge difference at the lower end of bitrates, while increasing/decreasing the bitrate by that very same amount makes a negligible difference at the upper end of bitrates. Finally, and most important, why do you need that anyway? If you need to hit a certain file size, then your target average bitrate is fixed. And then you want to get the best out of that fixed target average bitrate. And that's exactly what 2-Pass does. End of story. Otherwise, when you do not need to hit a certain file size, i.e. a somewhat bigger/smaller file doesn't matter, you just go with standard CRF. End of story.
dvd_maniac
29th December 2014, 00:25
All 3 of you guys (loRd, hello and feisty) seem to have a much better grasp of this than I do...
Is what I am suggesting not the best approach:?
Going from 2-pass to 1-pass and finding the 1-pass Quality Mode value that gives me the same filesize output as a 2-pass encode would? And that the 1-pass would give me roughly the same quality video output?
(All other settings would stay the same)
I'm not sure if my terminology caused some of the confusion or if my suggested approach is just illogical...
hello_hello
29th December 2014, 05:00
Finally, and most important, why do you need that anyway? If you need to hit a certain file size, then your target average bitrate is fixed. And then you want to get the best out of that fixed target average bitrate. And that's exactly what 2-Pass does. End of story. Otherwise, when you do not need to hit a certain file size, i.e. a somewhat bigger/smaller file doesn't matter, you just go with standard CRF. End of story.
To my way of thinking, one advantage a compression test might offer is to allow you to adjust the quality for a particular bitrate by adjusting the resolution if need be. Obviously it's not the same as adjusting the bitrate but if you need a fixed file size for some reason it's probably better to know you're going to end up with (for example) a nice 720p encode rather than a crappy 1080p one etc.
I really have no idea if the quality as a percentage scales directly with the bitrate. Probably not. I was just reporting how StaxRip works (I don't normally use it) and while playing around I noticed it's percentage calculations seemed to use the same method as the compressibility, or quality, whatever you want to call it, as was used for Xvid by programs such as AutoGK.
To be honest for Xvid it seemed reasonable, although maybe not "linear", but if 100% quality required "X" bitrate, 75% quality required 75% of "X" and usually looked pretty much the same, 50% quality was probably pushing it and anything lower tended to look not so good. At least it gave you an idea what to expect.
hello_hello
29th December 2014, 05:10
Is what I am suggesting not the best approach:?
Going from 2-pass to 1-pass and finding the 1-pass Quality Mode value that gives me the same filesize output as a 2-pass encode would? And that the 1-pass would give me roughly the same quality video output?
(All other settings would stay the same)
I thought you already had? CRF22 or something like that?
Yes it makes sense if you want to keep the quality pretty similar and yes, if the bitrate and encoder settings are the same each time, CRF and 2 pass will produce the same quality.
I'm pretty sure the default CRF value is 23. Me.... I use CRF18 for 720p or lower resolutions and CRF20 for 1080p to help keep the file size down (higher resolutions can get away with higher CRF values). It's all personal preference.
My suggestion would be to consider not letting past practice influence you too much. Run some test encodes, pick a CRF value that gives you the quality you prefer without the file sizes getting too out of control and run with it.
henryho_hk
6th January 2015, 05:42
If the time taken for (compressibility test + full compression) is not significantly shorter than (1st pass + 2nd pass), why bother?
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.