Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 30th June 2014, 14:27   #21  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
As linked in #post 16 by Gavino
Quote:
Originally Posted by Gavino View Post
Yes, the string table does accumulate entries for each frame rendered by a run-time filter.
I can think of a number of ways this could be improved/fixed, including changes to ScriptClip itself, but normally there is a simple workaround - use functions to cut down the size of the run-time script. Taking this approach to its limit, you can even replace the entire run-time script by a function call. Instead of writing
Code:
ScriptClip("""
  ... # very long script
""")
do this
Code:
function f(clip c, int current_frame) {
  c
  ... # code from run-time script
}
...
ScriptClip("f(current_frame)")
See here for an example which fixed a previously mysterious memory leak in SRestore.
(BTW The current_frame parameter is not needed if using GRunT, since it makes current_frame global).

In your case, the recursive use of ScriptClip adds a further complication, but I think you could restructure your code to call ScriptClip once and do the recursion inside it. In fact, you said in post #4 that you were able to do this with your earlier code.
So would not need to be, it is Grunt that does the clever stuff there.
In your other thread I think I passed current_frame in at least one snippet that did not need an explicit current_frame (If Grunt is installed).
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 30th June 2014 at 14:46.
StainlessS is offline   Reply With Quote
Old 1st July 2014, 10:01   #22  |  Link
fvisagie
Registered User
 
Join Date: Aug 2008
Location: Isle of Man
Posts: 588
I was confusing GScript and GRunT, thanks!
fvisagie is offline   Reply With Quote
Old 1st July 2014, 17:44   #23  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Yep, I do that myself all of the time, perhaps a single plug called eg GruntScript() is called for.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???
StainlessS is offline   Reply With Quote
Old 6th July 2014, 15:33   #24  |  Link
fvisagie
Registered User
 
Join Date: Aug 2008
Location: Isle of Man
Posts: 588
Quote:
Originally Posted by Gavino View Post
As StainlessS says, the string argument to ScriptClip() is instantiated once only, when the outer script is parsed.

However, at run-time, that string is itself parsed afresh by ScriptClip() for every frame, each time using up space in Avisynth's string table for variable names, etc.
Somewhat naïve testing seems to indicate that this applies equally much to FrameEvaluate() as might be expected; does the theory agree?

scriptclip.avs
Code:
fps = 25.0
BlankClip(length=Int(3600*fps), fps=fps)
evens = 0
ScriptClip("""
    evens = current_frame / 2 * 2 == current_frame \
        ? evens + 1 \
        : evens
    last
""", show=false, after_frame=false)
scriptclip2.avs
Code:
fps = 25.0
BlankClip(length=2*Int(3600*fps), fps=fps)
evens = 0
ScriptClip("""
    evens = current_frame / 2 * 2 == current_frame \
        ? evens + 1 \
        : evens
    last
""", show=false, after_frame=false)
frameevaluate.avs
Code:
fps = 25.0
BlankClip(length=Int(3600*fps), fps=fps)
evens = 0
FrameEvaluate("""
    evens = current_frame / 2 * 2 == current_frame \
        ? evens + 1 \
        : evens
#   last
""", show=false, after_frame=false)
frameevaluate2.avs
Code:
fps = 25.0
BlankClip(length=2*Int(3600*fps), fps=fps)
evens = 0
FrameEvaluate("""
    evens = current_frame / 2 * 2 == current_frame \
        ? evens + 1 \
        : evens
#   last
""", show=false, after_frame=false)
Quote:
>avsmeter scriptclip.avs

AVSMeter 1.7.9 (AVS 2.6, x86) by Groucho2004
AviSynth 2.60, build:Jan 14 2013 [16:50:35]

Number of frames: 90000
Length (hhh:mm:ss.ms): 001:00:00.000
Frame width: 640
Frame height: 480
Framerate: 25.000 (25/1)
Colorspace: RGB32

Frames processed: 90000 (0 - 89999)
FPS (min | max | average): 66717 | 97485 | 91832
CPU usage (average): 23%
Thread count: 1
Physical Memory usage (peak): 15 MB
Virtual Memory usage (peak): 12 MB
Time (elapsed): 000:00:00.980

>avsmeter scriptclip2.avs

AVSMeter 1.7.9 (AVS 2.6, x86) by Groucho2004
AviSynth 2.60, build:Jan 14 2013 [16:50:35]

Number of frames: 180000
Length (hhh:mm:ss.ms): 002:00:00.000
Frame width: 640
Frame height: 480
Framerate: 25.000 (25/1)
Colorspace: RGB32

Frames processed: 180000 (0 - 179999)
FPS (min | max | average): 69540 | 97453 | 92068
CPU usage (average): 24%
Thread count: 1
Physical Memory usage (peak): 20 MB
Virtual Memory usage (peak): 18 MB
Time (elapsed): 000:00:01.955

>avsmeter frameevaluate.avs

AVSMeter 1.7.9 (AVS 2.6, x86) by Groucho2004
AviSynth 2.60, build:Jan 14 2013 [16:50:35]

Number of frames: 90000
Length (hhh:mm:ss.ms): 001:00:00.000
Frame width: 640
Frame height: 480
Framerate: 25.000 (25/1)
Colorspace: RGB32

Frames processed: 90000 (0 - 89999)
FPS (min | max | average): 94501 | 115677 | 110254
CPU usage (average): 22%
Thread count: 1
Physical Memory usage (peak): 14 MB
Virtual Memory usage (peak): 12 MB
Time (elapsed): 000:00:00.816

>avsmeter frameevaluate2.avs

AVSMeter 1.7.9 (AVS 2.6, x86) by Groucho2004
AviSynth 2.60, build:Jan 14 2013 [16:50:35]

Number of frames: 180000
Length (hhh:mm:ss.ms): 002:00:00.000
Frame width: 640
Frame height: 480
Framerate: 25.000 (25/1)
Colorspace: RGB32

Frames processed: 180000 (0 - 179999)
FPS (min | max | average): 96123 | 114681 | 110382
CPU usage (average): 23%
Thread count: 1
Physical Memory usage (peak): 19 MB
Virtual Memory usage (peak): 17 MB
Time (elapsed): 000:00:01.631
fvisagie is offline   Reply With Quote
Old 6th July 2014, 15:41   #25  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,431
Quote:
Originally Posted by fvisagie View Post
Somewhat naïve testing seems to indicate that this applies equally much to FrameEvaluate() as might be expected; does the theory agree?
Yes. All the run-time filters (ScriptClip(), FrameEvaluate(), ConditionalFilter(), WriteFile[If]()) basically work the same way as far as string parsing is concerned.
__________________
GScript and GRunT - complex Avisynth scripting made easier
Gavino is offline   Reply With Quote
Old 7th July 2014, 06:27   #26  |  Link
fvisagie
Registered User
 
Join Date: Aug 2008
Location: Isle of Man
Posts: 588
Thanks.
fvisagie is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:31.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.