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 13th May 2003, 13:02   #1  |  Link
Didée
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 5,391
How to apply functions to repeating ranges?

Maybe I'm too dumb today to see the obvious ... or is there something missing in AviSynth?

My problem:
I captured a clip that has been put on air with the word "pop" overlayed as logo. I have no problems with de-logoing in itself, I do that almost every day (indeed). But in this case ... well: while the word "pop" is pretty small, it isn't stationary - it slowly travels on a circle, performing one complete rotation every 750 frames.
I don't want to de-logo the complete circle at once, that would be a big loss. Instead, I'm trying to de-logo 10 sequences of 75 frames each, so that only a small area is affacted at once.

But I don't succeed in puzzling it together ...

My 1st thought was to split the capture with "SelectRangeEvery()" into 10 parts, apply my functions "delogo1()", "delogo2()" etc. to each segment, and then to interleave it together again.
But: "Interleave()" works only on a per-frame-basis. I would need something like "interleave(clip1,clip2,...,BLOCKSIZE)" to interleave blocks of 75 frames from each clip.
This seems to be a no-go, unless I missed something. But it would be the most elegant solution!

My 2nd thought, obviously, was to fiddle it together with "ApplyRange", though this would mean a little more typing in the end. Perhaps I could reduce the typing effort if I can combine ApplyRange with ScriptClip somehow, I thought ...
I did not get that far! Much worse, I could not even get "ApplyRange" to accept my function. Works braindead-easy with the internal filters, but not with a user-defined function ... the following (parts) of my script :
Code:
function VD_DeLogo(clip clip, bool "on_frames", string "range", string "file_deblend", string "file_alpha", 
  \  string "file_color", string "file_repair", float "depth", float "power", int "par_X", int "par_Y", bool "interlaced")
{
  LoadVirtualdubPlugin("E:\VirtualDub\plugins\delogo.vdf", "_VD_DeLogo")
  X = round
[... all that stuff from Wilbert's import script]
}
#------------------------------
function delogo0 (clip clip) {
ConvertToRGB(clip)
log1=VD_DeLogo(false, "", "", "", "", "logo0.bmp", 1.5, 4.0, 1, 1, false).ConvertBackToYUY2()
return(log1)
}
#------------------------------
# [ ... ]
function delogo9 (clip clip) {
ConvertToRGB(clip)
log1=VD_DeLogo(false, "", "", "", "", "logo9.bmp", 1.5, 4.0, 1, 1, false).ConvertBackToYUY2()
return(log1)
}
#=================================
#
raw=last
applyrange(300,375, "delogo1", raw)  #  only fixed range to get it working at all, but it won't
[...}
return(last)

always give me "Invalid arguments to function 'applyrange' ", whatever I try to do with the syntax.

Someone with a genious idea? Please?

I won't do it all with "trim" only - in a week from now, I'd still be typing!

Thanks for any suggestions

Didée
__________________
- We´re at the beginning of the end of mankind´s childhood -

My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!)
Didée is offline   Reply With Quote
Old 13th May 2003, 13:33   #2  |  Link
Wilbert
Moderator
 
Join Date: Nov 2001
Location: Netherlands
Posts: 6,364
Strange, does the following script produce correct output:

delogo1(raw)

If not, does this show anything:

ver = Version()
return ApplyRange(0, 149, "Crop", ver, 224, 0, 64, 32)
Wilbert is offline   Reply With Quote
Old 13th May 2003, 15:04   #3  |  Link
Didée
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 5,391
A simple 'delogo1(raw)' works as expected, yes.

But your example with 'crop' also gives me "invalid arguments", indeed.

I just cross-checked three older versions of avisynth.dll (27-03, 14-04, 30-04) - they behave the same.

Hmhmh.

ATM I'm here with an old Athlon(I)700, WinXP, ...wait a second!
Sometimes I suspect something with this machine, perhaps because iSSE isn't officially supported by this old Athlon? E.g. it's impossible on this system to load AS2.0 plugins into AS2.5 with 'LoadPluginEx.dll' ...
I'll check today evening (night) on my other system - perhaps there everything is fine?

In the meantime, nonetheless I vote for giving 'interleave' an additional "blocksize" parameter, or ssth similar ... would come pretty handy at times, really.

'Cause I'm still in need to bring those 75-frame2-blocks in the right order again.
Somehow it should be possible with only the 'Scriptlip' functionality ... but a big headache for me, that is
__________________
- We´re at the beginning of the end of mankind´s childhood -

My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!)
Didée is offline   Reply With Quote
Old 13th May 2003, 16:00   #4  |  Link
Wilbert
Moderator
 
Join Date: Nov 2001
Location: Netherlands
Posts: 6,364
Same problem here:

doesn't work:
ApplyRange(0, 149, "Crop", Version(), 0, 0, 468, 80)

works:
Animate(0, 149, "Crop", Version(), 0, 0, 468, 80, ver, 0, 0, 468, 80)

I'm using a PIII though. Use Animate (till ApplyRange works again):

Animate(300, 375, "delogo1", raw, raw)

Last edited by Wilbert; 13th May 2003 at 16:02.
Wilbert is offline   Reply With Quote
Old 13th May 2003, 16:04   #5  |  Link
sh0dan
Retired AviSynth Dev ;)
 
sh0dan's Avatar
 
Join Date: Nov 2001
Location: Dark Side of the Moon
Posts: 3,480
Quote:
Sometimes I suspect something with this machine, perhaps because iSSE isn't officially supported by this old Athlon? E.g. it's impossible on this system to load AS2.0 plugins into AS2.5 with 'LoadPluginEx.dll' ...
I'll check today evening (night) on my other system - perhaps there everything is fine?
You are rambling - All athlons support ISSE, and this should affect your ability to load older filters anyway.

I'll look at the ApplyRange.
__________________
Regards, sh0dan // VoxPod
sh0dan is offline   Reply With Quote
Old 13th May 2003, 16:18   #6  |  Link
sh0dan
Retired AviSynth Dev ;)
 
sh0dan's Avatar
 
Join Date: Nov 2001
Location: Dark Side of the Moon
Posts: 3,480
In contrast to Animate, ApplyRange does not allow the first parameter to be non-clip.

ApplyRange can only work on "implicit last" or a given video. To real humans this means that the first parameter of the filter that is being applied must always be the same as the input of Applyfilter - there is no easy fix for this.

1) Use trim + splice.
2) Use Animate (if this is possible)
3) Submit a feature request at SourceForge.
__________________
Regards, sh0dan // VoxPod
sh0dan is offline   Reply With Quote
Old 13th May 2003, 16:32   #7  |  Link
Wilbert
Moderator
 
Join Date: Nov 2001
Location: Netherlands
Posts: 6,364
Quote:
ApplyRange can only work on "implicit last" or a given video. To real humans this means that the first parameter of the filter that is being applied must always be the same as the input of Applyfilter
Could you give an example?

I guess you mean this, but that doesn't work either:

ver = Version()
ver.ApplyRange(0, 149, "Crop", ver, 0, 0, 468, 80)
Wilbert is offline   Reply With Quote
Old 13th May 2003, 20:05   #8  |  Link
sh0dan
Retired AviSynth Dev ;)
 
sh0dan's Avatar
 
Join Date: Nov 2001
Location: Dark Side of the Moon
Posts: 3,480
Don't add ver to the parameters - The "clip" on applied filter is always the same as the one you give to the applyrange filter (in this case also ver).

ver = Version()
ver.ApplyRange(0, 149, "Crop", 0, 0, 468, 80)

or

ApplyRange(ver, 0, 149, "Crop", 0, 0, 468, 80)

The long explanation of the statement above (and why applyrange works like it does):

There are actually two functions defined as animate:

Animate(int start, int stop, string "filter", parameters...)
Animate(clip whichclip, int start, int stop, string "filter", parameters...)

- The top one is being used first, if there is no _explicit_ clip given as first parameter. That means - if the first number is an int, do NOT try to make a filter with "implicit last". This is so to enable users to create clips (BlankClip for instance).
This is also how Animate knows if it should take the clip given to it, and use it as the first argument for the filter (otherwise it has no way of knowing this).

ApplyRange cannot allow this, since it needs a clip to pass untouched through outside the specified range - this is why it needs to have a clip as input. So the basic difference is that animate never lets a frame pass through unfiltered, while applyrange does.

It should be possible to make ApplyRange accept arbitrary clips as arguments - it's just not straightforward. The current way it works is by design - even though it isn't optimal. Use it for applying simple filters for the time being, and use traditional trim/splice for more complex tasks.
__________________
Regards, sh0dan // VoxPod

Last edited by sh0dan; 13th May 2003 at 20:19.
sh0dan is offline   Reply With Quote
Old 14th May 2003, 07:46   #9  |  Link
Didée
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 5,391
Hello again,

yesterday I had an interesting evening, with enough swearing for the rest of the year .
By the way, I figured some things.

Short reminder: the functions delogo0() .. delogo9() are properly declared, and I want to apply them one after another to fixed ranges of the clip in a cycling manner, like that:
frame 001 - 075: delogo0
frame 076 - 150: delogo1
...
frame 676 - 750: delogo9
frame 751 - 825: delogo0
...
and so on ...

Since I didn't succeed in getting something reasonable to work with "ApplyRange()", I reminded myself of sh0dan's latest gift for us: Conditional filtering.

However, it was not that easy for me.

This simple line will work:
Code:
ScriptClip("numb=(current_frame/75)%10" + chr(13) + "delogo" + "5" + "()")
The calculation in the first part is of course useless, BUT the second part will correctly call the function "delogo5()". Well.


The following should work out what I want, but doesn't:
Code:
ScriptClip("numb=(current_frame/75)%10" + chr(13) + "delogo" + String(numb) + "()")
AviSynth throws "I dont know what 'numb' means". It seems to me, that either the function "String()" isn't properly evaluated inside of "ScriptClip()", or something gets spoiled up with the variable 'numb'. After all, the simple first example has no problems with 'numb', and delivers the numbers 0..9 in the expected frame ranges.


I armed myself with a bottle of beer, and dived (for the 10000th time) into the documentation. As usual, that was a good idea - at the beer's end, I came up with the following:
Code:
vid0=delogo0()
vid1=delogo1()
[...]
vid9=delogo10()

ScriptClip("numb=(current_frame/75)%10" + chr(13) + "select(numb,vid0,vid1,vid2,vid3,vid4,vid5,vid6,vid7,vid8,vid9)")
Bingo! Works like a charm. Before, I was not even aware that "Select()" exists at all ... learning every day!


Conclusion 1: Many ways lead to Rome.
Conclusion 2: AviSynth is such a powerful tool, I lack the right words to thank the developpers. Thank you all!!
Conclusion 3: There are some quirks left

One little problem is left: Finally, I figured that the rotation period of the logo is not 750 frames, but 749 ... Aaaaargh!


Best regards

Didée
__________________
- We´re at the beginning of the end of mankind´s childhood -

My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!)
Didée is offline   Reply With Quote
Old 14th May 2003, 07:57   #10  |  Link
Didée
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 5,391
Quote:
Originally posted by sh0dan
You are rambling - All athlons support ISSE, and this should affect your ability to load older filters anyway.
Sorry, but it was more kind of a typo. iSSE is supported on every Athlon, yes. Its SSE thats only available on the past-Athlon(I)-CPUs. At least that checkbox is always empty in all those CPU-optimizations-autodetect-thingies.
__________________
- We´re at the beginning of the end of mankind´s childhood -

My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!)
Didée is offline   Reply With Quote
Old 14th May 2003, 09:31   #11  |  Link
Wilbert
Moderator
 
Join Date: Nov 2001
Location: Netherlands
Posts: 6,364
@Didee,

I see want you want, don't know how to do it with ScriptClip. Moreover, could you explain why

ScriptClip("numb=(current_frame/75)%10" + chr(13) + "delogo" + "5" + "()")

works, especially this part: "numb=(current_frame/75)%10" + chr(13)?

Does the following work?

clip1=Animate(0, 75, "delogo0", raw, raw)
cilp2=Animate(76, 150, "delogo1", clip1, clip1)
etc.

or this:

clip1=raw.ApplyRange(0, 75, "delogo0")
clip2=clip1.ApplyRange(76, 150, "delogo1")
etc.

@Sh0dan,
Thanks for you explanation. I will update the docs.
Wilbert is offline   Reply With Quote
Old 14th May 2003, 11:57   #12  |  Link
Didée
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 5,391
Wilbert,

first, if you look again at my last <CODE> example - that does work with ScriptClip. Actual problem is solved.

The part "numb=(current_frame/75)%10" just generates a digit from 0 to 9 for each single frame, based upon the actual framenumber, and assigns it to 'numb'.
Then, chr(13) breaks to the next "line". There I want to call the function "delogoX", where X=numb.
In the second line, the usage of "ApplyRange()" would be obvious and logical, but ... as described. Fortunately, for this particular case, the function "Select()" comes to rescue, letting me do exactly what I want.

I can't try your last suggested tests now (am at work), I'll report tomorow.
However, that strategy is unusable for my mentioned problem:
- The capture file is ~90 min
- Need to write an ApplyRange()-line for each and every block of 75 frames
- that makes [rattata rattata] ... 1800 lines with ApplyRange() in the script. Not too practicable , and that's the very reason for all the effort.


- Didée
__________________
- We´re at the beginning of the end of mankind´s childhood -

My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!)
Didée 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 15:24.


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