HowToApplyFilterToManySingleFrames のバックアップソース(No.1)

Inspired by [[[this thread]:http://forum.doom9.org/showthread.php?t=99122]].

''Our mission.''

We have to apply a filter to a large number of frames, but creating a large script is tedious and stresses AviSynth a lot.

''Our solution''

We use a conditional filter and read the frame numbers from an external file.

''The script''

We want to use chroma from the previous frame on the frames specified.

#code(nonumber){{
global FreezeThis = 0               # don't change this - it does nothing.
video = AviSource("video.avi")
frozen = video.MergeChroma(DuplicateFrame(video,0))
ConditionalFilter(video, frozen, video, "FreezeThis", "==", "1")
ConditionalReader("BadFrames.txt", "FreezeThis", false)
}}

Now that looks pretty easy. Here is what we're doing. We create an original and an alternative video stream. Here we simply duplicate the first frame, thus offsetting it by one, and merges the chroma into the original video. Then we create a conditional filter that select frames from the alternative stream, if it has been selected. But we still haven't specified any frames. We do that in the external file called "Badframes.txt".

''The external file''

This is a pretty basic file for ConditionalReader. It should look like this:

Badframes.txt:

 type int
 default 0
 65 1
 324 1
 451 1
 871 1

So basicly it says, "as default set the value to 0". For the frames I specify, set it to 1.

''Advanced''

OK. In the original thread that was referenced chroma could sometimes be taken from OTHER frames. So why not create a filter that let's you specify an offset for each frame. This is a bit more tricky:

#code(nonumber){{
global FreezeThis = 0                                   # don't change this - it does nothing.
global video = AviSource("video.avi")
past = ScriptClip("trim(video,-FreezeThis,0)")
future = ScriptClip("blankclip(video, length=FreezeThis)+video")
offset = video.MergeChroma(Conditionalfilter(video, past, future, "FreezeThis", "<", "0"));
ConditionalFilter(video, video, offset, "FreezeThis", "==" "0")
ConditionalReader("BadFrames.txt", "FreezeThis", false)
}}

Badframes.txt:

 type int
 default 0
 65 5
 324 -10
 451 2
 871 4

Now we have a script where you can offset chroma by a selectable number of frames on a per frame basis!

#hr

註: このページは、[[HowToApplyFilterToManySingleFrames - AviSynth:http://www.avisynth.org/HowToApplyFilterToManySingleFrames]]からの転載です。