PDA

View Full Version : Avisynth WriteFileStart function need help !


Dark-Cracker
14th April 2004, 14:40
hi,

i have waste a few hour to try to change and old avisynth script using the chr.dll (needed to the write function) with the latest avisynth function writefilestart.

here is my old script :

--------------
LoadPlugin("E:\SAUVEG~1\Project\AutoIVTC\bin\script\MPEG2D~1.DLL")
LoadPlugin("E:\SAUVEG~1\Project\AutoIVTC\bin\script\decomb.dll")
LoadPlugin("E:\SAUVEG~1\Project\AutoIVTC\bin\script\chr.dll")

file="E:\SAUVEG~1\Project\AutoIVTC\interlace.log"
percentmovie=10

sep="."
combedthreshold=25

#---
function IsMoving() {return (diff < 1.0) ? false : true}
function GetPercent(clip x, float percent) {return SelectRangeEvery(x, floor(16./(percent/100.)), 16)}
#---

a = mpeg2source("E:\SAUVEG~1\Project\AutoIVTC\50mb.d2v")
c = GetPercent(a,percentmovie)

global clip = c

c = FrameEvaluate(c,"Write(file,string(IsCombed(combedthreshold)) + sep + string(IsMoving()),append=true)")
c = FrameEvaluate(c,"global diff = 0.50*YDifferenceFromPrevious(clip) + 0.25*UDifferenceFromPrevious(clip) + 0.25*VDifferenceFromPrevious(clip)")

return c
------------------

i have try to change it using the function "writefile" but without success, i have change the "write" function with "writefilestart" this generate me a file but it don't like my separator, apparently it doesn't understand the result (a boolean) is a string and not a funcion (because it the separator is a dot ".")

=> Script error: there is no function named "false"

i have change the separator but without success, it doesn't take the space separator, and if a add some character to separate the 2 boolean it return me :

=> I don't know what "isfalse" means

can someone could help me to correct it ?

thx :)
++

Wilbert
14th April 2004, 15:18
First, initiate the variable diff at the start.

c = FrameEvaluate(c,"WriteFile(file,string(IsCombed(combedthreshold)) + sep + string(IsMoving())")

AFAIU (and I don't :)), you don't need FrameEvaluate in that line. Does the following work:

c = WriteFile(c, file, string(IsCombed(combedthreshold)) + sep + string(IsMoving()))

Dark-Cracker
14th April 2004, 17:34
hi,

ok i have add diff=0 at the start of my script to init the global value. but it seems to me this global var was declared during the frameevalute so i am not sure my initialisation was correct.


i have tested with your exemple but it doesn't work :(
it say me the param for iscombed is not valid ???

Wilbert
14th April 2004, 18:05
ok i have add diff=0 at the start of my script to init the global value. but it seems to me this global var was declared during the frameevalute so i am not sure my initialisation was correct.

I guess you are right, it shouldn't be necessary.

You also have to make percentmovie, sep and combedthreshold global. But I'm not behind my own pc, so I can't check anything :)

ile="E:\SAUVEG~1\Project\AutoIVTC\interlace.log"

global percentmovie=10

global sep="."
global combedthreshold=25

#---
function IsMoving() {return (diff < 1.0) ? false : true}
function GetPercent(clip x, float percent) {return SelectRangeEvery(x, floor(16./(percent/100.)), 16)}
#---

a = mpeg2source("E:\SAUVEG~1\Project\AutoIVTC\50mb.d2v")
c = GetPercent(a,percentmovie)

global clip = c

c = WriteFile(c, file, string(IsCombed(combedthreshold)) + sep + string(IsMoving()))
c = FrameEvaluate(c,"global diff = 0.50*YDifferenceFromPrevious(clip) + 0.25*UDifferenceFromPrevious(clip) + 0.25*VDifferenceFromPrevious(clip)")

return c

Dark-Cracker
14th April 2004, 20:40
rhooo what is the problem with this script :(

i have test your solution but it still say me the argument for iscombed is not correct.

so i have try to remove the iscombed() function and only keep the ismoving() function this time it have show me another error :)

diff undeclared, so i have added at the start of my script :

global diff=0

but now the result of the ismoving() function was wrong it was always at "false".

i have also try to see if :

string(ismoving()) + sep + string(ismoving())

can write a correct log file. but in the log file it show me this error :

Script error: expected function name following `.'

so the separator is interpreted as a function :( .


if someone have an idea, feel free to post it :)
++

Wilbert
14th April 2004, 21:53
I got something working:


function IsMoving()
{
global b = (diff < 1.0) ? false : true
}

function shit(clip c)
{
file = "F:\interlace.log"
global clip = c

#c = WriteFile(c, file, "b")
c = WriteFile(c, file, "diff")
c = FrameEvaluate(c, "IsMoving")
c = FrameEvaluate(c,"global diff = 0.50*YDifferenceFromPrevious(clip) + 0.25*UDifferenceFromPrevious(clip) + 0.25*VDifferenceFromPrevious(clip)")

return c
}

v = mpeg2source("F:\From_hell\from_hell.d2v").trim(100,124)
shit(v)


If you change the two lines in the following ways:

c = WriteFile(c, file, "b")
#c = WriteFile(c, file, "diff")

it will write the truths/falses to the text-file.

Sorry, I don't have time to test further :) I hope it's a good start!

Dark-Cracker
14th April 2004, 23:59
thank u for your help.
i still can't get the isCombed() result correctely written in the file.

i give up writefile function is too boring to use i will keep the old chr.dll dependency for an easy and working function :)

in any case thank u for your help.

Wilbert
15th April 2004, 00:30
Is this better?


global sep="."
global combedthreshold=25

function IsMoving()
{
global b = (diff < 1.0) ? false : true
}

function shit(clip c)
{
file = "F:\interlace.log"
global clip = c

c = WriteFile(c, file, "a", "sep", "b")
c = FrameEvaluate(c, "global a = IsCombed(clip,combedthreshold)")
c = FrameEvaluate(c, "IsMoving")
c = FrameEvaluate(c,"global diff = 0.50*YDifferenceFromPrevious(clip) + 0.25*UDifferenceFromPrevious(clip) + 0.25*VDifferenceFromPrevious(clip)")

return c
}

v = mpeg2source("F:\From_hell\from_hell.d2v").trim(100,124)
shit(v)

Dark-Cracker
15th April 2004, 02:54
yep thank u this work like a charm :) thank u very much for spend a bit of your time on my problem :)

Bye.