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. |
20th March 2004, 01:43 | #1 | Link |
AviSynth Enthusiast
Join Date: Jul 2002
Location: California, U.S.
Posts: 1,267
|
stickboy's AviSynth plug-ins
Okay, I've made some really rudimentary AviSynth plug-ins. I've mentioned a couple of them in passing in some other threads, but I haven't said much about them.
SelectByString A function that's similar to the built-in Select function but that operates on strings. (If you're familiar with other programming languages, it can provide functionality similar to a switch statement or to an associative array.) Examples: Code:
SelectByString("jubjub", \ "tove", 0, \ "borogove", 1, \ "jubjub", 2, \ "jabberwock", 3) Obviously, it's more useful if the search string is a variable: Code:
function ColorNameToRGB(string colorName) { return SelectByString(colorName, \ "white", $FFFFFF, \ "black", $000000, \ "red", $FF0000, \ "green", $00FF00, \ "blue", $0000FF) } And, of course, these functions can be useful for making wrapper functions with presets. Min/Max Basic Min/Max functions that can take a variable number of arguments. Arguments can be integers or floats and even can be mixed, if so desired. Not much to say here. Threshold/Core [YUY2, RGB24, RGB32] Basic (and unoptimized) threshold and coring functions. Threshold maps all pixels darker than a specified threshold value to pure black and the rest to pure white. Core is similar; it maps all pixels darker than a specified threshold value to pure black and leaves the rest untouched. Shuffle Randomly shuffles the frames in a clip. Yeah, it's useless, but it can be used to make some mildly interesting effects. (See the included script of examples.) DeleteEvery/DeleteFrames Functions that facilitate deletion of multiple frames. DeleteEvery complements SelectEvery; SelectEvery(4, 0, 1, 2) is equivalent to DeleteEvery(4, 3). Again, not too useful, but I remember there have been some cases where people have wanted to delete, say, 1 frame of every 1000, which is impractical for SelectEvery. DeleteFrames--not surprisingly--is a version of the built-in DeleteFrame function that can handle multiple frames. Calling DeleteFrame multiple times is:
Source code to everything is included under a BSD-style license. Last edited by Guest; 10th October 2007 at 02:24. Reason: rule 4 |
20th March 2004, 16:46 | #2 | Link |
interlace this!
Join Date: Jun 2003
Location: i'm in ur transfers, addin noise
Posts: 4,555
|
bravo!!
deleteevery is just the thing for PAL telecine with duped frames (r4 fight club) [edit] and shuffle could be made a _little bit_ more useful if you could select random chunks of several frames rather than just single frames. i did something like that with a script when i was helping a friend make a grindcore video. lots of gore footage selected randomly in 5 frame chunks (that coincided with the double-kick). huge time-saver to do it that way rather than make a million cuts in premiere, i can tell you :|
__________________
sucking the life out of your videos since 2004 Last edited by Mug Funky; 20th March 2004 at 16:48. |
20th March 2004, 18:21 | #4 | Link |
Retired, but still around
Join Date: Oct 2001
Location: Lone Star
Posts: 3,058
|
Just a thought, but if each of the advanced script writers would post a similar guide to their work in this thread, then eventually, it could be edited, renamed and potentially made sticky. We do need a way to consolidate all this great work you guys are doing and this may be a simple way to do it.
__________________
How to Optimize Bitrate for CCE multipass |
20th March 2004, 21:39 | #5 | Link | |
AviSynth Enthusiast
Join Date: Jul 2002
Location: California, U.S.
Posts: 1,267
|
Quote:
|
|
21st March 2004, 01:40 | #6 | Link |
AviSynth Enthusiast
Join Date: Jul 2002
Location: California, U.S.
Posts: 1,267
|
New plug-in: ApplyEvery
ApplyEvery
A generalized function that can apply a specified function at regular intervals in a clip. DeleteEvery can be viewed as a specialized version; DeleteEvery(100, 0) is conceptually equivalent to ApplyEvery(100, "DeleteFrame(0)"). (In practice, DeleteEvery is much more efficient, so if you're only deleting frames, use that. Plus, DeleteEvery modifies the frame-rate appropriately.) This is basically a straight conversion of my JDL_ApplyEvery user-defined function to an AviSynth plug-in. I tried the following script with my user-defined version: Code:
BlankClip(length=2100, pixel_type="yuy2") ShowFrameNumber() JDL_ApplyEvery(4, "Reverse()") If I substitute in the plug-in version, I can increase the clip length to over 80000. (That's 20000+ iterations, a ~40-fold increase.) A script with that many iterations is slow to load, however. This is an experimental, quick-and-dirty build; source currently isn't included but will be forthcoming eventually, after I ponder some possible improvements. Last edited by stickboy; 31st March 2004 at 23:25. |
21st March 2004, 03:17 | #7 | Link |
Registered User
Join Date: Apr 2002
Location: Germany
Posts: 5,391
|
ApplyEvery!!!
Now, this is great! ... but a year too late By that time, I had a clip with a logo consisting of the word "pop" in small letters, that was slowly travelling its way around a big imaginary circle. I ended up in breaking the circumfang in 10 or 12 pieces, made a "delogo" function for each of these fractions, and then fiddled something together with the "select" function and conditional filtering acc. to framecount. That would've been a job for ApplyEvery ... Thanks for "centralizing" your functions, stickboy. - 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!) |
22nd March 2004, 05:56 | #8 | Link |
interlace this!
Join Date: Jun 2003
Location: i'm in ur transfers, addin noise
Posts: 4,555
|
@scharfis_brain - it's nothing spectacular... just a matter of duping 1 in 25 frames and not touching the audio. sadly i've only seen it used once.
i've noticed sped-up audio discs often transcode the audio from the NTSC version! this completely breaks any transparency the audio once had. (if you can get hold of r4 "being john malkovich" you'll hear the opening applause is riddled with pre-echo and stereo collapse)
__________________
sucking the life out of your videos since 2004 |
1st April 2004, 03:37 | #9 | Link |
AviSynth Enthusiast
Join Date: Jul 2002
Location: California, U.S.
Posts: 1,267
|
New ApplyEvery version up.
I merged my ApplyEvery and DeleteEvery plug-ins and added a new function: InterleaveEvery.
InterleaveEvery is yet another almost useless function, but I felt that it was needed for completeness. InterleaveEvery can undo the work of SelectEvery + DeleteEvery. If you use SelectEvery and DeleteEvery to pull some frames out, InterleaveEvery can put them back in: Code:
src = AVISource( ... ) # pull out some frames subClip = src.SelectEvery(5, 0, 1) src = src.DeleteEvery(5, 0, 1) # inject the frames back in src.InterleaveEvery(subClip, 5, 0, 1) But, if you wanted to, say, invert the first two frames of every group of five, InterleaveEvery makes it easy to do that. (Not that anyone would want to do that, of course...) Or maybe it could be used to insert subliminal messages. Or something. Last edited by stickboy; 1st April 2004 at 03:59. |
24th December 2004, 23:19 | #10 | Link |
AviSynth Enthusiast
Join Date: Jul 2002
Location: California, U.S.
Posts: 1,267
|
RemapFrames
I neglected to announce this here before, but I made another plug-in: RemapFrames.
RemapFrames provides general control over manipulation of frame indices in a clip. It doesn't affect the audio track. I still haven't figured out a good way to deal with audio, but it's intended to be an alternative to long chains of FreezeFrame and DeleteFrame calls, which touch up individual frames and which also don't affect the audio. Anyhow, today I hacked in a new function to RemapFrames: ReplaceFramesSimple. On a number of occasions I've done things like: Code:
c = src.Telecide(...).Decimate(...) # Oops. Some frames are still combed, and I don't want to # post-process the entire clip. ApplyRange(100, 110, "SomeDeinterlacer") ApplyRange(200, 200, "SomeDeinterlacer") ApplyRange(250, 250, "SomeDeinterlacer") ApplyRange(300, 310, "SomeDeinterlacer") Code:
c = src.Telecide(...).Decimate(...) deinterlaced = c.SomeDeinterlacer() ReplaceFramesSimple(c, deinterlaced, \ mappings="[100 110] 200 250 [300 310]") |
13th January 2007, 22:55 | #11 | Link |
Mr. Woof
Join Date: Jan 2002
Location: USA
Posts: 784
|
stickboy, I'd like to use applyrange to isolate 2 sections in my clip, but I also need to IVTC the clip (VHS capture). Your warning in the script says I shouldn't use applyrange along with anything that alters frame count, so then what should I use? Trim isn't very reliable from what I've read although I'm no expert.
How should I proceed? Can I just find the decimated frame range and use those numbers, calling jdl_applyrange after IVTC? Last edited by chipzoller; 13th January 2007 at 23:52. |
14th January 2007, 11:38 | #12 | Link |
AviSynth Enthusiast
Join Date: Jul 2002
Location: California, U.S.
Posts: 1,267
|
I don't understand what you want to do. What do you want to use JDL_ApplyRange (or the internal ApplyRange) for? What are you doing that with it that will affect the frame count?
The filter you apply with JDL_ApplyRange shouldn't affect the frame count. You can do whatever you want to the clip before or after calling JDL_ApplyRange, though. That said, it's probably a better idea to do IVTC early on so you don't waste time filtering frames that will be removed, and then figure out the appropriate frame numbers to give to ApplyRange/JDL_ApplyRange/whatever in the IVTC'd clip. BTW, why isn't Trim reliable? If you're referring to my Caveats about using Trim in functions thread, then you've misunderstood. |
14th January 2007, 14:39 | #14 | Link |
Mr. Woof
Join Date: Jan 2002
Location: USA
Posts: 784
|
I have a capture that the intro and credits are animated and the middle is live action. I want to use applyrange to filter the intro. and credits separately from the live action section, but at the same time, the capture needs to be IVTCd. This thread may better explain.
|
14th January 2007, 20:30 | #15 | Link |
AviSynth Enthusiast
Join Date: Jul 2002
Location: California, U.S.
Posts: 1,267
|
Yeah, just IVTC first and use ApplyRange afterward.
Or actually, in this case, just using Trim directly is probably more straightforward: Code:
intro = Trim(0, 1000).IVTC().OtherFilters() rest = Trim(1001, 0).IVTC() intro + rest |
10th October 2007, 00:54 | #16 | Link |
Registered User
Join Date: Mar 2007
Posts: 15
|
Good Morning, Stickboy!
I've been happy for about three days now, that i have found a solution for re-arranging frames algorithmically - with your RemapFrames function. Unfortunately, the function does not eat the three parameters, as the following script earns a "Invalid arguments to function RemapFrames": Code:
dur=1200 src2 = aviSource("an .AVI") target = BlankClip(src2) target.lengthenClip(dur).ShowFrameNumber() #return src2 will work! #RemapFrames(target, filename = "D:\Code\Avisynth\gfa.Frames.vsc", src2) #as well as RemapFrames(src2, filename = "D:\Code\Avisynth\gfa.Frames.vsc", target) # yield the error "Invalid Arguments" I need to extend these functions you wrote, if you could give me some advise:
blausand |
10th October 2007, 22:37 | #17 | Link |
Registered User
Join Date: Mar 2007
Posts: 15
|
Bug in LengthenClip() regarding c.framecount?
Don't say that! It seems that your work is quite valueable to a small community (me, in fact?) of video artists.
Regarding the malfunction mentioned above:It seems that RemapFrames does not insert last automatically when the first argument is omitted. To double-check, i use 'optional parameter notation' allover now. The error changed to "Value out of bounds" when i used "pure argument notation" and that turned out to be an error within LengthenClip(). LengthenClip() does not correct the clip property "framecount", as the following screenshot wants to make me believe: Last edited by blausand; 10th October 2007 at 22:40. |
10th October 2007, 23:34 | #18 | Link | |||
AviSynth Enthusiast
Join Date: Jul 2002
Location: California, U.S.
Posts: 1,267
|
Quote:
Quote:
Code:
RemapFrames(src2, filename="D:\Code\Avisynth\gfa.Frames.vsc", sourceClip=target) Quote:
Last edited by stickboy; 10th October 2007 at 23:41. |
|||
11th October 2007, 17:09 | #19 | Link |
Registered User
Join Date: Mar 2007
Posts: 15
|
clip.function() does not alter clip...
at least [me] thought, the object.function semantic operates destructive per default.
It took me some effort to understand this: Code:
target.LengthenClip(new_duration) target = target.LengthenClip(new_duration) i have to make an explicit assignment, as in the second line. If you look at my second ScreenShot, you'll see a proof of inconsistency, though. Anyway, i think that this behaviour should be emphasized in any introductory or tutorial text; I'd personally prefer to work with last, making one operation per line, but working with several clips and using last complicates commenting in and out single lines of code. How can i finish every clip-editing block with an assignment line? The following ends with "Not a Clip" error: E.g.: Code:
LoadPlugin("C:\Programme\MEDIA\AviSynth 2.5\PlugIns\ApplyEvery.dll") # (necessary because Avisynth didn't register my custom installation path correctly ;( # #### CLIP1 #### aviSource("src0.AVI", pixel_type = "RGB32") BilinearResize(320,240) Mask(Levels(last, 126,1.0,128, 0, 255)) ShowFrameNumber() LengthenClip(1200) CLIP1 = last blausand Last edited by blausand; 11th October 2007 at 17:32. |
11th October 2007, 17:40 | #20 | Link |
Angel of Night
Join Date: Nov 2004
Location: Tangled in the silks
Posts: 9,559
|
You have to use CLIP1 or return CLIP1 as the last line of your script; avisynth doesn't like assignments as the last line for some reason, even when there is a logical last.
And yeah, avisynth is designed so that a source clip is never modified, although it may be lost (and internally, a source may be modified/overwritten if it's never reused in script). |
Thread Tools | Search this Thread |
Display Modes | |
|
|