Log in

View Full Version : Using ImageWriter to make screencaps, help if possible


Gargalash
27th January 2009, 19:00
Hello all,
This is my first post ever and I want to thank the community. So far I have read tons of pages here and I have almost always found answers.

My problem:
I have over 200 AVIs. For each, I need to get a jpg screenshot every 90 frames (or so). I bet ImageWriter can be used to do that, but I don't know how. I'm trying to build a script and I would then use the avs batching tool to get one for each video files. From there I can batch with virtualdub and then with photoshop to get my final product.

I would need the output jpgs to be named according to the filename (and numbered). I guess I could use the "%filename" in the ImageWriter function and that would define a output jpg filename that can be the same as the the clip filename when batching with this
http://beta.zenaria.com/kpo/avs.html

I am really stuck when it comes to create a script that will write the frame, then frame+90, etc. I guess a loop is needed until the current frame number is higher than framecount.

Here is what I can think of for now...
AVISource("%filenamE")
framenumber = 0
DO while framenumber<framecount
framenumber = framenumber+90
ImageWriter(file=%filenamE+framenumber, start = framenumber, end= -1, string type = "jpg", info = false)
LOOP

I don't know how to loop, or if it's possible. Or maybe there is another way to do this. This is where you help me! :)

Any ideas? Thanks for helping.

kemuri-_9
27th January 2009, 20:26
ConditionalFilter(last,ImageWriter(last,"filename",type="jpg"),last, "current_frame % 90", "equals", "0" )
SelectEvery(90,0)


writes only frames that are multiples of 90, with their proper frame numbers and doesn't even process any of the other frames.

Gargalash
27th January 2009, 20:40
kemuri-_9,
Thank you so much!
I will make tests with that. I'll have to get familiar with ConditionalFilter as well...

I'll get back with the results, hopefully good :)

IanB
27th January 2009, 21:15
You do not even need the conditional filter, the SelectEvery(90, 0) is all that is required.

Gargalash
27th January 2009, 21:31
IanB,
I was coming back here to suggest exactly this.
I was getting the same results by simply imagewriting everything after using SelectEvery() and vice versa.

I have a question regarding the condition.
"current_frame % 90", "equals", "0"
I looked for "%" in the wiki, it says "mod". What does it mean? (I'm no coder...). Also, is current_frame a clip property?

Thanks for your help!

kemuri-_9
27th January 2009, 21:55
"mod" means the remainder after the division.

7 mod 5 is 2 (the remainder after 7 is divided by 5 is 2)

current_frame is a special keyword in ConditionalFilter, ScriptClip, and FrameEvaluate filters/functions that refers to the current frame number.

I originally developed the ConditionalFilter line to not require the SelectEvery to only ImageWrite the proper frames,
but this for if you actually want to process the other frames in some way (like filtering the entire video and just writing some of the frames to files)

Wilbert
27th January 2009, 21:56
I looked for "%" in the wiki, it says "mod". What does it mean? (I'm no coder...).

http://avisynth.org/mediawiki/Modulo

Also, is current_frame a clip property?
Nope. It's a frame "property".

Gargalash
27th January 2009, 22:28
Thanks for your answers!
I managed to do everything I wanted.