PDA

View Full Version : Avisynth Script to determine filter results Vs Original Source


techmule
18th August 2005, 15:51
Hi,

I always wanted a way with avisynth, so as to determine what my video results would be without going through the long encoding process and vola!!!! after hours of reading heres how to go about it. I have used avisynth 2.5.

- Copy a small part of your avi from your source using vdubmod as your sample clip.
-Change your sample clip directory for Avisource() function
- load the plugins used (see my script below)
#
# Script begins here... #
#########################
#
# Loading plugins and functions... #
####################################
#
LoadPlugin("d:\Program Files\avisynth plugins\AutoCrop.dll")
LoadPlugin("d:\Program Files\avisynth plugins\avsmon25a.dll")
LoadPlugin("d:\Program Files\avisynth plugins\blockbuster.dll")
LoadPlugin("d:\Program Files\avisynth plugins\Convolution3DYV12.dll")
LoadPlugin("d:\Program Files\avisynth plugins\DctFilter.dll")
LoadPlugin("d:\Program Files\avisynth plugins\descratch.dll")
LoadPlugin("d:\Program Files\avisynth plugins\ffavisynth.dll")
LoadPlugin("d:\Program Files\avisynth plugins\FrameDbl.dll")
LoadPlugin("d:\Program Files\avisynth plugins\MipSmooth.dll")
LoadPlugin("d:\Program Files\avisynth plugins\MPEG2Dec3.dll")
LoadPlugin("d:\Program Files\avisynth plugins\RemoveDirtSSE2.dll")
LoadPlugin("d:\Program Files\avisynth plugins\RemoveGrainSSE2.dll")
LoadPlugin("d:\Program Files\avisynth plugins\Sampler.dll")
LoadPlugin("d:\Program Files\avisynth plugins\STMedianFilter.dll")
LoadPlugin("d:\Program Files\avisynth plugins\UnDot.dll")
LoadPlugin("d:\Program Files\avisynth plugins\UnFilter.dll")
LoadPlugin("d:\Program Files\avisynth plugins\VSFilter.dll")


#Filters Go below
#########################
Avisource("D:\big\test.avi",false)
blindPP(quant=2,cpu=4)
Blockbuster(method="noise",detail_min=1,detail_max=3,variance=0.3,seed=1)
removegrain(mode=1)
#descratch(mindif=60)
mipsmooth(preset="MovieHQ")
filtered= last

# If source video starts at different frame
frameadjust=0

# Videos to compare: (v1 is original, v2 is the re-encoded(after applying filter))
v1 = Avisource("D:\big\test.avi",false).trim(frameadjust,0)
v2 = filtered
sub = v1.subtract(v2)
substrong = sub.levels(122,1,132,0,255)

return StackVertical(StackHorizontal(v1.subtitle("original"),v2.subtitle("encoded")),StackHorizontal(sub.subtitle("Difference"),substrong.subtitle("Difference amplified")))

### End of Script

Save the script as name.avs and run this using your media player (I used WMP). Now you can see the effects of the filters as scripted by you Vs Source and change dynamically till it meets your expectations.

I also want to thank all avisynth forums and ppl who posted their scripts in them. Since I am very new to avisynth (5-10 days), those scripts have helped me to understand the functions better and helped me in creating this script to my needs.

Prodater64
18th August 2005, 16:59
Here another by Dialhot from kvcd.net:

source=Mpeg2Source(...)

left=source.script1()
right=source.script2()

width=left.width()/2
height=left.height()

left=crop(left,0,0,width,height)
right=crop(right,width,0,width,height)

StackHorizontal(left.subtitle("Script1"),right.subtitle("Script2"))

function script1(clip c) {
c
#----- ENTER CODE OF SCRIPT ONE HERE -----

#----- END OF CODE OF SCRIPT ONE-----
}

function script2(clip c) {
c
#----- ENTER CODE OF SCRIPT TWO HERE -----
Greyscale()
#----- END OF CODE OF SCRIPT TWO-----
}

tedkunich
18th August 2005, 19:08
Hi,

I always wanted a way with avisynth, so as to determine what my video results would be without going through the long encoding process and vola!!!! after hours of reading heres how to go about it. I have used avisynth 2.5.

<snip>




For my money, interleaving the original and filtered videos is the most accurate way to compare. You can single step through the frames and see the differences quite readily. Stacking (horizontal or vertical) will work too, but it is hard to see subtle changes that way....


T

mg262
18th August 2005, 22:32
I would add a proviso to all of this... there are different kind of noise and different kinds of distortion caused by filters, and the appropriate method to bring these out varies with the kind of phenomenon in question. I would say that whatever else you try you should use a least one method which involves playing the clip. (E.g. because strong spatial filters might yield frames which individually looked very good but which do not match the neighbouring frames closely enough to give a fluid result.)


I generally use two playback methods: one method which applies a filter to the right-hand side only (similar to the method in the second post), and one method which switches the filtering on and off every few seconds. I would personally avoid simple stacking methods because the requisite subsequent resizing will make it hard to notice a lot of phenomena. Subtract is useful in learning where distortion might occur so that you can look for it in the filtered clip, but once you have an idea of that I would switch it off, if no other reason than because you can't look at the subtract clip and the original/filtered clips at the same time.

askol
19th August 2005, 02:21
AMVApp (http://www.animemusicvideos.org/guides/avtech/amvapp.html) has a few nice scripts in it called BeforeAfter and BeforeAfterLine.

An example of BeforeAfter can be seen here: http://www.amvwiki.org/index.php/Image:Trythil_greenwood_edgeenhan.png

And hey, here are the scripts:

http://www.amvwiki.org/index.php/BeforeAfter
http://www.amvwiki.org/index.php/BeforeAfterLine

adrianmak
19th April 2006, 09:56
what is the difference between BeforeAfter and BerforeAfterLine script ?

foxyshadis
19th April 2006, 13:47
BeforeAfterLine adds a thin line between them. (That's a heckuva lot more robust than my sxs!)

Soulhunter
19th April 2006, 15:14
I made a similar function (http://mf.creations.nl/avs/functions/soulhunter/SSC.avs) some time ago... ^^


Bye

adrianmak
20th April 2006, 04:58
I tried all the above methods, basically all of them are splitting the original source into half, one half keep untouch and another half is applied filter(s) and then combine them back as one . However, the filtered half and unfilter half are two different portion of same scene and it is a little bit hard to compare the different how good or how bad of the filtered portion.

So is it possible to put unfilter and filtered portion as one
e.g.
all previous method
Scene was divided into two parts, A and B
A|B ---> A|B(filtered)

new method should be
A|B -----> A|A(filtered) or B|B(filtered)

Hope yours unstand my question

Soulhunter
20th April 2006, 10:27
Like this?
# _______________________________________________________
#
# SBSC | Side By Side Compare
# _______________________________________________________
#
# Another lame function by Soulhunter... \m\ ^_^ /m/
# _______________________________________________________
#
#
# Usage examples:
#
# Original = AviSource("C:\Path\to\Source.avi")
# Filtered = Original.FFT3DFilter(Sigma=1)
# SBSC(Original,Filtered)
#

Function SBSC(Clip ClipA,Clip ClipB)
{

OX = ClipA.Width
OY = ClipA.Height

ClipB = ClipB.Lanczosresize(OX,OY)

ClipA = ClipA.Crop(0,0,OX/2,OY).Subtitle("ClipA")
ClipB = ClipB.Crop(0,0,OX/2,OY).Subtitle("ClipB")

StackHorizontal(ClipA,ClipB)

}

Bye

Inc
20th April 2006, 10:47
As you already add a Lanczosresize on the filtered so it matches the same pic size of the source .... think about this:
Function SBSC_Interleaved(Clip orig,Clip filtered)
{

OX = ClipA.Width
OY = ClipA.Height

ClipB = ClipB.Lanczosresize(OX,OY)

ClipA = ClipA.Subtitle("Clip Orig")
ClipB = ClipB.Subtitle("Clip Filtered")

Interleave(ClipA,ClipB)

}

So you can just use the frame step button in Vdub etc. to switch between the orig/filtered. Its like in Photoshop "layer on/off".
When switching between layers diffs will be more recognisable for human eyes compared to a horizontal stacked pic alignment.

Alain2
20th April 2006, 23:25
maybe my ClipComp (http://forum.doom9.org/showthread.php?t=102286) script could help you ? (with default settings, look frame by frame in vdubmod for instance)