PDA

View Full Version : Import execution at start and end


DDogg
1st April 2003, 23:19
It was suggested to start a thread here (At least I think it was).

Request:
Execution of Import command at specified frame number OR trigger at before start and after end of video event. Plenty of background in my last post in CALL command. Object is to use IMPORT in concert with CALL command.

Question: Is there a possibility of extended CALL function being included in core with extended syntax to allow stacked execution of external and internal commands before and after video event?

sh0dan
2nd April 2003, 09:42
As per your request, I cannot see it being done in any way, without a major rewrite of AviSynth. Imports must be done at script parse time - no way around that. The only way to do this is for the client application to open the script, and reopen it after the specified frame has been delivered.

What would you be using this for anyway?

Belgabor
2nd April 2003, 10:04
Iirc call executes an external program, why not add functions/commands? This way you'd just have to wrap whatever your imported script does into a function and give that to call.

Bidoche
2nd April 2003, 10:30
But Call is executed at parse-time, no ?

bilu
2nd April 2003, 11:21
It seems to me that CALL marks itself as part of the graph to be executed at a certain frame, much like a trimmed source.

But CALL executes external functions and you can import their output later. We could have an adapted Import function that could trigger at a certain frame, like

Import("c:\file.avs", 2000)

that would behave like (sorry for the syntax, i'm @work now)

vid1=avisource("file.avi").trim(0,1999)
vid2=avisource("file.avi").trim(2000,0).Blur(1.5)
vid=vid1+vid2

return vid


Bilu

Bidoche
2nd April 2003, 11:31
...
If you can do it with a script, why a delayed Import ?

bilu
2nd April 2003, 12:16
No reason at all. :rolleyes:

Currently the only way to use the output of a CALL command is like this:


LoadPlugin("call.dll")
Call(BlankClip, "lame --decode fatboy.mp3 fatboy.wav", "-2")
WavSource("fatboy.wav")

OR

Autocrop(mode=2,wMultOf=16,hMultOf=16,threshold=40)
Call("cmd /c copy D:\autocrop.log D:\crop.avs","-2")
import("D:\avs_filters\avs25\tests\analyse\crop.avs")


"-2" will make CALL execute before encoding, and that is the only way to use external values in Avisynth currently.

Until 3.0 (at least) it seems we can't expect any kind of "triggers".


Best regards,
Bilu

Bidoche
2nd April 2003, 12:54
And unless you explain exactly what you want and why it is needed, there won't be anything either in 3.0.


Besides this "-2" is particularly cryptic, I think I will add a 6th parameter type in 3.0, namely 'symbolic', in order to have something more readable (The parser/linker will take of converting symbols to ints)

bilu
2nd April 2003, 14:21
@Bidoche

Using per frame conditional filtering: here (http://forum.doom9.org/showthread.php?s=&threadid=50105) and here. (http://forum.doom9.org/showthread.php?s=&threadid=50104 )

Also check WHILE function in Avisynth (http://forum.doom9.org/showthread.php?s=&threadid=48127) and Sh0dan's feature request (http://sourceforge.net/tracker/index.php?func=detail&aid=611945&group_id=57023&atid=482676)


Best regards,
Bilu

Bidoche
2nd April 2003, 15:33
flow control is already considered for 3.0, and I don't see the connection here.
We were talking about CALL.

bilu
2nd April 2003, 15:43
Originally posted by DDogg
It was suggested to start a thread here (At least I think it was).

Request:
Execution of Import command at specified frame number OR trigger at before start and after end of video event. Plenty of background in my last post in CALL command. Object is to use IMPORT in concert with CALL command.

Question: Is there a possibility of extended CALL function being included in core with extended syntax to allow stacked execution of external and internal commands before and after video event?

I think Ddogg's request is flow control. CALL would become some sort of work around until 3.0 . I may be wrong on my interpretation :rolleyes:

I didn't understand his question though... :confused:

Bilu

Bidoche
2nd April 2003, 15:48
I agree with you, the point is I don't understand what he really wants.

DDogg
2nd April 2003, 16:00
@Sh0dan, first, I sense I have been an irritant to you. Please allow me to start fresh. I'll try to make my chaotic thinking style more precise in the future.What would you be using this for anyway?Please work with me and read my last post in CALL command for the not very elegant workarounds I am trying to use. Please also see about six posts above the last (March 27) for report example showing events can be made to happen before Frame 0 and after EOF with CALL.

Task (just an example):
1> Pre frame 0 - output to disk file report.txt StartTime="xx.xx.xx"
2> After EOF - append to report.txt EndTime="xx.xx.xx"
Above is now possible using CALL and NicEcho.exe
3> At EOF Import report.txt, get variables into avisynth, compute ElapsedTime, append to report.txt ElapsedTime = "xx.xx.xx".

This is what my last post in the call command thread addresses. Nic hinted the "invoke" command might allow him to execute an internal avisyth command like Import from within CALL.

Q:Dunno, what does devel think? I could never get any feedback from you guys (maybe 'cause I was too pushy, sorry).

Frankly I don't think I/we see all the new possibilities this would allow, but eventually, my hope is to be able to /edit at pre during or post frame event/edit import an external AVS or CALL an external standalone program, separately or in concert, for pre-processing/compression analysis/various calculations/multiple test iterations, reportage, etc.

Q:This strikes me as a worthy goal, what do you guys think?
I think Ddogg's request is flow control. CALL would become some sort of work around until 3.0 Yes, an expanded CALL command incorporated in 2.5 core or as plugin that allowed multiple external and internal commands to be executed in sequence while WITHIN the call event would allow much additional flexibility. Call allows execution at before, during and after frame events (just my wording). This is what I am looking for.

Q:I just don't know if it would ever be possible for CALL to execute an internal avisynth command. Until I do know, my thinking will always be less than clear.

sh0dan
2nd April 2003, 16:16
This should really be the job of the client IMO.

You can already print out the start and end times - couldn't Call just have an append feature, so all times will be written?

DDogg
2nd April 2003, 16:32
<sigh> lol, I give up! :) There were some questions above.

/edit The point is to be able to get the variables that reside in an external file back into Avisynth at a given time so that they can be operated upon and further actions be triggered (like with the call command).

bilu
2nd April 2003, 16:54
@Ddogg

Don't give up and leave me alone... please! :D

I think I've understood what you meant here. (http://forum.doom9.org/showthread.php?s=&threadid=46506&postid=286279) :)

You want to execute multiple commands inside CALL, to

1)output end time;
2)import start time;
3)calculate elapsed time;
4)output elapsed time;

The problem seems to be using the end time output of CALL command.Even if CALL were used just before the last frame (not too much inaccuracy and still within the graph, so we could make the elapsed time calculation) you couldn't use the end time output EVEN if it could be directly passed to an internal variable.

Even if you did:

vid1=avisource("file.avi").trim(0, lastframe -1).Call(whatever,lastframe-1)
vid2=avisource("file.avi").trim(lastframe -1,0).elapsedtime().Call(elapsed_report,-2)

vid=vid1+vid2

return vid


being elapsedtime() your calculations, how could you import the end time value? And if the end time were passed to an internal variable at lastframe-1, would it work? (Sh0dan,Bidoche?)


Bilu

Bidoche
2nd April 2003, 17:00
Some precision :
Actually the parser vartable and the environnement vartable are the same. (Correct me if I am mistaken)

Personally I don't think it's normal, script variables should be lost at the end of the parsing.
So they will be independant in 3.0 (unless someone is very very convincing).
If you want to tune things with variables you can have filters play with the environment vartable.

bilu
2nd April 2003, 17:27
Originally posted by Bidoche
If you want to tune things with variables you can have filters play with the environment vartable.
OK, but that would mean that any calculation would need to be done inside a filter and not on the script, right?

Maybe the most flexible way (if Avisynth can render more than on script at a time) would be creating a new script with a blank clip to

- import start and end time
- make the calculations
- output elapsed time through CALL

After all, start and end times were rendered in the parent script already. :rolleyes:

But we would need to make CALL execute another Avisynth script. Is it possible? :confused:


Bilu

DDogg
2nd April 2003, 17:35
I'm going to give this my best shot but I hope this example does not cause confusion of the bigger grail of external pre-processing and analysis which requires Importation of results and then conditional action based upon an evaluation from within AviSynth. Hey, this is NOT about elapsed time, that is just an example.

1> Call gives us an envelope to do something before and after the video event (again just my wording. Probably poor).
2> The problem arises that Import is not a command that CALL can execute nor is there a way, to the best of my present knowledge, to cause Import to execute dependably in sequence (directly after) the Call event.

Presently we can:
Call event (-2 trigger) (before video)
Write StartTime="xx.xx.xx" to external disk file
Call event (-1 trigger) (after last frame - EOF)
Append EndTime="xx.xx.xx" to external disk file

So now we have a report.txt that contains:
StartTime="xx.xx.xx"
EndTime="xx.xx.xx"

What I hope for:
Call event (-2 trigger) (before video)
Write StartTime="xx.xx.xx" to external disk file
Call event (-1 trigger) (after last frame - EOF)
#Multiple actions executed in sequence
Append EndTime="xx.xx.xx" to report.txt
Import report.txt
ElapsedTime=Math operations on variables StartTime and EndTime
append ElapsedTime="xx.xx.xx" to report.txt

Earnest Request: Bidoche, Sh0dan, could you look at Nic's code and/or at least his concept and state whether you think it is possible or impossible for CALL to execute an internal command? This is probably the answer I should have waited for before even attempting this discussion. If the answer is impossible, then it may well be that this whole discussion is moot.

/edit I asked about import at specified frame number because if Call can not do an internal command then an Import at specified frame or SOF/EOF would (I think) do a lot of the computation and automatically set variable when imported as the imported script executes as part of being imported.

bilu
2nd April 2003, 17:55
Originally posted by DDogg
I asked about import at specified frame number because if Call can not do an internal command then an Import at specified frame or SOF/EOF would (I think) do a lot of the computation and automatically set variable when imported as the imported script executes as part of being imported.

I think the imported script becomes part of the original script when the filter graph is rendered, just at the beginning.

Bilu

bilu
2nd April 2003, 18:07
@Ddogg

There is hope in the world ;) Look at this thread (http://forum.doom9.org/showthread.php?s=&postid=288755#post288755)

Bilu

Bidoche
2nd April 2003, 18:08
ElapsedTime=Math operations on variables StartTime and EndTime Do you really need the avisynth parser for that ?

DDogg
2nd April 2003, 18:11
As per your request, I cannot see it being done in any way, without a major rewrite of AviSynth. Imports must be done at script parse time - no way around that. The only way to do this is for the client application to open the script, and reopen it after the specified frame has been delivered. Sh0dan, can you expand this a little please? I don't understand if this was an answer to my heading "request" or to "question". Since I am not a coder I have some difficulty understanding what you are saying many times.

DDogg
2nd April 2003, 18:19
Do you really need the avisynth parser for that ?Sorry, dunno. My head is swimming at this stage and I don't comprehend what you mean. Damn! I wish I was a coder and understood the internal workings of Avisynth better. This is so frustrating and painful for me to "get it". I worry I am distracting you guys, but hope something positive comes from this.

Bidoche
2nd April 2003, 18:31
@DDogg

bilu uses the avisynth parser to calculate end - start.

DDogg
2nd April 2003, 19:47
Well I have tried my best to present my thoughts as clearly as I know how and ask clear questions.

I'll kick back and hope for answers to my specific few questions and one "earnest request"@Bidoche mentioned above.

Bilu seems to understand what I'm trying to do so maybe he can further the discussion if it has merit.

bilu
2nd April 2003, 20:53
Originally posted by bilu

OK, but that would mean that any calculation would need to be done inside a filter and not on the script, right?

Maybe the most flexible way (if Avisynth can render more than on script at a time) would be creating a new script with a blank clip to

- import start and end time
- make the calculations
- output elapsed time through CALL

After all, start and end times were rendered in the parent script already. :rolleyes:

But we would need to make CALL execute another Avisynth script. Is it possible? :confused:


Originally posted by Bidoche
bilu uses the avisynth parser to calculate end - start.



I never said I did, because I need a way to execute an Avisynth script to at least try. :sly:

But I will try with AVS2AVI with XVID with the NULL preset, if it is possible to

- do more than one XVID encode at a time

- dump file of codec configuration used in AVS2AVI can actually keep more than just the codec selection: I would need the preset also. I think it can because it can keep the setting for both passes in the dumpfile and use the first then the second.

It should be more easy to do a NULL encode ;)
I'll try it in a few hours.


Best regards,
Bilu

DDogg
2nd April 2003, 21:59
Before this gets buried in BS:

Earnest Request: Bidoche, Sh0dan, could you look at Nic's code and/or at least his concept and state whether you think it is possible or impossible for CALL to execute an internal command? This is probably the answer I should have waited for before even attempting this discussion. If the answer is impossible, then it may well be that this whole discussion is moot.

sh0dan
2nd April 2003, 22:34
@all: What you're wanting is perfectly possible - if you:

a) Write a specific filter.
or
b) Change the client app to do this.

This is hundred times easier than rewriting avisynth.

@Bidoche:
>Actually the parser vartable and the environnement vartable are the same. (Correct me if I am mistaken)
Correct.

Personally I don't think it's normal, script variables should be lost at the end of the parsing.
They are not! :)

@bilu:
>Earnest Request: Bidoche, Sh0dan, could you look at Nic's code and/or at least his concept and state whether you think it is possible or impossible for CALL to execute an internal command? This is probably the answer I should have waited for before even attempting this discussion. If the answer is impossible, then it may well be that this whole discussion is moot.

Use env->Invoke() to call any internal command.

bilu
2nd April 2003, 22:50
@sh0dan

I'm not a programmer, sorry. And that's Ddogg's words. :D

A question: Invoke() works like Import() ?
I mean, when you load a filter from Invoke() can you unload it? Or it's permanent in the graph like with Import()?

This seems like going back to the WHILE thread (http://forum.doom9.org/showthread.php?s=&threadid=48127) again :D

Bilu

sh0dan
2nd April 2003, 22:53
Invoke makes it possible to execute a function inside any filter at any time. The created filter is not part of the graph itself, but maintained by the filter that called it.

bilu
2nd April 2003, 23:03
COOL... :D :D :D

How about a filter that takes as parameter a text file with description of filters and conditions?

And if it could also use CALL and look for variables inside other text files when asked to it would be gold :)

Example: CondFilter("c:\file.txt")

file.txt
========
conditionalfilter(last,last,last.trim(1,0),"YDifferenceToNext()",">","10", show=true)
CALL("c:\cmdfile.bat",40")
ImportVar("c:\file.var",41)?Subtitle(subtext):last

cmdfile.bat
===========
echo subtext="that's all folks!!!" > c:\file.var

I'm also adding another concept in ImportVar: to have a successful import boolean flag so we can use functions depending on that import.

Talking about Invoke... a good example is also MonitorFilter (correct me if I'm wrong) when adjusting the audio delay.

Best regards,
Bilu

DDogg
2nd April 2003, 23:38
Sh0dan, thanks very much for your reply.

bilu
2nd April 2003, 23:56
@sh0dan

Internal variables are kept after the script is parsed, but can they be modified at any time on the environment vartable, as Bidoche said?

Best regards,
Bilu

bilu
3rd April 2003, 10:24
Originally posted by sh0dan
Invoke makes it possible to execute a function inside any filter at any time. The created filter is not part of the graph itself, but maintained by the filter that called it.

I need to make this stupid question: why not passing the entire script through Invoke() and make Avisynth the only filter in the graph?

If it were possible it would solve all limitations on triggering with internal and external variables, WHILE loops and most of the stuff that I and Ddogg have been talking about on this thread and others.


Best regards,
Bilu

DDogg
3rd April 2003, 16:29
Invoke makes it possible to execute a function inside any filter at any time. The created filter is not part of the graph itself, but maintained by the filter that called it.

Sh0dan, I imagine you are getting a little tired of this thread and thanks for your patience :) I would like to ask a specific question:

1> From your reading of the internal structure of Avisynth, plugins and Nic's CALL code, can you tell:

If it is possible for "The created filter" (your words) to do multiple tasks in a sequence while the filter is in an "active" state? In other words could a plugin activate an external program like Command.com to do a task, and then INVOKE an internal command like IMPORT (and maybe others) before going "inactive" (my poor choice of words).

It is hard for me to ask a coherent question of you as I don't know all the proper technical words. Hopefully I got my question across clearly enough for you to make sense of it.

sh0dan
4th April 2003, 09:08
If it is possible for "The created filter" (your words) to do multiple tasks in a sequence while the filter is in an "active" state? In other words could a plugin activate an external program like Command.com to do a task, and then INVOKE an internal command like IMPORT (and maybe others) before going "inactive" (my poor choice of words).

It depends on what you want the "import" filter to do.

- If you want to set internal variables - yes - that's perfectly possible.

- If you want to infuence the filter chain (adding/removing filters) - partially. You can add filters at the current point in the filter chain, by using Invoke.

- If you want to disable or enable filters, by variable values read by the import, you can do this by using conditionalfilter.

- We are working on a generic way to invoke (parts of) scripts on a per frame basis - don't know if this helps you.

bilu
4th April 2003, 09:46
Originally posted by sh0dan
We are working on a generic way to invoke (parts of) scripts on a per frame basis - don't know if this helps you.

That's very nice to know. I'm curious if it can unload these parts of scripts on a per frame basis too, and load external values through Import() or something similar.


Is there any public information on new developments like this one on SourceForge? I've searched but haven't found, and I've also followed the links on your signature. Sometimes user requests like this one could get more objective if we would know what you guys are working on. :)

But then again you may just want peace to develop and create solid concepts without little or no context-wise user interference, which is pretty understandable :rolleyes:

It's a pity i'm no coder. :scared:


[EDIT 2]
I found Sh0dan's post pretty self-explanatory:

http://forum.doom9.org/showthread.php?s=&postid=289875#post289875

[/EDIT 2]


Bilu

DDogg
4th April 2003, 16:52
Your answer very much helped and I really appreciate you taking the time to reply.