Log in

View Full Version : crf vs denoise for size boundaries


tormento
28th January 2010, 07:37
If I need to stay within a size bound, do you think it is better to use a higher crf or apply a slight denoise?

I can't understand where is the tradeoff between detail loss with higher compression or less details to encode.

My usual crf is 20 for BD rip and 22 for DVD rip.

The denoise filter I use more is fft3dGPU(video,mode=1,precision=2, sigma=1.25, bt=4, bw=32, bh=32, ow=16, oh=16).gradfun2db. Sometimes the sigma is up to 2 or 3 with very grainy films. Usually I apply two times a denoise with a lower impact than use one time with bigger numbers.

Ideas?

cogman
28th January 2010, 08:00
If I need to stay within a size bound, do you think it is better to use a higher crf or apply a slight denoise?

I can't understand where is the tradeoff between detail loss with higher compression or less details to encode.

My usual crf is 20 for BD rip and 22 for DVD rip.

The denoise filter I use more is fft3dGPU(video,mode=1,precision=2, sigma=1.25, bt=4, bw=32, bh=32, ow=16, oh=16).gradfun2db. Sometimes the sigma is up to 2 or 3 with very grainy films. Usually I apply two times a denoise with a lower impact than use one time with bigger numbers.

Ideas?
If you HAVE to stay within a size bound, then your best bet is to do a two-pass encode. There is no "do not pass this filesize but its ok to be a lot smaller" mode AFAIK.

Noise filtering can only do so much in compression efficiency (and it does do a fair amount). However, it shouldn't be considered a compression method itself. It is a filter, that is all.

tormento
28th January 2010, 09:21
If you HAVE to stay within a size bound, then your best bet is to do a two-pass encode. There is no "do not pass this filesize but its ok to be a lot smaller" mode AFAIK.

Noise filtering can only do so much in compression efficiency (and it does do a fair amount). However, it shouldn't be considered a compression method itself. It is a filter, that is all.

My size bound is less than a dual layer dvd but I am not looking for the exact size. My question: better use a noise filter or a higher crf to obtain a good result?

Blue_MiSfit
28th January 2010, 09:30
Well, you have a choice then. You can either:

A) Encode at a typical CRF and accept that if your file is "too big" you have to re-encode at a higher CRF, or just doing a proper 2 pass encode.
B) Encode using 2 pass always.

The rate control mode you're looking for is impossible to do using only one pass AFAIK.

tormento
28th January 2010, 09:58
Well, you have a choice then. You can either:

A) Encode at a typical CRF and accept that if your file is "too big" you have to re-encode at a higher CRF, or just doing a proper 2 pass encode.
B) Encode using 2 pass always.

The rate control mode you're looking for is impossible to do using only one pass AFAIK.

Perhaps my english is not so good. ;)

I care only that the encoded file fits on a DVD-DL, not a specific size!

My question is: if it doesn't fit is it better to use a higher CRF or a noise filter with same CRF?

J_Darnley
28th January 2010, 10:48
How often have you crossed the size limit? I doubt you ever have with a DVD rip as for the bluray encodes, maybe. What you could do is run the crf encode with --pass 1 --slow-firstpass. Then if that encode becomes too large then run a second pass at the appropriate bitrate to make it the right size. But this will be slow if many films become too large.

As for your denoising question, I would only denoise if the video were exceptionally noisy. I don't think I would use to solely enhance compression.

Another tip people seem to use is that they scale their bluray movies down to 720p. That will save you some bits and probably a better idea than denoising.

Poutnik
28th January 2010, 14:32
I think the OP question was intended rather what ( higher compression without filtering vs Lower compression with filtering ) and why, not how.

cogman
28th January 2010, 17:57
Noise filtering should be solely used to remove noise from a video. You should not over filter in an attempt to gain a lower bitrate. Filtering should be done to make the video look good.

If you have a video that goes over after filtering, I would suggest using two pass to get it to the hard bound. That doesn't mean that you should use two pass every time, just when the footage goes over.

tormento
29th January 2010, 02:07
Ok but film grain sometimes is really too much. Cheap film tape or low light conditions lead to this. Don't you think that "flatten" a bit the areas should improve not only compression but visual quality too?

Blue_MiSfit
29th January 2010, 02:37
If you have an extremely grainy source, and can't spend tons of bitrate to retain it accurately, the best solution is indeed to degrain it with a real degraining filter, like MDegrain/2/3.

This will keep most of the visual look, while reducing the encoding complexity by a huge amount - I've seen over a 50% improvement for extremely grainy sources!

~MiSfit

cogman
29th January 2010, 05:43
Ok but film grain sometimes is really too much. Cheap film tape or low light conditions lead to this. Don't you think that "flatten" a bit the areas should improve not only compression but visual quality too?

Don't get me wrong, Noise filters are great and do give good compression gains on fairly grainy sources. My point was, don't overdue it. Noise filters should be raised/lowered because of bitrate gains, they should be raised/lowered to make the film look better. Filtering is all about trying to get the video to its best quality, the side effect is that often you get better compression as a result.

Over filtering is bad, any way you slice it. It removes detail, decreases quality, and can produce some pretty poor results. If you need real blurring then you might consider doing it at the encoder level by playing with the deblock settings.

Personally, I tend to favor strong filters such as MCTemporalDenoise. You usually get some pretty astounding results from it. The price is, it is slow. (as are most temporal denoisers.)

tormento
29th January 2010, 08:18
degrain it with a real degraining filter, like MDegrain/2/3.
and:
Personally, I tend to favor strong filters such as MCTemporalDenoise.
Generally, I use

fft3dGPU(mode=1,precision=2, sigma=1.25, bt=4, bw=32, bh=32, ow=16, oh=16).gradfun2db

as read somewhere on this and other forum.

Do you think the filters you told should give better results for grain? Film grain is, as a matter of fact, noise. It is the same thing as digital noise on CMOS. Why do you think that the grain should be treated in a different way than noise? And should be grain treated as temporal/spatial/both noise? I read somewhere about "walking dots", don't know if it applies here.

julius666
29th January 2010, 15:53
Well, if size matters, and you want to do a low-bitrate encoding, then for not-so-grainy sources a light denoising can help a lot.

I use this script for that purpose (of course you need a decent GPU for these fft3dgpu settings):
fft3dgpu(sigma=0.8, bw=128, bh=128, bt=3, precision=3, plane=4, sharpen=0)
gradfun2db()
TTempsmooth(maxr=3, strength=1)

TTempsmooth is mainly for "calming down" the dither of gradfun2db().

This script is rather fast, but efficiently removes light noise.

However in the case of a high-bitrate encoding, I would go simply a lower crf.

Blue_MiSfit
29th January 2010, 21:38
At risk of turning this into a debate of the merits of film grain vs noise, I'll bite, but let's keep this short and civilized :)

While it's technically true that grain is the artifact of an imaging process, it's quite different from sensor noise. It adds a specific texture or feel to an image, and I strongly feel that in most cases it should be preserved as accurately as possible. Furthermore, removing the grain is always a lossy process and if not done carefully can produce unnatural looking results.

That being said, encoding a grainy film without enough bitrate to preserve it will also produce an ugly unnatural look. So, when it comes to filtering and compression, you're always playing the balancing game.

What works for me personally is to simply use a relatively low CRF number, which will almost guarantee the grain will be reasonably well preserved (along with VBV to keep peeks constrained to L4.1). If something comes out way too large, I either degrain, or encode at 720p, or do both. In fact, I frequently encode at 720p anyway, due to the lack of "real 1080p detail" in most BluRay discs.

At work, it's a different story since I do high volume transcoding. I usually use a fast and brutal filter like DeGrainMedian to give me a compressibility boost. Since I have to use CBR encoding to enable true streaming, this also limits the ability of the encoder to preserve grain accurately. Only very special sources get a whole hog degrain. Most of the time I just run through and hope for the best.

~MiSfit

henryho_hk
4th February 2010, 02:58
I wish there is some kind of standard compressibility test procedures/parameters for x264.

Blue_MiSfit
4th February 2010, 03:25
Indeed. Determining source complexity and expressing this as a useful metric is very difficult from what I understand :)

You can always do something akin to the old Gordian Knot compressibility check - aka use SelectEvery to select a range of frames, and encode that at a given CRF. I dunno... :)
~MiSfit

Poutnik
8th February 2010, 08:13
By using CRF it is more compression test than compresibility test, as far as CRF modifiies compression according to source.
But it follows consense accepted in times of XviD,
where compressibility was not function just source properties ( e.g. bits per pixel for given Q, matrix and settings),
but it was taylored to estimate future encoding.