View Full Version : what is wrong with this mini script?
Zep
11th January 2004, 05:18
ok i never had a problem before then suddenly this script
causes errors on crop with an invalid arguments error
clip = mpeg2source("d:\movie.d2v")
Crop(16,8,-16,-8)
UPDATE:
oh geez it turns out i need to add clip like this
Crop(clip,16,8,-16,-8)
why just on Crop and none of the other comands need clip added
i would like to know :)
anyone?
Richard Berg
11th January 2004, 06:55
# try this
mpeg2source("d:\movie.d2v")
Crop(16,8,-16,-8)
Almost all commands need a clip as the first argument. It can be passed in directly or taken from the implicit "last" variable.
stickboy
11th January 2004, 11:30
To elaborate:
If a function returns a clip, if that clip is not explicitly assigned to another variable, then it gets assigned automatically to the special variable last.
If a function Foo takes a clip as its first argument and if that argument is not explicitly specified, it is automatically transformed into Foo(last, ...).
In your case, since you assigned the return value of mpeg2source to the variable clip, last was never assigned a value, and hence the implict Crop(last, ...) generated an error.
Zep
11th January 2004, 18:33
Originally posted by Richard Berg
# try this
mpeg2source("d:\movie.d2v")
Crop(16,8,-16,-8)
I can't because i need clip later in the script
clip = mpeg2source("d:\er.d2v").Crop(16,8,-16,-8).YV12InterlacedReduceBy2().Decimate(cycle=5)
movie = clip.Trim(0,9075).LanczosResize(624,352)
movie = movie+clip.Trim(9076,20187).Crop(112,64,-116,-68).LanczosResize(624,352)
movie = movie+clip.Trim(20188,0).LanczosResize(624,352)
return movie
interestingly enough i assume the first crop doesn't need
clip now because I moved it before the assigning of clip
but the later crop doesn't seem to need it which is strange.
When did the var last get assigned?
NOTE: in case you are wondering what i was doing. it was an episode of
HDTV 1920 x 1080i of the show ER. What NBC does is some scenes
they zoom out and fill black around the scene so on those scenes i
have to crop closer. This keeps all scenes filling the LanczosResize(624,352)
and since the standard rez is 704 x whatever it fill the 624 x 352
just fine and dandy.
Zep
11th January 2004, 18:41
Originally posted by stickboy
To elaborate:
If a function returns a clip, if that clip is not explicitly assigned to another variable, then it gets assigned automatically to the special variable last.
If a function Foo takes a clip as its first argument and if that argument is not explicitly specified, it is automatically transformed into Foo(last, ...).
In your case, since you assigned the return value of mpeg2source to the variable clip, last was never assigned a value, and hence the implict Crop(last, ...) generated an error.
ahh yes i see now. can last be assigned so i do not have to add clip to everything?
also what about my previous post. When did last get assigned?
since I assigned the return value of mpeg2source to the variable
clip, then when did last get assigned?
the second crop as an example there is no error so last
must have be assigned, right?
stickboy
11th January 2004, 22:12
Originally posted by Zep
ahh yes i see now. can last be assigned so i do not have to add clip to everything?Aside from the automatic behavior, there's nothing special about last. You can assign clips to last explicitly if you wish (e.g. last = clip1), and you can assign other clips to last (e.g. clip1 = last).
also what about my previous post. When did last get assigned?
since I assigned the return value of mpeg2source to the variable
clip, then when did last get assigned?It didn't.
the second crop as an example there is no error so last
must have be assigned, right?Sorry, I guess I oversimplified my previous explanation.
If a function returns a clip, if that clip is otherwise unused, then AviSynth assigns it to last automatically. By "unused", I mean that it does not get assigned to a variable and does not get used as an argument to some other function or operator.
Also, remember that clip.Foo(...) is equivalent to Foo(clip, ...). So your line:
movie = movie+clip.Trim(9076,20187).Crop(112,64,-116,-68).LanczosResize(624,352)This is the same as:
movie = movie + LanczosResize(Crop(Trim(clip, 9076, 20187), 112, 64, -116, -68), 624, 352)Each of the functions used in the above code requires a clip as its first argument, and that requirement is met, so there is no error.
Zep
12th January 2004, 06:53
Originally posted by stickboy
Aside from the automatic behavior, there's nothing special about last. You can assign clips to last explicitly if you wish (e.g. last = clip1), and you can assign other clips to last (e.g. clip1 = last).
good to know
Originally posted by stickboy
If a function returns a clip, if that clip is otherwise unused, then AviSynth assigns it to last automatically. By "unused", I mean that it does not get assigned to a variable and does not get used as an argument to some other function or operator.
interesting.
Originally posted by stickboy
Also, remember that clip.Foo(...) is equivalent to Foo(clip, ...).
ok that explains it.
Thx :)
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.