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 28th August 2021, 01:24   #1  |  Link
konstantin1
Registered User
 
Join Date: Mar 2014
Posts: 38
Fow can I force ImageWriter to write the frames?

I have a quite complex, and memory consuming script, in which I read images, and put them various layers, eg. arrows, text, etc.

I found out, that my script use much less memory, if at a point I write out the layered images to PNG files, and then read them back into variables, and then the following commands, filters use those PNG images in the script.

A sample from my script:

Code:
blank=blackness(text,$00000000).trim(0,-1).loop(k0)
image1x1.trim(0,-1).ImageWriter("png\image1x1\", type="png")++k4x4.trim(0,-1).ImageWriter("png\k4x4\", type="png")++text.trim(0,-1).ImageWriter("png\text\", type="png")

image1x1r=imagesource("png/image1x1/000000.png",pixel_type="RGB32",FPS=FPS).trim(0,-1).loop(k0)
k4x4r=imagesource("png/k4x4/000000.png",pixel_type="RGB32",FPS=FPS).trim(0,-1).loop(k0)
textr=imagesource("png/text/000000.png",pixel_type="RGB32",FPS=FPS).trim(0,-1).loop(k0)
stack=output=="gif" ?  StackHorizontal(image1x1,k4x4,text,blank) : StackHorizontal(image1x1r,k4x4r,textr,blank)
The problem is that the images are written by ImageWriter only in that case, if ImageWriter is the last command (eg. inserting an __END__ ), and I visit, or let render every 3 frames, and then deleting the __END__ marker.

How can I force imagewriter to write those 3 frames as images?
konstantin1 is offline   Reply With Quote
Old 28th August 2021, 01:53   #2  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 11,018
Try insert RT_Stats, function RT_ForceProcess() on the blank line [EDIT #3].
It will force read every frame of Last clip [ie your Imagewriter stuff], and so force the images to be written.
Then the remainder of script will execute.

EDIT:You spell "How" with an 'H'

EDIT:
Below inserted where line 3 is should also work [I think, untested]

Code:
for(n=0,FrameCount-1) {
    current_frame = n
    AverageLuma  # force read of Last clip, frame n, will force writing to image.
}
EDIT:
OK, maybe it dont work, AverageLuma only for YUV, yours probably RGB, so try instead
Code:
for(n=0,FrameCount-1) {
    current_frame = n
    (Last.IsRGB) ? AverageR : AverageLuma   # force read of Last clip, frame n, will force writing to image.
}
Should work with either YUV or RGB Last clip [AverageR Requires AVS+]

EDIT: Or alternatively [Avs v2.58+]
Code:
ForceClip = Last.crop(4,4).ConvertToYV12()
for(n=0,FrameCount-1) {
    current_frame = n
    ForceClip.AverageLuma   # force read of Last clip, frame n, will force writing to image.
}
__________________
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; 28th August 2021 at 13:27.
StainlessS is offline   Reply With Quote
Old 29th August 2021, 13:44   #3  |  Link
konstantin1
Registered User
 
Join Date: Mar 2014
Posts: 38
Thank you very much, it really works!
I used second option, due to Avisynth+ 3.4
konstantin1 is offline   Reply With Quote
Old 29th August 2021, 14:44   #4  |  Link
kedautinh12
Registered User
 
Join Date: Jan 2018
Posts: 2,168
Quote:
Originally Posted by konstantin1 View Post
Thank you very much, it really works!
I used second option, due to Avisynth+ 3.4
I think it's updated to avs+ 3.7.1 now
kedautinh12 is offline   Reply With Quote
Old 29th August 2021, 15:24   #5  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 11,018
Oops, and the one for v2.58 of course would require GScript.
__________________
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
Reply

Tags
imagewriter, png

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 00:14.


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