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. |
26th January 2011, 20:46 | #1 | Link |
Registered User
Join Date: Aug 2006
Posts: 336
|
for cycle
Hello. I need to write in a script a code like this
//I want load, process and save 1.jpg, 2.jpg, 3.jpg for (i = 1; i <= 3; i++) { string1 = String(i) string2 = string1 + ".jpg" ImageSource(string2) ..... ..... ImageWriter (string2,0,0,"jpg") i = i + 1; } How can I implement loop in avisynth? thanks |
26th January 2011, 23:44 | #2 | Link |
Avisynth language lover
Join Date: Dec 2007
Location: Spain
Posts: 3,431
|
The Avisynth language does not have a loop construct, but looping can be achieved using a recursive function.
Alternatively, GScript is a set of language extensions that includes a for-loop construct. There are a couple of things to sort out in your script, though. First, I'm sure you didn't mean to have both i++ and i=i+1 in the code. Less obviously, you need to be aware that ImageWriter will only write to the file for frames that form part of the script's final output. So you need to join the individual ImageWriter results together. Code:
GScript(""" for (i = 1, 3) { string1 = String(i) string2 = string1 + ".jpg" ImageSource(string2) ..... ImageWriter (string2,0,0,"jpg") result = (i == 1 ? last : result + last) } return result """) |
27th January 2011, 01:54 | #3 | Link | |
Registered User
Join Date: Aug 2006
Location: Stockholm/Helsinki
Posts: 805
|
Quote:
result = (i == 1 ? pointresize(16,16) : result + pointresize(16,16)) or a better resizer/bigger size if you actually want to preview the images. |
|
27th January 2011, 12:03 | #5 | Link | ||
Avisynth language lover
Join Date: Dec 2007
Location: Spain
Posts: 3,431
|
Quote:
Note that you must 'play' the entire video for ImageWriter to write everything out. Quote:
Code:
function f(int i, int limit) { string1 = String(i) string2 = string1 + ".jpg" ImageSource(string2) ..... ImageWriter (string2,0,0,"jpg") PointResize(16, 16) # see ajp_anton's post return (i < limit ? last+f(i+1, limit) : last) } f(1, 3) Last edited by Gavino; 27th January 2011 at 12:09. Reason: must play entire video |
||
Thread Tools | Search this Thread |
Display Modes | |
|
|