[MPlayer-users] one-pass encoding results better than two-pass

Matyas Sustik mplayer.list at sustik.com
Wed Jan 7 21:13:49 CET 2009

Jason Garrett-Glaser wrote:
> x264 [info]: SSIM Mean Y:0.9805128
> x264 [info]: PSNR Mean Y:44.861 U:48.798 V:49.399 Avg:45.849 Global:45.537
> kb/s:3259.63
> The two pass encoding (same filter and x264enc options) produced a file with
> 9437678 bytes.
> x264 [info]: SSIM Mean Y:0.9803121
> x264 [info]: PSNR Mean Y:44.632 U:48.669 V:49.280 Avg:45.642 Global:45.489
> kb/s:3068.16
> I would call that roughly 190kbps higher bitrate.  At least that's
> what my calculator says, yours may disagree.

I did not care for those numbers printed by mencoder as I mentioned earlier.
   But you bring up an interesting question: what exactly does mencoder
report in the units kb/s?  How does that relate to the bitrate=3000 option I
was passing to the codec?

>> Single pass encoding:
>> File size: 21902932
>> x264 [info]: SSIM Mean Y:0.9822603
>> x264 [info]: PSNR Mean Y:44.466 U:47.888 V:49.304 Avg:45.431 Global:44.716
>> kb/s:2734.11
>> Two passes:
>> File size: 23831479
>> x264 [info]: SSIM Mean Y:0.9838375
>> x264 [info]: PSNR Mean Y:44.659 U:48.036 V:49.531 Avg:45.624 Global:45.243
>> kb/s:2990.10
>> 3 passes:
>> File size: 23903141
>> x264 [info]: SSIM Mean Y:0.9837665
>> x264 [info]: PSNR Mean Y:44.587 U:47.986 V:49.520 Avg:45.557 Global:45.237
>> kb/s:2999.61
>> The first two run results I can accept without much suspicion.  However the
>> benefit of the second pass is non-existent for me: the increase of less than
>> 0.002 SSIM costs almost 10% in file size. But the third seems again to be
>> suspicious featuring a larger file with lower SSIM.
> If you don't know how to read metrics, don't read them, or at least
> ask before you do.  SSIM is inverse logarithmic.

You may misspoke there, there is no logarithm in SSIM.  Maybe you thought of
PSNR.  I guess that you may wanted to point out that SSIM is not linear (but
that does not automatically mean it is logarithmic).  That point is well
taken; it was only my gut feeling at that point that the gain in SSIM/PSNR is
not justified by the file size increase.

I note that the above metrics are arithmetic/structural and not perception
based (as the definition goes).  Correlation with perception makes them
useful and I read that SSIM is the current favourite in that regard.  But
lossy video compression quality measurement will never be as objective as say
temperature measurement.

So to get a better answer to the question how the increased file size and
SSIM/PSNR relate, and whether two pass is useful or not, I attempted to find
the one pass encoding bitrate option that produces the same file size and
then the same SSIM.  (These are two separate problems.)  These runs take a
while on my machine so I have the following so far:

one pass encoding with bitrate=3275 produces:
File size: 23814217
x264 [info]: SSIM Mean Y:0.9833172
x264 [info]: PSNR Mean Y:44.766 U:48.092 V:49.478 Avg:45.713 Global:45.019

> If SSIM goes from
> 0.98 to 0.99, the quality of the encode *doubled*.

See my remark above regarding perception.  If by doubled one means that
1/(1-SSIM) is doubled, then yes, by definition...

Thanks for your attention.
Every hardware eventually breaks.  Every software eventually works.

More information about the MPlayer-users mailing list