Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 5th December 2007, 04:07   #21  |  Link
Dark Shikari
x264 developer
 
Dark Shikari's Avatar
 
Join Date: Sep 2005
Posts: 8,688
Quote:
Originally Posted by Zep View Post
there is is NO WAY in hell you can get 300 to 700 megs at 1280 x 720p even with max settings in x264. Even at 4.4 gigs I tell the difference in quality VS direct from the bluray.
Obviously you can tell the difference; you can't get visually lossless at any smaller than the original in most cases anyways.

The quality is quite good overall though if you're not a quality snob. You'd be quite surprised how good x264 is at low bitrates, especially when you've denoised it heavily (thus also reducing the bit cost for highest detail areas).
Dark Shikari is offline   Reply With Quote
Old 5th December 2007, 04:08   #22  |  Link
Zep
Registered User
 
Join Date: Jul 2002
Posts: 587
Quote:
Originally Posted by Dark Shikari View Post
I think I used (I no longer have the script):

src=last
removegrain(19)
removegrain(19)
DeGrainMedian(mode=0)
fft3dgpu(precision=2)
hqdn3d(0,0,3,6)
fft3dfilter(sigma=0,sharpen=1)
last.mergechroma(src)
Lanczos4Resize(1280,720)
the fact you had to Lanczos4Resize(1280,720) means you smoothed out the encode IMHO too much and lost detail else no need for that filter call. Which is why I decided not to go that route.

I would love to see a clip of that of the same scenes in my clips. :P
Zep is offline   Reply With Quote
Old 5th December 2007, 04:12   #23  |  Link
Zep
Registered User
 
Join Date: Jul 2002
Posts: 587
Quote:
Originally Posted by Dark Shikari View Post
Obviously you can tell the difference; you can't get visually lossless at any smaller than the original in most cases anyways.

The quality is quite good overall though if you're not a quality snob. You'd be quite surprised how good x264 is at low bitrates, especially when you've denoised it heavily (thus also reducing the bit cost for highest detail areas).
yeah but I want it really good. what is the point of spending all this time tweaking the grain removal only to have lower quality elsewhere?

My goal was to get rid of a good amount of grain and keep it looking as good as the bluray as much as possible on 1 DVD-R.
Zep is offline   Reply With Quote
Old 5th December 2007, 04:23   #24  |  Link
Dark Shikari
x264 developer
 
Dark Shikari's Avatar
 
Join Date: Sep 2005
Posts: 8,688
Quote:
Originally Posted by Zep View Post
yeah but I want it really good. what is the point of spending all this time tweaking the grain removal only to have lower quality elsewhere?

My goal was to get rid of a good amount of grain and keep it looking as good as the bluray as much as possible on 1 DVD-R.
300 has enough grain that if you remove the grain, you will lose loads and loads of detail. Its pretty much unavoidable.
Dark Shikari is offline   Reply With Quote
Old 5th December 2007, 04:56   #25  |  Link
Sagekilla
x264aholic
 
Join Date: Jul 2007
Location: New York
Posts: 1,752
Quote:
Originally Posted by Dark Shikari View Post
300 has enough grain that if you remove the grain, you will lose loads and loads of detail. Its pretty much unavoidable.
Yeah, RemoveGrain(19) alone gave the grain a jittery look so I had to keep the HQdn3D before that so it wouldn't have a flicker. A simple LimitedSharpenFaster added on helped retain some "detail" so it didn't look horrendous though.


Wish I had a blu-ray source so I could encode to 720p though.
Sagekilla is offline   Reply With Quote
Old 5th December 2007, 22:47   #26  |  Link
Zep
Registered User
 
Join Date: Jul 2002
Posts: 587
Quote:
Originally Posted by Dark Shikari View Post
300 has enough grain that if you remove the grain, you will lose loads and loads of detail. Its pretty much unavoidable.
which is why if you look at my clips you will see I did not remove all the grain.

Comparing to the Bluray 95% of detail is still there after my grain removal and is the best
balance I could get. i.e. get rid of just enough grain and grain dancing to not annoy me
while watching and thus keep most of detail intact to not annoy me on that front as well

Last edited by Zep; 5th December 2007 at 22:53.
Zep is offline   Reply With Quote
Old 5th December 2007, 23:01   #27  |  Link
Zep
Registered User
 
Join Date: Jul 2002
Posts: 587
Quote:
Originally Posted by Dark Shikari View Post
300 has enough grain that if you remove the grain, you will lose loads and loads of detail. Its pretty much unavoidable.
BTW

interestingly enough it is not the grain that annoys me. It
is the DANCING grain. So I feel you can get rid of a lot of
dancing grain and keep detail if you use filters that look for
grain dance and only Degrain those areas while leaving the
rest alone. Most of the grain for instance is NOT on actors
faces and real live stuff. It appears they added in forced grain
to all the CGI created stuff like the cool skies.


I have been experimenting with a edge/detail finding filters than then mask those areas
which I then use so that the grain removal does NOT remove from the masked areas.
In fact I'm doing it right now and the results are very impressive. I have been able
to turn up grain removal while keeping even more detail than before. This
is how I plan to do the final encode for sure. The down side is SUPER SLOW
It will take days to encode the final.

Last edited by Zep; 6th December 2007 at 00:07.
Zep is offline   Reply With Quote
Old 5th December 2007, 23:27   #28  |  Link
Sagekilla
x264aholic
 
Join Date: Jul 2007
Location: New York
Posts: 1,752
Quote:
Originally Posted by Zep View Post
which is why if you look at my clips you will see I did not remove all the grain.

Comparing to the Bluray 95% of detail is still there after my grain removal and is the best
balance I could get. i.e. get rid of just enough grain and grain dancing to not annoy me
while watching and thus keep most of detail intact to not annoy me on that front as well
I wish I had a Blu-ray source to work off of like you do, I just went with HQdn3D() after a resize since RemoveGrain(19) decimated WAY too much detail and softened the image a lot.
Sagekilla is offline   Reply With Quote
Old 6th December 2007, 00:20   #29  |  Link
Pookie
Registered User
 
Join Date: Apr 2005
Posts: 1,339
Didee's suggestions from previous threads:


Code:
source=last
denoised=fft3dfilter(sigma=8,sigma2=8,plane=4,degrid=1)
backward_vec2 = MVAnalyse(denoised,isb = true, delta = 2, pel = 2, blksize=16, overlap=8, sharp=1, idx = 1)
backward_vec1 = MVAnalyse(denoised,isb = true, delta = 1, pel = 2, blksize=16, overlap=8, sharp=1, idx = 1)
forward_vec1 = MVAnalyse(denoised,isb = false, delta = 1, pel = 2, blksize=16, overlap=8, sharp=1, idx = 1)
forward_vec2 = MVAnalyse(denoised,isb = false, delta = 2, pel = 2, blksize=16, overlap=8, sharp=1, idx = 1)
MVDegrain2(source,backward_vec1,forward_vec1,backward_vec2,forward_vec2,thSAD=800,idx=2)

Last edited by Pookie; 6th December 2007 at 00:26.
Pookie is offline   Reply With Quote
Old 6th December 2007, 00:58   #30  |  Link
Didée
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 5,394
Similar, but not exactly like that. The prefilter should be able to cut down the grain almost completely. Some loss of detail is nothing to worry about at this stage. Then, thSAD should not be increased, but instead decreased from the default 400.
Using a prefilter together with such a high thSAD is guaranteed to introduce artifacts in areas where MC fails.

Alltogether, that suggestion was just an "easy" version of a general methodology. A script allowing for full control over all aspects is ten times as long as that, and quite a bit slower as well.
__________________
- We´re at the beginning of the end of mankind´s childhood -

My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!)
Didée is offline   Reply With Quote
Old 6th December 2007, 01:13   #31  |  Link
Pookie
Registered User
 
Join Date: Apr 2005
Posts: 1,339
"Using a prefilter together with such a high thSAD is guaranteed to introduce artifacts in areas where MC fails"

Indeed. You can't tell from the cropped example source file what thSAD values to use because it is only a small segment of wall and sky. It would be nice to see something of detail to determine if the degraining is going to be too strong.
Pookie is offline   Reply With Quote
Old 6th December 2007, 02:33   #32  |  Link
Sagekilla
x264aholic
 
Join Date: Jul 2007
Location: New York
Posts: 1,752
Quote:
Originally Posted by Didée View Post
Similar, but not exactly like that. The prefilter should be able to cut down the grain almost completely. Some loss of detail is nothing to worry about at this stage. Then, thSAD should not be increased, but instead decreased from the default 400.
Using a prefilter together with such a high thSAD is guaranteed to introduce artifacts in areas where MC fails.

Alltogether, that suggestion was just an "easy" version of a general methodology. A script allowing for full control over all aspects is ten times as long as that, and quite a bit slower as well.
I can see plenty of places where the MC fails and 300 becomes a soupy mess.. Namely the snow scene with the wolf, where the snow just accumulates and becomes a soup of artifacts.

Can you recommend a version that'll work without those problems?
Sagekilla is offline   Reply With Quote
Old 6th December 2007, 17:46   #33  |  Link
Didée
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 5,394
@ Sagekilla:
In other words, you mean if the holy grail of noise removal already has been discovered?
I fear it has not, yet.


@ Zep: Some more thoughts on "dancing" grain.

This sort of "dancing" usually isn't a property of the original grain, at least for the most part. Grain in itself usually is a high-frequency distortion only. The "dancing" effect is introduced by lossy DCT-based compressors, where in the lossy compression process some error is introduced into the low-frequency parts, caused mainly by the hi-frequency parts.

Something to try: the following script will remove the low-frequency flicker, leaving the high-frequencies intact.

Code:
#LoadPlugins: MedianBlur.dll 
#             RemoveGrain.dll 
#             mt_masktools.dll 
#             FluxSmooth.dll

AviSource("K:\300_original.avi")

o = last
f = o.MinBlur(1,2).MinBlur(2,2).RemoveGrain(11,-1)
f.FluxSmoothT(7).mt_AddDiff(mt_MakeDiff(o,f,U=2,V=2),U=4,V=4) 

# eventually, limit the maximum pixel change to +/- 2 :
# mt_LutXY(o,last,"x 2 + y < x 2 + x 2 - y > x 2 - y ? ?",U=2,V=2)

# to compare:
stackvertical(o,last)
#interleave(o,last)

return(last)

#------------------------------------------
# Taken from MCBob.avs:
function MinBlur(clip clp, int r, int "uv")
{
uv   = default(uv,3)
uv2  = (uv==2) ? 1 : uv
rg4  = (uv==3) ? 4 : -1
rg11 = (uv==3) ? 11 : -1
rg20 = (uv==3) ? 20 : -1
medf = (uv==3) ? 1 : -200

RG11D = (r==1) ? mt_makediff(clp,clp.removegrain(11,rg11),U=uv2,V=uv2)
 \    : (r==2) ? mt_makediff(clp,clp.removegrain(11,rg11).removegrain(20,rg20),U=uv2,V=uv2)
 \    :          mt_makediff(clp,clp.removegrain(11,rg11).removegrain(20,rg20).removegrain(20,rg20),U=uv2,V=uv2)
RG4D  = (r==1) ? mt_makediff(clp,clp.removegrain(4,rg4),U=uv2,V=uv2)
 \    : (r==2) ? mt_makediff(clp,clp.medianblur(2,2*medf,2*medf),U=uv2,V=uv2)
 \    :          mt_makediff(clp,clp.medianblur(3,3*medf,3*medf),U=uv2,V=uv2)
DD    = mt_lutxy(RG11D,RG4D,"x 128 - y 128 - * 0 < 128 x 128 - abs y 128 - abs < x y ? ?",U=uv2,V=uv2)
clp.mt_makediff(DD,U=uv,V=uv)
return(last)
}
In result, there will be almost no smoothing, and the grain basically is fully preserved. It's just the flicker, or "dancing" effect, that will be removed.
As a side-effect, there might occur some slight toning-down of shadings when there is motion. One can definetly see it in single-frame comparisons by flipping between original and processed. But one will hardly note that during watching the movie.
__________________
- We´re at the beginning of the end of mankind´s childhood -

My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!)

Last edited by Didée; 22nd April 2008 at 11:54. Reason: some script bugfixes
Didée is offline   Reply With Quote
Old 6th December 2007, 22:20   #34  |  Link
Zep
Registered User
 
Join Date: Jul 2002
Posts: 587
Quote:
Originally Posted by Pookie View Post
"Using a prefilter together with such a high thSAD is guaranteed to introduce artifacts in areas where MC fails"

Indeed. You can't tell from the cropped example source file what thSAD values to use because it is only a small segment of wall and sky. It would be nice to see something of detail to determine if the degraining is going to be too strong.

download the original clip it is in a link above
Zep is offline   Reply With Quote
Old 6th December 2007, 22:22   #35  |  Link
Zep
Registered User
 
Join Date: Jul 2002
Posts: 587
Quote:
Originally Posted by Didée View Post
@ Sagekilla:
In other words, you mean if the holy grail of noise removal already has been discovered?
I fear it has not, yet.


@ Zep: Some more thoughts on "dancing" grain.

This sort of "dancing" usually isn't a property of the original grain, at least for the most part. Grain in itself usually is a high-frequency distortion only. The "dancing" effect is introduced by lossy DCT-based compressors, where in the lossy compression process some error is introduced into the low-frequency parts, caused mainly by the hi-frequency parts.

Something to try: the following script will remove the low-frequency flicker, leaving the high-frequencies intact.

Code:
#LoadPlugins: MedianBlur.dll 
#             RemoveGrain.dll 
#             mt_masktools.dll 
#             FluxSmooth.dll

AviSource("K:\300_original.avi")

o = last
f = o.MinBlur(1,2).MinBlur(2,2).RemoveGrain(11,-1)
f.FluxSmoothT(7).mt_AddDiff(mt_MakeDiff(o,f,U=1,V=1),U=4,V=4) 

# eventually, limit the maximum pixel change to +/- 2 :
# mt_LutXY(last,o,"x 2 + y < x 2 + x 2 - y > x 2 - x ? ?",U=2,V=2)

# to compare:
stackvertical(o,last)
#interleave(o,last)

return(last)

#------------------------------------------
# Taken from MCBob.avs:
function MinBlur(clip clp, int r, int "uv")
{
uv   = default(uv,3)
uv2  = (uv==2) ? 1 : uv
rg4  = (uv==3) ? 4 : -1
rg11 = (uv==3) ? 11 : -1
rg20 = (uv==3) ? 20 : -1
medf = (uv==3) ? 1 : -200

RG11D = (r==1) ? mt_makediff(clp,clp.removegrain(11,rg11),U=uv2,V=uv2)
 \    : (r==2) ? mt_makediff(clp,clp.removegrain(11,rg11).removegrain(20,rg20),U=uv2,V=uv2)
 \    :          mt_makediff(clp,clp.removegrain(11,rg11).removegrain(20,rg20).removegrain(20,rg20),U=uv2,V=uv2)
RG4D  = (r==1) ? mt_makediff(clp,clp.removegrain(4,rg4),U=uv2,V=uv2)
 \    : (r==2) ? mt_makediff(clp,clp.medianblur(2,2*medf,2*medf),U=uv2,V=uv2)
 \    :          mt_makediff(clp,clp.medianblur(3,3*medf,3*medf),U=uv2,V=uv2)
DD    = mt_lutxy(RG11D,RG4D,"x 128 - y 128 - * 0 < 128 x 128 - abs y 128 - abs < x y ? ?",U=uv2,V=uv2)
clp.mt_makediff(DD,U=uv,V=uv)
return(last)
}
In result, there will be almost no smoothing, and the grain basically is fully preserved. It's just the flicker, or "dancing" effect, that will be removed.
As a side-effect, there might occur some slight toning-down of shadings when there is motion. One can definetly see it in single-frame comparisons by flipping between original and processed. But one will hardly note that during watching the movie.

ok I guess I finally found all the same versions of the plugins you are using.
My result was not that good. for me my removal is much better. not only is more grain
removed and less dancing grain with what does remain but more detail in mine is retained.

however mine runs slower than the above by a fair bit.


thanks for the ideas though

Last edited by Zep; 7th December 2007 at 10:48.
Zep is offline   Reply With Quote
Old 6th December 2007, 23:21   #36  |  Link
Sagekilla
x264aholic
 
Join Date: Jul 2007
Location: New York
Posts: 1,752
Thanks for the script Didee! It worked much better than any of the other methods before (for me anyway.) I didn't get much of a bitrate reduction, 100-150 kbps at best, but at least the grain isn't jumping around like it used to, and I still get retain some of the "detail," even if some of it is fake from the grain. It may not be the Holy Grail of removing noise/grain, but for 300 it works perfectly.

Edit: I tried it out on my copy of "Knocked Up" as well, and it seemed to do a very nice job of stabilizing the grain so the backgrounds look static for the most part.

Last edited by Sagekilla; 6th December 2007 at 23:36.
Sagekilla is offline   Reply With Quote
Old 7th December 2007, 10:46   #37  |  Link
Zep
Registered User
 
Join Date: Jul 2002
Posts: 587
Quote:
Originally Posted by Sagekilla View Post
Thanks for the script Didee! It worked much better than any of the other methods before (for me anyway.) I didn't get much of a bitrate reduction, 100-150 kbps at best,

because it is not really doing much. At least for me it only reduces the amount of grain by a very small amount and what is left is dancing around almost as much.

if you want to see a fast and really good grain removal use ffdshow noise removal and turn on Denoise3d but only use the HQ setting and max it out. Very fast and very good.


Now mix that with your avi synth script and tweak from there.


I think you see better results because you are not coming from the Bluray but are using the lower rez version which has far less grain and most of these plugs are geared to low rez DVD. Removegrain just can't cut it on high rez Bluray source and this is where removegrainHD is better and why it was written.

Last edited by Zep; 7th December 2007 at 10:53.
Zep is offline   Reply With Quote
Old 7th December 2007, 15:31   #38  |  Link
Terranigma
*Space Reserved*
 
Terranigma's Avatar
 
Join Date: May 2006
Posts: 953
Quote:
Originally Posted by Zep View Post
because it is not really doing much.
Did you remove the stackvertical line, and uncomment interleave/mt_LutXY and added selectevery(2,1)?
Terranigma is offline   Reply With Quote
Old 7th December 2007, 16:42   #39  |  Link
Didée
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 5,394
Zep, it seems you were expecting the wrong thing from that script...

Quote:
My result was not that good.
because it is not really doing much. At least for me it only reduces the amount of grain by a very small amount
That was exactly the aim of the exercise. The grain is hardly touched at all. Removed are only the bad effects that the grain forced the original source encoder to do.

Quote:
...and what is left is dancing around almost as much.
Can't agree with that. To my eyes it looks noticeable different.
If I literally go one step back - so that I hardly can see the hi-freq grain at all anymore - then I still see lots of flickering in the "original", while the lowpass-processed one looks pretty solid.


Quote:
for me my removal is much better. not only is more grain removed and less dancing grain with what does remain...
no doubt about that. Since my script didnt't try at all to remove any grain, your script surely did remove more.

Again: That script was in no way meant for grain removal. It was also not meant as script to use for final encoding (although one can do so, if the result happens to be sufficient and pleasant.)
It was only showing that one of the major annoyances of very grainy sources, namely the low-frequency flicker - can be tackled with rather simple means.
One step further, something in this direction often is very useful for subsequent motioncompensated denoising. If the flicker is left in, it eventually will also disturb the ME engine (making the vectors follow the flicker, causing spatial shifts where in fact there should be none), which will lower the benefit one can get from MC-NR. When the flicker is taken out before the motion search, chances are better to get more clean vectors.

Quote:
...but more detail in mine is retained.
Is it so? Or is it perhaps wishful thinking?

Random example: Frame 180.

The overall difference caused by ...

left: my script, right: your 'best.so.far' clip
-

Or: flip forth-back between these three: my script - original - your 'best.so.far'
- -

Okay, we didn't see either your latest script or its results, but from what you said it was basically similar to what you showed with 'best.so.far", plus masking of certain areas, allowing for even stronger settings. Now, I doubt that the kinds of negative impacts, as shown above, can be rescued by only a little masking...
Get this right: the result of your 'best.so.far' is not bad at all, it's quite good. But there *is* smearing / shifting, and there *is* detail loss. Hence I can't follow your finding that your script "keeps more detail", when mine doesn't loose any to start with.

We surely all are interested in seeing the latest script you came up with. However, after years of toying around with very grainy sources in all kinds of even-so-sophisticated ways, I can tell: grain removal on strong-grained sources won't ever be perfect. It's always a "you win here, you lose there" game. Winning without losing is out of reach.

---

BTW, what BlureRay is this that we're juggling around with 720p?
__________________
- We´re at the beginning of the end of mankind´s childhood -

My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!)
Didée is offline   Reply With Quote
Old 7th December 2007, 17:15   #40  |  Link
Terranigma
*Space Reserved*
 
Terranigma's Avatar
 
Join Date: May 2006
Posts: 953
Quote:
Originally Posted by Didée View Post
One step further, something in this direction often is very useful for subsequent motioncompensated denoising. If the flicker is left in, it eventually will also disturb the ME engine (making the vectors follow the flicker, causing spatial shifts where in fact there should be none), which will lower the benefit one can get from MC-NR. When the flicker is taken out before the motion search, chances are better to get more clean vectors.
Didée, are you saying it'd be more beneficial to use this idea you came up with, to remove low-frequencies, will work better if it's used before mo-comp. denoising?
Terranigma is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:21.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.