[[[このスレッド]:http://forum.doom9.org/showthread.php?t=99122]]にインスパイアされて。
''私たちの任務''
私たちは、多数のフレームに、フィルタを適用しなければなりません。しかし、大きなスクリプトを作成するのは長たらしくて退屈で、AviSynth に大いにストレスをかけます。
''私たちの解決策''
私たちは、条件フィルタ(conditional filter)を使って、外部ファイルからフレーム番号を読み込みます。
''スクリプト''
私たちは、指定されたフレームに、前のフレームの色差を使いたいと思います。
#code(nonumber){{
global FreezeThis = 0 # これを変更しないで - それは何もしません。
video = AviSource("video.avi")
frozen = video.MergeChroma(DuplicateFrame(video,0))
ConditionalFilter(video, frozen, video, "FreezeThis", "==", "1")
ConditionalReader("BadFrames.txt", "FreezeThis", false)
}}
さて、ずいぶん簡単そうに見えます。こちらに、私たちが行っていることがあります。私たちは、オリジナルのビデオストリームと代替のビデオストリームを作成します。ここで私たちは、単純に、最初のフレームを複製します。このようにして、1フレームずつそれを差し引き計算(offset)して((訳者註: 先頭フレームをDuplicateFrameで複製し、先頭に1フレーム追加することによって、frozenのフレームを1フレームずつずらしています。))、オリジナルのビデオに色差をマージします。それから、私たちは、もしそれが選択されている場合は代替ストリームからフレームを選択する、条件フィルタを作成します。しかし、私たちは、まだどのフレームも指定していません。私たちは、"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]]からの転載です。