Quantcast Avisynth: Motion Adaptive Filtering Now Possible? - Page 20 - digitalFAQ.com Forums [Archives]
  #381  
06-05-2003, 03:33 PM
kwag kwag is offline
Free Member
 
Join Date: Apr 2002
Location: Puerto Rico, USA
Posts: 13,537
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by Jellygoose
I'll give that a try right now, thanks for the tip kwag!

Edit: However, since it was last tested a long time ago, I'd like to give that a try too! remember CQ_VBR did beat CQ a long time ago too... TMPGEnc has changed maybe, so if you don't mind sending me the part of the script with adaptive Blockbuster variance, I'll give it a shot!
Sure

Here you go:

First define these lines, right after the MaxTreshold line. Like this:

Code:
MaxTreshold = 1.50
bb_method="noise"
bb_noise=True
Now add this lines AFTER the scene detection line:

ScriptClip("bb_noise && nf > 0.001 ? BlockBuster(method=bb_method, detail_min=1, detail_max=6, variance=((1/nf)*8 ), seed=0) : \
BlockBuster(method=bb_method, detail_min=100, detail_max=100, variance=0, seed=0 ) ")


That's it
Play with the "8" in the variance, and also the detail_min.
If you don't want BlockBuster, you don't need to delete the functions Just edit bb_noise=True to read bb_noise=False

Enjoy!,
-kwag
Reply With Quote
Someday, 12:01 PM
admin's Avatar
Site Staff / Ad Manager
 
Join Date: Dec 2002
Posts: 42
Thanks: ∞
Thanked 42 Times in 42 Posts
  #382  
06-05-2003, 04:00 PM
Jellygoose Jellygoose is offline
Free Member
 
Join Date: Jun 2002
Location: Germany
Posts: 1,288
Thanks: 0
Thanked 0 Times in 0 Posts
Much appreciated, thank you KleverWag...
__________________
j3llyG0053
Reply With Quote
  #383  
06-05-2003, 04:41 PM
Jellygoose Jellygoose is offline
Free Member
 
Join Date: Jun 2002
Location: Germany
Posts: 1,288
Thanks: 0
Thanked 0 Times in 0 Posts
Ok, I raised the Min. Bitrate Value to 450, which is VERY high in my eyes... however, I don't see a difference in picture quality compared to the 100 kb min. Bitrate that I use...
I still see that the current script, seems to enhance artifacts around objects for some reason... well it's a matter of taste maybe... I'll try to play a little around with blockbuster and aSharp... if you're interested in the results just drop me a PM...

BtW: I just ordered myself the Cyberhome DV-CH 505 Player, to see if that wonderful picture that this player's supposed to have is for real... Well even if not, the player was a bargain for 105 Euro's, and it looks sooo cool here's a pic: http://cgi.ebay.de/ws/eBayISAPI.dll?...&category=8329
__________________
j3llyG0053
Reply With Quote
  #384  
06-05-2003, 04:52 PM
kwag kwag is offline
Free Member
 
Join Date: Apr 2002
Location: Puerto Rico, USA
Posts: 13,537
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by Jellygoose
Ok, I raised the Min. Bitrate Value to 450, which is VERY high in my eyes... however, I don't see a difference in picture quality compared to the 100 kb min.
Yep, you're right. I even did a test at 10,000Kbps constant bit rate on some special dark gray scenes, and DCT blocks are present. It's not a bitrate related issue

-kwag
Reply With Quote
  #385  
06-05-2003, 04:56 PM
Jellygoose Jellygoose is offline
Free Member
 
Join Date: Jun 2002
Location: Germany
Posts: 1,288
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by kwag
Quote:
Originally Posted by Jellygoose
Ok, I raised the Min. Bitrate Value to 450, which is VERY high in my eyes... however, I don't see a difference in picture quality compared to the 100 kb min.
Yep, you're right. I even did a test at 10,000Kbps constant bit rate on some special dark gray scenes, and DCT blocks are present. It's not a bitrate related issue

-kwag
Well I'm positive that it is always source related, although you might not see it at all in the source... I know of movies that I encoded myself, with very similar dark scenes with fog and rain, and DCT blocks did not show up at all on my backup...

Edit: I know this didn't help at all, but I just wanted to say something
__________________
j3llyG0053
Reply With Quote
  #386  
06-05-2003, 05:29 PM
Jellygoose Jellygoose is offline
Free Member
 
Join Date: Jun 2002
Location: Germany
Posts: 1,288
Thanks: 0
Thanked 0 Times in 0 Posts
Haven't had any luck with Blockbuster either, to get rid of those blocks... It seems pretty difficult to adjust the noise in the adaptive script...
I actually thought that blockbuster was already kind of adaptive, because noise was only added to areas where detail was below a certain value. so now the amount of noise added to those areas is linear adaptive right?
well are the values you posted your standard values?
Very agressive, as far as I can tell... I tried to lower the amount of noise by changing the 8 into a 5... am I on the right track?
__________________
j3llyG0053
Reply With Quote
  #387  
06-05-2003, 07:11 PM
DKruskie DKruskie is offline
Free Member
 
Join Date: May 2003
Location: Michigan
Posts: 147
Thanks: 0
Thanked 0 Times in 0 Posts
I'm using the latest script, but for some reason my letterboxing is not working..here is the script from tok.

## DLL Section ##
#
LoadPlugin("C:\Filters25\MPEG2Dec3.dll")
LoadPlugin("C:\Filters25\STMedianFilter.dll")
LoadPlugin("C:\Filters25\UnFilter.dll")
LoadPlugin("C:\Filters25\asharp.dll")
LoadPlugin("C:\Filters25\undot.dll")
#
####

## Defined Variables and Constants ##
#
MaxTreshold = 1.50
scd_trigger = 15 # Scene change trigger value.
nf = 0 # Current frame.
#
####

## Main section and static filters ###
#
Mpeg2Source("C:\DVD\longkiss.d2v")
#
undot()
Limiter()
asharp(2, 4)
BicubicResize(352,240,0,0.6,8,0,704,480)
STMedianFilter(8, 32, 0, 0 )
MergeChroma(blur(MaxTreshold))
MergeLuma(blur(0.2))
#
#

## Dynamic Linear Adaptive Filtering and Scene Change Detection ##
#
# ( Portions from AviSynth's manual ) - This will apply temporalsoften to
# very static scenes, and apply variable blur on moving scenes.
# We also assign a variable - and this is why a line break is inserted:

ScriptClip("nf = YDifferenceToNext()"+chr(13)+ "nf > 2.5 ? asharp( -(fmin((nf/35), 1)), 0 ) : \
TemporalSoften(2,7,7,3,2) ")

#
# Scene change detection ( kwag ) - If a scene change is detected, we
# blur heavily. This affects the scene before and the one after the
# scene change, thus providing a softer transition for the encoder instead
# of a sharp "spike".
# If it's not a scene change, then we just blur dynamically, depending on
# the action.

ScriptClip("nf > scd_trigger ? asharp( -2,0) : asharp( -(fmin((nf/35), 1)), 0) ")

#
#
#

#LetterBox(16,16,16,16) # Depends on situation. Use MovieStacker!
#AddBorders(0,0,0,0) # Depends on situation. Use MovieStacker!
Limiter()

#
#
## Functions ###

function fmin(float f1, float f2) {
return (f1<f2) ? f1 : f2
}

#
####
AssumeFPS(23.976)
LoadPlugin("C:\TOK\ToK_EXTRAS\Sampler\Sampler-2.5.dll")
oldfps = framerate
interval = round((FrameCount/24)/59.940)/10
nFrames = round(24)
SelectRangeEvery( (round(framecount/interval)),nFrames)


David
Reply With Quote
  #388  
06-05-2003, 07:15 PM
Racer99 Racer99 is offline
Free Member
 
Join Date: Sep 2002
Location: Massachusetts
Posts: 119
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by DKruskie
#LetterBox(16,16,16,16) # Depends on situation. Use MovieStacker!

David
Shouldn't it be
Code:
LetterBox(16,16,16,16) # Depends on situation. Use MovieStacker!
Racer99
Reply With Quote
  #389  
06-05-2003, 07:23 PM
DKruskie DKruskie is offline
Free Member
 
Join Date: May 2003
Location: Michigan
Posts: 147
Thanks: 0
Thanked 0 Times in 0 Posts
Yep your right ..just tested it out and its working again..thanks


David
Reply With Quote
  #390  
06-05-2003, 09:34 PM
kwag kwag is offline
Free Member
 
Join Date: Apr 2002
Location: Puerto Rico, USA
Posts: 13,537
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by ARnet_tenRA
Here is a way to do it Kwag. I am sure you can optimize it more. I have added the GreyScale filter to show how each section is getting a different filter. Of course you can filter any way you want.
Code:
AviSource(" -Your movie here.- ")

aa=Crop(0*width/4,0*height/4,1*width/4,1*height/4).GreyScale()
ab=Crop(1*width/4,0*height/4,1*width/4,1*height/4)
ac=Crop(2*width/4,0*height/4,1*width/4,1*height/4).GreyScale()
ad=Crop(3*width/4,0*height/4,1*width/4,1*height/4)
ba=Crop(0*width/4,1*height/4,1*width/4,1*height/4)
bb=Crop(1*width/4,1*height/4,1*width/4,1*height/4).GreyScale()
bc=Crop(2*width/4,1*height/4,1*width/4,1*height/4)
bd=Crop(3*width/4,1*height/4,1*width/4,1*height/4).GreyScale()
ca=Crop(0*width/4,2*height/4,1*width/4,1*height/4).GreyScale()
cb=Crop(1*width/4,2*height/4,1*width/4,1*height/4)
cc=Crop(2*width/4,2*height/4,1*width/4,1*height/4).GreyScale()
cd=Crop(3*width/4,2*height/4,1*width/4,1*height/4)
da=Crop(0*width/4,3*height/4,1*width/4,1*height/4)
db=Crop(1*width/4,3*height/4,1*width/4,1*height/4).GreyScale()
dc=Crop(2*width/4,3*height/4,1*width/4,1*height/4)
dd=Crop(3*width/4,3*height/4,1*width/4,1*height/4).GreyScale()

StackVertical(StackHorizontal(aa,ab,ac,ad),StackHorizontal(ba,bb,bc,bd),StackHorizontal(ca,cb,cc,cd),StackHorizontal(da,db,dc,dd))
Regards, Tenra
Hi Tenra,

I've been playing with your script, and I have seen the horizon

I just tried this:

Code:
aa=Crop(0*width/4,0*height/4,1*width/4,1*height/4).asharp(4,0)
ab=Crop(1*width/4,0*height/4,1*width/4,1*height/4).asharp(-4,0)
ac=Crop(2*width/4,0*height/4,1*width/4,1*height/4).asharp(4,0)
ad=Crop(3*width/4,0*height/4,1*width/4,1*height/4).asharp(-4,0)
ba=Crop(0*width/4,1*height/4,1*width/4,1*height/4).asharp(4,0)
bb=Crop(1*width/4,1*height/4,1*width/4,1*height/4).asharp(-4,0)
bc=Crop(2*width/4,1*height/4,1*width/4,1*height/4).asharp(4,0)
bd=Crop(3*width/4,1*height/4,1*width/4,1*height/4).asharp(-4,0)
ca=Crop(0*width/4,2*height/4,1*width/4,1*height/4).asharp(4,0)
cb=Crop(1*width/4,2*height/4,1*width/4,1*height/4).asharp(-4,0)
cc=Crop(2*width/4,2*height/4,1*width/4,1*height/4).asharp(4,0)
cd=Crop(3*width/4,2*height/4,1*width/4,1*height/4).asharp(-4,0)
da=Crop(0*width/4,3*height/4,1*width/4,1*height/4).asharp(4,0)
db=Crop(1*width/4,3*height/4,1*width/4,1*height/4).asharp(-4,0)
dc=Crop(2*width/4,3*height/4,1*width/4,1*height/4).asharp(4,0)
dd=Crop(3*width/4,3*height/4,1*width/4,1*height/4).asharp(-4,0)
Just to verify that indeed asharp would apply to the specific quadrant. It works
Now we just need to grab the YDifferenceToNext function to actually return ONLY the corresponding quadrant from the following frame. If this is possible, we're gonna be rocking

-kwag
Reply With Quote
  #391  
06-06-2003, 01:10 AM
bman bman is offline
Free Member
 
Join Date: Apr 2002
Posts: 356
Thanks: 0
Thanked 0 Times in 0 Posts
@ Tenra
Nice result , man , Your script will give us new addaptive filter in very soon future
@Kwag
Script rocks and results are cool too but are sure that deviding frame for 4 quadrants is enough ???
I think For battle scenes with many moving parts it'll be just not enough to get same effect as in the pictures above .
Maybe it makes sence to make more quadrants : lets say 16 or even 25 ,36 ....
So we can blur just small part of whole frame and sharpen the other pars
Or maybe to make it flexible , to be dinamic number that will change according the movement on frame : more moveing parts bigger number and still picture just 4 .
It probably be not easy to program this kind or script but with our " Brilliant " minds I think it's quite possible to get .
Sorry for long blah,blah but when I see progress of this very same tread I get more appetite (I hope i wrote right)
Regards
bman
Reply With Quote
  #392  
06-06-2003, 05:26 AM
girv girv is offline
Free Member
 
Join Date: Sep 2002
Posts: 108
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to girv
On some sources I've found that filesize can grow when adaptive filtering is applied. Encoding a fairly low movement - mostly people talking - AVI source at 480x480 my test samples grow by about 1.2Mb out of 50Mb when adaptive filtering from the latest optimal script is applied, where other higher action sources shrink by a similar amount, all compared to base non-adaptive filtered encodes.

Anyone else noticed this or have I stuffed the tests?

Here's the dynamic part of the script. I know it looks different to Kwag's but the filters applied to each frame should be the same.
Code:
ScriptClip(  "ydp = YDifferenceFromPrevious()" + chr(13)
\ + "ydn = YDifferenceToNext()" + chr(13)
\ + "yd = ydp - ydn" + chr(13)
\ + "yb = ydn / 35" + chr(13)
\ + "yb = yb > 1 ? 1 : yb" + chr(13)
\ + "ydn     > 2.5 ? asharp(-yb,0) : TemporalSoften(2,7,7,3,2)" + chr(13)
\ + "Abs(yd) > 15  ? asharp(-1,0)  : asharp(-yb,0)")
Reply With Quote
  #393  
06-06-2003, 05:26 AM
girv girv is offline
Free Member
 
Join Date: Sep 2002
Posts: 108
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to girv
On some sources I've found that filesize can grow when adaptive filtering is applied. Encoding a fairly low movement - mostly people talking - AVI source at 480x480 my test samples grow by about 1.2Mb out of 50Mb when adaptive filtering from the latest optimal script is applied, where other higher action sources shrink by a similar amount, all compared to base non-adaptive filtered encodes.

Anyone else noticed this or have I stuffed the tests?

Here's the dynamic part of the script. Anything wrong?
Code:
ScriptClip(  "ydp = YDifferenceFromPrevious()" + chr(13)
			\ + "ydn = YDifferenceToNext()" + chr(13)
			\ + "yd = ydp - ydn" + chr(13)
			\ + "yb = ydn / 35" + chr(13)
			\ + "yb = yb > 1 ? 1 : yb" + chr(13)
			\ + "ydn     > 2.5 ? asharp(-yb,0) : TemporalSoften(2,7,7,3,2)" + chr(13)
			\ + "Abs(yd) > 15  ? asharp(-1,0)  : asharp(-yb,0)" + chr(13)
			\ + "last")
Reply With Quote
  #394  
06-06-2003, 05:55 AM
bman bman is offline
Free Member
 
Join Date: Apr 2002
Posts: 356
Thanks: 0
Thanked 0 Times in 0 Posts
Hi Girv !
Did u compared clips resulted yours and Kwag's script on the same source by size and visual quality ???
Did u tested DVD sources too ???
bman
Reply With Quote
  #395  
06-06-2003, 06:22 AM
rendalunit rendalunit is offline
Free Member
 
Join Date: Apr 2002
Location: san jose, Ca
Posts: 1,148
Thanks: 0
Thanked 0 Times in 0 Posts
sorry if this was already mentioned in this long thread but has anyone tried the Motion Adaptive Mixer by MarcFD

from the readme:
Code:
 MAM Motion Adaptive Mixer by MarcFD
(v0.6)

What it does:

      This filter uses movement detection (same engine as CopySame) to adapt the denoising method used :
      - In still areas it uses temporal filtering
      - In moving areas it uses spatial filtering
      The filter itself wouldn't make the filtering : you can use the filter you want :
      It's compatible with all avisynth filters !
      The ability to alternate the denoising method is used to avoid both blurring and ghosting
      Because each filter is used when it's the most accurate.

      Using M.A.M. you can use the best denoising possible on every area of you clip

Usage :

      Work only in YUY2 mode.
      Add the following lines in your .avs script :

      LoadPlugin("MAM.dll")
      *Source(...)
      MAM(Cnr2().TemporalSoften2(1,10,0),smoothHIQ(3,15,25,192,10))

      Syntax :

      MAM(temporal,spatial[,mode,lr,cr,md])


      mode
            effective work :
                + mode -1 : Debug mode : will draw in black moving areas. Use to tweak.
                + mode 0 : Normal mode. Fastest. MMX optimised
                + mode 1 : Blend : will blend the spatial and the temporal filtering in some cases. Please try. 

      temporal :
            your source filtered with any temporal filter
            avoid temporal filtering radius > 1 if you want the best ghosting protection

      spatial :
            your source filtered with any spatial filter
            No restrictions on spatial filtering.
            Just keep in mind your eye wouldn't be able to focus on moving areas

      lr,cr :
            lr for luma and cr for chroma
            Used to avoid noise movement
            Use soft values.Only increase if you see strange blur artifacts in still areas
            Defaults : 
      md :
            A denoising can be used on movement, for an optimal movement detection
            and better filtering. Use 0 to disable.
            1 is the more agressive setting, higher values would denoise less
It looks like this is exactly what we want to do
Reply With Quote
  #396  
06-06-2003, 06:48 AM
bman bman is offline
Free Member
 
Join Date: Apr 2002
Posts: 356
Thanks: 0
Thanked 0 Times in 0 Posts
@ rendal

Quote:
Usage :

Work only in YUY2 mode.
It could be useless in avs 2.5
bman
Reply With Quote
  #397  
06-06-2003, 08:30 AM
Jellygoose Jellygoose is offline
Free Member
 
Join Date: Jun 2002
Location: Germany
Posts: 1,288
Thanks: 0
Thanked 0 Times in 0 Posts
I already tried that MAM filter a long time ago with avisynth 2.07 and the quality was poor... It took extremely long and I remember I was really surprised how bad the result actually looked...
__________________
j3llyG0053
Reply With Quote
  #398  
06-06-2003, 09:03 AM
kwag kwag is offline
Free Member
 
Join Date: Apr 2002
Location: Puerto Rico, USA
Posts: 13,537
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by girv
On some sources I've found that filesize can grow when adaptive filtering is applied.
The reason is that on very low movement scenes, there is no blur applied at all Only TemporalSoften.
But on the full encoded film, the total file size should be smaller than without the adaptive filtering. Unless the complete movie is a drama that there's barely any action
If that's the case, then I would lower the line:
"nf > 2.5 ?"
To read:
"nf > 1.0 ?"
So that bluring starts at a lower activity.

-kwag
Reply With Quote
  #399  
06-06-2003, 09:58 AM
kwag kwag is offline
Free Member
 
Join Date: Apr 2002
Location: Puerto Rico, USA
Posts: 13,537
Thanks: 0
Thanked 0 Times in 0 Posts
Well my friends, my quadrant adaptive motion tests are over, at least for some time
I did it, but the result is unacceptable. I divided the screen in 32 quadrants, and applied the same filters that are on the current script to each quadrant.
The result in an encoding speed is 1 second every ~1 minute, 30 seconds on my P4 @1.6Ghz
So obviously, this is a no no situation. So the current script is about as far as we can go, that is, we can add more stuff but on a complete frame by frame basis. Forget about slicing each frame
Now I'm going to look at ren's recommendation on Motion Adaptive Mixer and see what it's all about. The description looks like it would fill in some gaps. So I'll take a look at that now.

Edit: MAM is a 2.0x filter. Bye!

-kwag
Reply With Quote
  #400  
06-06-2003, 10:22 AM
Jellygoose Jellygoose is offline
Free Member
 
Join Date: Jun 2002
Location: Germany
Posts: 1,288
Thanks: 0
Thanked 0 Times in 0 Posts
I already thought that it would take a LONG time to do all these kinds of calculations!!
I think we're already pretty well-off with the current script... However I'm still searching for a way to get rid of artifacts around objects and DCT Blocks in dark areas...
I know it's not bitrate related, because they're visible in every resolution I tested...
__________________
j3llyG0053
Reply With Quote
Reply




Similar Threads
Thread Thread Starter Forum Replies Last Post
Avisynth: Dynamic Linear Adaptive Filtering and Scene Change Detection supermule Avisynth Scripting 3 09-15-2006 01:45 AM
Avisynth: Message from linear motion adaptive filtering? holgerschlegel Avisynth Scripting 7 08-27-2003 04:08 AM
Avisynth: Help with Linear Motion Adaptive Filtering pitoman Avisynth Scripting 2 08-05-2003 12:51 PM
Avisynth: Motion adaptive filtering good enough? bicho_visacoso Avisynth Scripting 6 06-15-2003 06:30 AM
Avisynth: AVS 2.5x Script, Motion Adaptive Filtering problems? Bchteam Avisynth Scripting 15 05-31-2003 12:38 PM

Thread Tools



 
All times are GMT -5. The time now is 05:21 AM  —  vBulletin © Jelsoft Enterprises Ltd