[MEncoder-users] How much filtering before low-bitrate H.264

Jorge Peixoto de Morais Neto please.no.spam.here at gmail.com
Mon Mar 17 06:23:36 CET 2008


Hi. I decided for H.264 for my low-bitrate anime compression.
I want the bitrate below 400 kbits/s. I want the image as
detailed,sharp,correct as possible. I want text to be readable.
To look aesthetically good is less important.

I decided for constant-quality encoding (maybe crf=32).
The video is 576x432 25 fps anime. It was compressed with Xvid
and has small but visible compression artifacts. Does this mean I should
filter the video before encoding? Which is true:

A) I should filter to reduce noise, to avoid wasting bits encoding
noise. Then mencoder can put the bits where they are really needed.

B) I should not filter, because I am encoding to a quite low bitrate
that will introduce serious compression artifacts anyway. In this
case, the noise will be the first thing discarded by the lossy
compression. It is pointless to artificially remove noise
beforehand. Filtering would destroy detail and achieve nothing.

If A is true, then should I use nr, hqdn3d, pp=ac or what?
Maybe both pp=ac and hqdn3d?

To decide, I have made some tests with the following method:
I encode the movie at two qualities next to the one I want (in this
case, crf=33 and crf=32). Then, assuming that the PSNR is a linear
function of log(bitrate) (1), I extrapolate to find the bitrate needed
for a given PSNR.

All tests had the common options
-ovc x264 -x264encopts
psnr:subq=5:8x8dct:frameref=2:bframes=3:b_pyramid:weight_b:keyint=512

Some of my results with a 48 second clip:

No filtering:
crf=32: bitrate 420.72 PSNR 35.909 in 61.3s
crf=33: bitrate 377.94 PSNR 35.301 in 60.312s
bitrate for 35.5 PSNR would be 391.44

-x264encopts nr=150
crf=32: bitrate 416.35 PSNR 35.866 in 62.225s
crf=33: bitrate 374.21 PSNR 35.262 in 61.585s
bitrate for 35.5 PSNR would be 390.28

-vf pp=ac
crf=32: bitrate 372.89 PSNR 35.826 in 61.586s
crf=33: bitrate 335.62 PSNR 35.186 in 60.221s
bitrate for 35.5 PSNR would be 353.42 

-vf hqdn3d
crf=32: bitrate 406.52 PSNR 36.049 in 69.064s
crf=33: bitrate 366.34 PSNR 35.425 in 68.185s
bitrate for 35.5 PSNR would be 370.95 

-vf pp=ac,hqdn3d
crf=32: bitrate 381.51 PSNR 36.157 in 70.946s
crf=33: bitrate 343.73 PSNR 35.52 in 69.888s
bitrate for 35.5 PSNR would be 342.61 

-vf hqdn3d,pp=ac
crf=32: bitrate 400.37 PSNR 36.121 in 71.455s
crf=33: bitrate 360.92 PSNR 35.488 in 70.5s
bitrate for 35.5 PSNR would be 361.63 

-vf pp=ac,hqdn3d=80:60:120
crf=32: bitrate 293.77 PSNR 39.463 in 72.171s
crf=33: bitrate 262.38 PSNR 38.805 in 70.786s
bitrate for 35.5 PSNR would be 148.74

So filtering helps encoding efficiency. But in the last
case (-vf pp=ac,hqdn3d=80:60:120), the image is obviously very blurry,
so the PSNR is really small. It certainly is not the 38.805 reported.
This suggests that the reported PSNR is from comparing the *already
filtered picture* with the *filtered, compressed picture*. For me it
would be far more useful to compare the *original picture* with the
*filtered, compressed picture*.

So I cannot decide know how much (if any) filtering I should apply.
What do you think? A or B?

Also, I suggest the mencoder documentation to explicitly say, for the
psnr option, what is compared with what.

(1) The site http://www.normalesup.org/~george/comp/video_quality/
seems to confirm that, for a certain range of bitrates, the PSNR is
indeed a linear function of log(bitrate). See the "x264---native" line



More information about the MEncoder-users mailing list