Log in

View Full Version : x264 encoding constant quality and black borders


scott1256ca
27th March 2012, 17:17
I want to know how leaving black borders at the top and bottom of a video affects quality when you are encoding using constant quality?

I assume crf uses some metric to measure quality for each frame and that metric will include the black bars at the top and bottom of each frame. Further, those black bars are likely to match between the source and encode with very high accuracy. So how much does that skew the metric?

Do you need to encode with a lower crf value to compensate?
Is there a way to tell x264 to ignore the black borders when calculating its quality metric?

While I know I could do some test encodes to find out, I'm wondering if anyone has already done this and knows the answer. Can I test by turning off psy and comparing ssim or psnr. I know eyes are better, but they take longer to do the comparisons. And I'd be encoding the same clips using the same settings.

I expect psnr and ssim would suffer from the same problem, namely that they would be skewed by calculating the "noise" in the black borders which again would be very low noise, so may artificially raise the overall estimated quality reported ssim or psnr.

In case it affects your answer, I am personally just interested in high quality encodes from, well, fairly high quality sources. For example, I really don't care about the quality of highly compressed online videos.

Thanks

nm
27th March 2012, 18:27
I want to know how leaving black borders at the top and bottom of a video affects quality when you are encoding using constant quality?

I assume crf uses some metric to measure quality for each frame and that metric will include the black bars at the top and bottom of each frame. Further, those black bars are likely to match between the source and encode with very high accuracy. So how much does that skew the metric?

Do you need to encode with a lower crf value to compensate?

I don't think there's need to compensate.

Can I test by turning off psy and comparing ssim or psnr.

Yep. Use --tune ssim and --tune psnr.

You could compare only the image parts with AviSynth SSIM plugin, if you feel like it.

I expect psnr and ssim would suffer from the same problem, namely that they would be skewed by calculating the "noise" in the black borders which again would be very low noise

To avoid wasting any unnecessary bits on the borders, they should be painted over with black (Y=16) in AviSynth. Borders should be at mod 16 positions with razor-sharp edges (no smoothing).

Of course, this is more work than cropping the borders out, but it's the best option if you need those borders for spec compliant Blu-ray output or something similar.

sneaker_ger
27th March 2012, 20:13
I don't think there's need to compensate.

http://forum.doom9.org/showthread.php?t=149403

I don't know if this applies to mbtree, though. (The thread dates one month after mbtree introduction.)

nm
27th March 2012, 21:03
http://forum.doom9.org/showthread.php?t=149403

Yep, I remembered that discussion but was too lazy to dig it up. :)

I don't know if this applies to mbtree, though. (The thread dates one month after mbtree introduction.)

With mbtree there shouldn't be need to compensate CRF. I just made a quick test where a letterboxed encode and a cropped version came out with almost identical bitrates.

Without mbtree the letterboxed encode was 7 % larger (and therefore had higher quality).

scott1256ca
28th March 2012, 06:32
Thanks for your responses. I'll do a couple of tests of my own when I get a chance.