digitalFAQ.com Forums [Archives]

digitalFAQ.com Forums [Archives] (http://www.digitalfaq.com/archives/)
-   Avisynth Scripting (http://www.digitalfaq.com/archives/avisynth/)
-   -   Avisynth: A simple way to compare two scripts (http://www.digitalfaq.com/archives/avisynth/13702-avisynth-simple-compare.html)

Dialhot 07-23-2005 09:39 AM

A simple way to compare two scripts
 
As I bother to user MovieStacker just for that, this is a little avs script aimed to compare the result of two other scripts.

Simply put the code of the scripts in the function script1 and function script2.
The example below compare the original source (script1 empty) and the result of the greyscale() command.

Note: you can resize or do whatever you want in the scripts but be carefull that both scripts must produce clips with same parameters (size, fps, colorspace)

Code:

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-----
}


incredible 07-23-2005 12:15 PM

Nice!

And here also a nice compare function if you dont want to se a side by side but a "switching"-like comparison:

Code:

source=Mpeg2Source(...)
Interleave(script1(source).subtitle("Script1",10,20),script2(source).subtitle("Script2",10,20))


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-----
}

Means: Do scroll to the Script1 frame you want to compare ... then step one frame forth. Now you see the Script2 version of the frame. Back n' Forth and Back'n forth gives you a nice comparing like in a "switching" way.

I do use this often when comparing encodings etc.

rds_correia 07-23-2005 02:34 PM

Uau! this one should become a sticky guys :D

Zyphon 07-27-2005 12:55 PM

Thanks guys for both methods this is a really useful script great work. :D

ginoboy 09-13-2005 08:37 AM

very good!

thanks guys!

Prodater64 10-23-2005 05:21 AM

I know what is greyscale, but for what is it useful in those scripts?

digitall.doc 10-23-2005 05:28 AM

Prodater,
I think it was just an example...
Between this lines
Code:

#----- ENTER CODE OF SCRIPT ONE HERE -----

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

you have to put the filters of scripts (1 and 2) you want to compare.

Inc and Dialhot compared no filter against greyscale() as an example.

danpos 10-23-2005 08:06 AM

Alternate (by mg262 from D9).
 
Alternate

More instructions on own link.

Cya!

Prodater64 10-23-2005 09:17 AM

Re: Alternate (by mg262 from D9).
 
Quote:

Originally Posted by danpos
Alternate

More instructions on own link.

Cya!

Thanks.

Prodater64 11-21-2005 04:55 PM

A simple but usefull add:

Code:

source=Mpeg2Source(...)

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

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

left=crop(left,0,0,width,height).addborders(0,0,2,0,$0000FF).crop(2,0,-0,-0)
right=crop(right,width,0,width,height).addborders(2,0,0,0,$0000FF).crop(0,0,-2,-0)

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-----
}

It adds a vertical blue (you can change the color) line separating both clips.
The script crop 2 pixels at right and left sides to compensate the addborder in the midle, but most times those sides are black overscan zones.

Dialhot 11-21-2005 05:14 PM

:ok:

Prodater64 11-21-2005 05:34 PM

Quote:

Originally Posted by Dialhot
:ok:

:D :D :D

Prodater64 11-26-2005 08:43 PM

Two more mods:

Compare left half of both scripts:

Code:

source=Mpeg2Source(...)

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

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

left=crop(left,0,0,width,height).addborders(0,0,2,0,$0000FF).crop(2,0,-0,-0)
right=crop(right,0,0,width,height).addborders(2,0,0,0,$0000FF).crop(0,0,-2,-0)

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-----
}

Compare right half of both scripts:

Code:

source=Mpeg2Source(...)

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

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

left=crop(left,width,0,width,height).addborders(0,0,2,0,$0000FF).crop(2,0,-0,-0)
right=crop(right,width,0,width,height).addborders(2,0,0,0,$0000FF).crop(0,0,-2,-0)

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-----
}

Does any body know how to do it (select one of three options L/R, L/L or R/R) with conditional switches (if mode == LR, if mode == LL, if mode == RR) in only one avs script.

http://www.digitalfaq.com/archives/i.../2005/11/4.jpg

http://www.digitalfaq.com/archives/error.gif

Fluffbutt 11-26-2005 09:13 PM

I've been playing, but I can't see a way.

Avisynth ConditionalFilter does not allow for a variable to be set
(psuedocode: set Type=left, then test Type for "left").

Is there a way to make an avisynth runtime function give a predefined result that won't change throughout the life of the script?

We may have to wait for 3.0

"..Improved parser: the parser will include the widely requested flow control structs (if then else, for, while). It will add two new types : frame and function..."

Prodater64 11-27-2005 01:03 AM

Quote:

Originally Posted by Fluffbutt
I've been playing, but I can't see a way.

I have it!!!

Code:

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

mode="LR" # "LR", "RR" or "LL"

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

source=Mpeg2source("")

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

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

left = (mode == "RR") ? crop(left,width,0,width,height).addborders(0,0,2,0,$0000FF).crop(2,0,-0,-0):crop(left,0,0,width,height).addborders(0,0,2,0,$0000FF).crop(2,0,-0,-0)
right = (mode == "LL") ? crop(right,0,0,width,height).addborders(2,0,0,0,$0000FF).crop(0,0,-2,-0):crop(right,width,0,width,height).addborders(2,0,0,0,$0000FF).crop(0,0,-2,-0)

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-----
}


Fluffbutt 11-30-2005 05:10 AM

Hahah, brilliant.. I tried to set a variable, but couldn't get it to react with the scripts.

I was trying a if..then...else type arrangement; yours is a masterpiece!

Prodater64 12-01-2005 05:26 AM

Quote:

Originally Posted by Fluffbutt
Hahah, brilliant.. I tried to set a variable, but couldn't get it to react with the scripts.

I was trying a if..then...else type arrangement; yours is a masterpiece!

Thanks.
It is, indeed, an if..then.
left = (mode == "RR") ? can be read as "if mode = "RR" then left = ...."
statement after "?" is the conditional statement.
statement after ":" is the "else" statement.

Fluffbutt 12-03-2005 04:12 AM

Quote:

Originally Posted by Prodater64
It is, indeed, an if..then.
left = (mode == "RR") ? can be read as "if mode = "RR" then left = ...."
statement after "?" is the conditional statement.
statement after ":" is the "else" statement.

Good grief! And programmers call that 'structure'? LOL! It seems wierd to me that = and == both mean 'equals' ("if mode = "RR" then left = ....").

Oh well.. Thanks again..

tengo6dedos 02-14-2009 03:42 PM

I do not know if someone will find it useful by now but I simply use:

Code:

DGDecode_Mpeg2Source(....)
a=last.
\      FFT3dfilter().
\      LanczosResize(x,y) 
#
#################
#
dfttest()
LanczosResize(x,y)
stackhorizontal(a,last)


top is for left screen n bottom if for right, *top filters must end with dot "." unless is the last one, same goes for the word "last"

saluts


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

Site design, images and content © 2002-2024 The Digital FAQ, www.digitalFAQ.com
Forum Software by vBulletin · Copyright © 2024 Jelsoft Enterprises Ltd.