Quantcast Avisynth: Motion Adaptive Filtering Now Possible? - Page 2 - digitalFAQ.com Forums [Archives]
  #21  
05-15-2003, 06:51 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
Ok, this looks very promising

-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
  #22  
05-15-2003, 07:31 PM
sbin sbin is offline
Free Member
 
Join Date: May 2003
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
clip = ConvertToYV12( clip )
If you use MarcFD's mpeg2dec3, there is no need for this line because it supports native YV12.

http://ziquash.chez.tiscali.fr/
Reply With Quote
  #23  
05-15-2003, 07:40 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 sbin
Quote:
clip = ConvertToYV12( clip )
If you use MarcFD's mpeg2dec3, there is no need for this line because it supports native YV12.

http://ziquash.chez.tiscali.fr/
Thanks , I was beginning to wonder if there was a workaround

-kwag
Reply With Quote
  #24  
05-15-2003, 07:48 PM
sbin sbin is offline
Free Member
 
Join Date: May 2003
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Not that it's really relevant to the thread, but MarcFD never ceases to amaze me. He may not be the absolute best AVS filter author, but for a 17-year-old kid he writes some pretty darned amazing stuff. This guy is going to be bringing us a LOT of good stuff in the future.
Reply With Quote
  #25  
05-15-2003, 07:54 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 sbin
but for a 17-year-old kid he writes some pretty darned amazing stuff.
Damn, I wish I had a computer when I was 17
If I had, then probably KVCD would have been a standard in every home on every DVD player

-kwag
Reply With Quote
  #26  
05-16-2003, 01:45 AM
sbin sbin is offline
Free Member
 
Join Date: May 2003
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Ok, there is definitely a problem with the stmedianfilter and temporalsoften settings. Using the straight current script, I get a file size of 12,434k, which is actually smaller than what I get with the best motion adaptive settings in the new script. Here are some file sizes. When I say "motion adaptive" I mean I used the luma blurring values of 1.5/.75/.2. In the case of the current script, that means some colorspace conversions.

current script = 12,434k
current script + motion adaptive = 11,867k

new script = 13,404k
new script + motion adaptive = 12,598k

Although there is no doubt that motion adaptive filtering reduces file size, the new script overall is not as good as the current script. Then I started wondering which new filter was the culprit. I replaced temporalsoften with the old temporalsmoother(1,2) (and, of course, the accompanying colorspace conversion) and got a file size of 13,054k - somewhere in the middle. Replacing stmedianfilter with the old 2.0 version and current script values got me down to the same size as the current script.

So while the principle is sound, the script needs a lot of tweaking to be as good as the current script. The following script gave me my best file size to date (11,867k):
Code:
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins20\LoadPluginEx.dll")
Loadplugin("C:\Program Files\AviSynth 2.5\plugins20\STMedianFilter.dll")
Loadplugin("C:\Program Files\AviSynth 2.5\plugins20\unfilter.dll")
Loadplugin("C:\Program Files\AviSynth 2.5\plugins20\legalclip.dll")
Loadplugin("C:\Program Files\AviSynth 2.5\plugins20\mpeg2dec.dll")


threshold_sm = 5 
threshold_hm = 15 
Width = 544 
Height = 480 

clip = Mpeg2Source("Z:\SPYLVESE\spy.d2v")
clip = ConverttoYUY2(clip)
clip = BilinearResize(clip, 544,368,5,0,710,480)  
clip = Crop(clip, 0, 44, -0, -44)
clip = STMedianFilter(clip, 10, 30, 0, 0, 10, 30) 
clip = unfilter(clip, 50,50) 
clip = temporalsmoother(clip, 1,2) 
clip = ConverttoYV12(clip)
clip = Filter_Motion( clip, Width, Height, threshold_sm, threshold_hm) 
clip = AddBorders(clip, 0,100,0,100) 
clip = Limiter(clip)
clip = Sampler(clip, Length=24)

return clip

#####################
##### Functions ##### 
#####################

### High motion filtering 
function Motion_High( clip High, float X, float Y) 
{  
High = mergechroma(High,blur(High,1.50))
High = mergeluma(High,blur(High,1.50))
Return High 
} 

### Medium motion filtering 
function Motion_Medium( clip Medium, float X, float Y) 
{ 
Medium  = mergechroma(Medium ,blur(Medium,1.50))
Medium  = mergeluma(Medium ,blur(Medium,.75))
Return Medium 
} 

### Low motion filtering 
function Motion_Low( clip Low, float X, float Y) 
{ 
Low  = mergechroma(Low ,blur(Low,1.50))
Low  = mergeluma(Low ,blur(Low,.20))
Return Low 
} 

### Detect high, medium, or low motion 
function Detect_Motion( clip detect, clip Low, clip Medium, clip High, float threshold_sm, float threshold_hm) 
{ 
global Courant_fr = detect 
global Next_fr = detect.trim(1,0) 
output1 = Conditionalfilter( Courant_fr, Low, Medium, "YDifferenceFromPrevious() + UDifferenceFromPrevious() + VDifferenceFromPrevious()", "<", "threshold_sm", false) 
output2 = Conditionalfilter( Next_fr, output1, Medium, "YDifferenceFromPrevious() + UDifferenceFromPrevious() + VDifferenceFromPrevious()", "<", "threshold_sm", false) 
output3 = Conditionalfilter( Courant_fr, High, output2, "YDifferenceFromPrevious() + UDifferenceFromPrevious() + VDifferenceFromPrevious()", ">", "threshold_hm", false) 
output4 = Conditionalfilter( Next_fr, output3, output2, "YDifferenceFromPrevious() + UDifferenceFromPrevious() + VDifferenceFromPrevious()", ">", "threshold_hm", false) 
return output4 
} 

### Filter the scene based on motion 
function Filter_Motion( clip filter, float X, float Y, float threshold_sm, float threshold_hm) 
{ 
Low = Motion_Low( filter, X, Y) 
Medium = Motion_Medium( filter, X, Y) 
High = Motion_High( filter, X, Y) 
output = Detect_Motion( filter, Low, Medium, High, threshold_sm, threshold_hm) 
return output 
}
Reply With Quote
  #27  
05-16-2003, 03:58 AM
bman bman is offline
Free Member
 
Join Date: Apr 2002
Posts: 356
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by sbin
The following script gave me my best file size to date (11,867k):
That's very interesting .
According your test it's worth to switch to AVS v2.51 !!???
This Filter combination is my favorite for almoast every my encodes .
What I'm interesting is If u can compare resulted clip quality to quality without Filter_Motion . To make it easy to understand let's say : with Motion CQ 60 and to get the same visual quality clip without Motion - CQ 65 .
It's easyer to see difference ( if there is any ) when we express it in numbers .
Please report if u have new results about Filter_Motion .
bman
Reply With Quote
  #28  
05-16-2003, 04:10 AM
jorel jorel is offline
Invalid Email / Banned / Spammer
 
Join Date: Aug 2002
Location: Brasil - MG - third stone from the sun
Posts: 5,570
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by sbin
Not that it's really relevant to the thread, but MarcFD never ceases to amaze me. He may not be the absolute best AVS filter author, but for a 17-year-old kid he writes some pretty darned amazing stuff. This guy is going to be bringing us a LOT of good stuff in the future.
you're right sbin!


MarcFD is fantastic.
Reply With Quote
  #29  
05-16-2003, 07:32 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
I just noticed that I can't use this script with ToK
The current version of ToK sets the file prediction at the end of the script, and it doesn't work
I also tried to move it to the top, after the "clip = Mpeg2source( Source )" line, and it doesn't work either
I believe that Sampler.dll has been compiled for avisynth 2.5x
I guess in order to use this method, we must use manual file size prediction until we can get a fix for using this with ToK

-kwag
Reply With Quote
  #30  
05-16-2003, 03:45 PM
Jellygoose Jellygoose is offline
Free Member
 
Join Date: Jun 2002
Location: Germany
Posts: 1,288
Thanks: 0
Thanked 0 Times in 0 Posts
amazing work, all of you!
i hope this thread leads us to another big improvement in quality...
hopefully SansGrip can compile the sampler.dll to AviSynth2.51.

Isn't there some kind of integrated filter in the newest AviSynth version that does the same thing the sampler.dll?

Keep up the good work! I'll try this new stuff out tomorrow!
btw: can you run AviSynth2.0x and AviSynth2.5x at the same time?
__________________
j3llyG0053
Reply With Quote
  #31  
05-16-2003, 05:05 PM
Sagittaire Sagittaire is offline
Free Member
 
Join Date: May 2003
Posts: 97
Thanks: 0
Thanked 0 Times in 0 Posts
I am the author of this intelligent script. The objective of this intelligent script is of detecter the various types of motion and to apply filters specific. Here some French addresses to use this script correctly.

Downlaod
http://jfl1974.free.fr/HTM/Download.htm

FAQ filters avisynth
http://jfl1974.free.fr/HTM/21_Test_Filtres.htm

Comparative of the video codecs
http://jfl1974.free.fr/HTM/22_Test_Codec_Video.htm

FAQ ffdshow
http://jfl1974.free.fr/HTM/24_ffdshow.htm

And here the last version of this script. I added "subtitle" so that you observe how script works. You can modify the threshold to make script more or less senssible to the scene fast and slow ...

Code:
###################################################################################

# AviSynth 2.51 #

# Script Motion Detection Filter YV12 #

###################################################################################


#################################### Faq ...;-) ###################################


# MPEG2Dec3.dll #
# Convolution3DYV12.dll #
# FluxSmooth-2.5.dll #
# Unfilter.dll #

# Source : Path projet .d2v of DVD2AVI 1.76 #
# CPU_type : you will choose 5 for Pentium IV and 2 for the other processors #

# Threshold : adjustment of the threshold of detection of the scenes #

# Top : Crop top of the image #
# Left : Crop left of the image #
# Right : Crop right of the image #
# Bottom : Crop bottom of the image #

# DimX : Width of the image #
# DimY : Height of the image #

# Start : Start Frame #
# End : End Frame #



#################################### Variables ####################################


Source = "C:\Stock\azerty.d2v"
CPU_type = 2

threshold_sm = 5
threshold_hm = 15

Top = 76
Left = 16 
Right = 16 
Bottom = 74

DimX = 640 
DimY = 272

Start = 0
End = 0



################################# Script Principal ################################


clip = Mpeg2Source( Source, idct = CPU_type)
clip = Trim( clip, Start, End)
clip = Crop( clip, Left, Top, -Right, -Bottom)
clip = lumafilter( clip, 0, 0.9)
clip = Unfilter( clip, +4, +4) 
clip = Filter_Motion( clip, DimX, DimY, threshold_sm, threshold_hm)
clip = FluxSmooth( clip, 5, 3)
clip = limiter( clip)
Return clip



#################################### Fonctions ####################################


# Motion_Hight : function of filtering of fast scenes #

function Motion_Hight( clip Hight, float X, float Y)

{

Hight = Convolution3D( Hight, 0, 8, 12, 8, 12, 3, 0)
Hight = BicubicResize( Hight, X, Y, 0.33, 0.33)
Return Hight.subtitle("Hight")

}



# Motion_Medium : function of filtering of Mediums scenes #

function Motion_Medium( clip Medium, float X, float Y)

{

Medium = Convolution3D( Medium, 0, 4, 6, 4, 6, 2.75, 0)
Medium = BicubicResize( Medium, X, Y, 0, 0.5)
Return Medium.subtitle("Medium")

}



# Motion_Slow : function of filtering of Slow scenes #

function Motion_Slow( clip Slow, float X, float Y)

{

Slow = Convolution3D( Slow, 0, 2, 3, 2, 3, 2.5, 0)
Slow = BicubicResize( Slow, X, Y, 0, 0.7)
Return Slow.subtitle("Slow")

}



# Detect_Motion : function of detection of scenes slow, medium and rapid #

function Detect_Motion( clip detect, clip Slow, clip Medium, clip Hight, float threshold_sm, float threshold_hm)

{

global Courant_fr = detect
global Next_fr = detect.trim(1,0)

output1 = Conditionalfilter( Courant_fr, Slow, Medium, "YDifferenceFromPrevious() + UDifferenceFromPrevious() + VDifferenceFromPrevious()", "<", "threshold_sm", false)

output2 = Conditionalfilter( Next_fr, output1, Medium, "YDifferenceFromPrevious() + UDifferenceFromPrevious() + VDifferenceFromPrevious()", "<", "threshold_sm", false)

output3 = Conditionalfilter( Courant_fr, Hight, output2, "YDifferenceFromPrevious() + UDifferenceFromPrevious() + VDifferenceFromPrevious()", ">", "threshold_hm", false)

output4 = Conditionalfilter( Next_fr, output3, output2, "YDifferenceFromPrevious() + UDifferenceFromPrevious() + VDifferenceFromPrevious()", ">", "threshold_hm", false)

return output4

}



# Filter_Motion : function of filtage of scenes slow, medium and rapid #

function Filter_Motion( clip filter, float X, float Y, float threshold_sm, float threshold_hm)

{

Slow = Motion_Slow( filter, X, Y)
Medium = Motion_Medium( filter, X, Y)
Hight = Motion_Hight( filter, X, Y)
output = Detect_Motion( filter, Slow, Medium, Hight, threshold_sm, threshold_hm)
return output

}

###################################################################################
__________________
Le Sagittaire
--------------------
Inutile de discuter avec moi ... j'ai toujours raison ... en tous cas j'en suis convaincu et c'est le principal ...
Reply With Quote
  #32  
05-16-2003, 06:00 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
Welcome Sagittaire
We've been playing and modifying your script

-kwag
Reply With Quote
  #33  
05-16-2003, 06:07 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
btw: can you run AviSynth2.0x and AviSynth2.5x at the same time?
Hi Jellygoose,

The script will work only on AviSynth 2.5x, because the heart of the script is the "Conditionalfilter" function
It won't be long before we convert this to a linear strength filter instead of three filter bracket ranges (Low, Medium, High), and integrate the new algorithm into MovieStacker ( Hello muaddib )

-kwag
Reply With Quote
  #34  
05-16-2003, 06:15 PM
ovg64 ovg64 is offline
Free Member
 
Join Date: Jan 2003
Location: Puerto Rico
Posts: 423
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to ovg64
OK Sagittaire is this going to work with our KVCDs, cause that looks like a Divx site and is like in frensh language I don't understand frensh
Reply With Quote
  #35  
05-16-2003, 06:22 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
Hi ovg64,

Check page 2 of this thread. It's been translated to english.

-kwag
Reply With Quote
  #36  
05-16-2003, 07:40 PM
muaddib muaddib is offline
Free Member
 
Join Date: Jun 2002
Location: São Paulo - Brasil
Posts: 879
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by kwag
I just noticed that I can't use this script with ToK
The current version of ToK sets the file prediction at the end of the script, and it doesn't work
I also tried to move it to the top, after the "clip = Mpeg2source( Source )" line, and it doesn't work either
I believe that Sampler.dll has been compiled for avisynth 2.5x
I guess in order to use this method, we must use manual file size prediction until we can get a fix for using this with ToK

-kwag
Hey kwag,

Did you try to move ALL functions to the top of the script?
I did not try the script yet, but it "should" work...
Reply With Quote
  #37  
05-16-2003, 07:52 PM
muaddib muaddib is offline
Free Member
 
Join Date: Jun 2002
Location: São Paulo - Brasil
Posts: 879
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by kwag
The script will work only on AviSynth 2.5x, because the heart of the script is the "Conditionalfilter" function
It won't be long before we convert this to a linear strength filter instead of three filter bracket ranges (Low, Medium, High), and integrate the new algorithm into MovieStacker ( Hello muaddib )
Hi K man! We will sure do that!
I didn't have time to put my hands in this great script (thanks Sagittaire), but don't stop... It's getting exciting!
Reply With Quote
  #38  
05-16-2003, 08:41 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
You know, this thread reminds me something I exposed several months ago, read here: http://www.kvcd.net/forum/viewtopic.php?t=2834
And instead of using a long script to do all of this, if one of SansGrip's filters could be modified ( NoMoSmooth ) to include "attached" avisynth functions like mergechroma, mergeluma, etc, then we could use the temporal motion engine built-in this filter
This way, it would work just like any other avisynth filters. For example, BlockBuster has tresholds to apply noise, depending on the darkness of the picture. NoMo applies filtering, depending on difference between adjacent frames. So this engine can be applied to "call" mergeluma or other filters, depending on selected activity "trigger" points.
SansGrip, where are you
The result: "Automatic Linear Motion Adaptive Filtering"
And that is what we need

-kwag
Reply With Quote
  #39  
05-17-2003, 12:12 AM
sbin sbin is offline
Free Member
 
Join Date: May 2003
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Greetings all. I haven't had much time to play with this today, because I had to do some work at my paying job. But hopefully I can spend some quality time with this now that the weekend is here.

Quote:
btw: can you run AviSynth2.0x and AviSynth2.5x at the same time?
You can, but there's not much need to since loadpluginex.dll will allow you to run 2.0 filters in 2.5x.

But if you want to run both versions, you can make 2 virtualdub folders and put the different avisynth.dll versions in each folder. Then just start whichever Virtualdub version you want to use. Not sure how that works with frameserving directly to TMPGEnc, though.... never tried it.
Reply With Quote
  #40  
05-17-2003, 01:14 AM
jorel jorel is offline
Invalid Email / Banned / Spammer
 
Join Date: Aug 2002
Location: Brasil - MG - third stone from the sun
Posts: 5,570
Thanks: 0
Thanked 0 Times in 0 Posts

Sagittaire
welcome!

great pages and great job.
the result will be amazing

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 01:43 PM  —  vBulletin © Jelsoft Enterprises Ltd