これは、かつて「AviSynthのぺーじ」として公開されていたものの"残骸"です。以下に記されている内容には、間違いが含まれている可能性があります。より正確で新しい情報を知りたい場合は、AviSynth付属のドキュメントや公式サイト(http://www.avisynth.org/)を参考にすることをおすすめします。また、このページは、予告なしに削除される可能性もあります。
ユーザー定義関数実例集
はじめに
 このページでは2ちゃんねるDTV板Avisynthスレやその他のサイトで公開されているユーザー定義関数と私が作成した関数を紹介しています。

 作者さんに無断で掲載しているものもありますが、まとめて紹介することのメリットもあると思いますので、何卒御了承下さい。もし問題があるようでしたら、メールしてください。早急に削除いたします。

   なかには(とりわけ私が作成した関数は)動作が不安定な(うまく動作しない)ものが含まれているかもしれません。使用する際は自己責任でお願いします。

 また特に注意書きがない場合でも、AviSynth2.5以降でないと使用できない可能性があります。ご注意下さい。

※他にもAviSynth.orgShareFunctionsのページや、stickboyさんサイトでも多数の関数が紹介されています。

使用方法
 スクリプト内の任意の位置にfunction以下の関数を貼り付け、書式や引数や使用例を参考にフィルタ部分を記述します。
# 例(Testという名前の関数を使用する場合)

#//--- フィルタ記述部分(カッコ内は関数によって異なる) ---//
Test("autoY", "coring")

#//--- 関数(そのままコピペ。Testが関数の名前) ---//
function Test(clip clip, string "scale" string "saturate")
{
LoadPlugin("C:\Path\ColorYUY2_for_25.dll")
clip = clip.ColorYUY2(levels = scale, opt = saturate)
return clip
}
 int, string, boolなどの意味についてはAviSynth Q&Aのページやスクリプト入門を参考にしてください。

関数一覧
AddRange
作 者 DivX & Avisynth を絶賛しよう 3 の236さん
説 明 VirtualDub(Mod)の設定ファイル(.vdf)内のAddRangeを利用して編集。CM編集のページを参照。
書 式 AddRange(clip clip, int "startframe", int "offset")
引 数 startframe / 開始フレーム
offset / オフセット
関数(1) # オリジナル
function AddRange(clip clip, int "startframe", int "offset")
{
return clip.Trim( default(startframe,0), ((default(offset,0)==0) ? 0 : startframe+offset-1) )
}
関数(2) # 簡略版
function AddRange(clip clip, int "startframe", int "offset")
{
return clip.Trim( startframe, -offset)
}
使用例 AddRange(537,13456) + AddRange(15792,8600) + AddRange(26191,14475)
AspectCrop
作 者 お前らのショボイAvisynthスクリプト貼ってくださいスレの230さん
説 明 アスペクト比を狂わせずにクロップする関数
書 式 AspectCrop(clip clip, int "left", int "top", int "right", int "bottom",
\int "minwidth", int "minheight", int "aspectx", int "aspecty",
\string "clrfmt", bool "interlaced", bool "cutOff", bool "debug")
引 数 left / 切り抜く左端の長さ。デフォルトは0。
top / 切り抜く上端の長さ。デフォルトは0。
right / 切り抜く右端の長さ。デフォルトは0。
bottom / 切り抜く下端の長さ。デフォルトは0。
minwidth / 最低限保持する幅。デフォルトは0。
minheight / 最低限保持する高さ。デフォルトは0。
aspectx, aspecty / アスペクト比の指定。縦横比がaspectx:aspectyになるように調整。デフォルトは711:485。
clrfmt / クロップする際、現在の色空間の制限以外にこの色空間の制限を加える。デフォルトは指定なし。
interlaced / trueで縦の切り抜き開始終了位置を偶数にする。YV12だと意味無し。デフォルトはtrue。
cutOff / trueで黒縁がなくなるまで切り抜き、falseで黒縁をギリギリまで削る。デフォルトはtrue。
debug / trueでクロップする際に使った引数などを表示。デフォルトはfalse。
関数 function AspectCrop(clip clip, int "left", int "top", int "right", int "bottom",
\int "minwidth", int "minheight", int "aspectx", int "aspecty",
\string "clrfmt", bool "interlaced", bool "cutoff", bool "debug")
{
left = default(left, 0)
top = default(top, 0)
right = Abs(default(right, 0))
bottom = Abs(default(bottom, 0))
minwidth = default(minwidth, 0)
minheight = default(minheight, 0)
aspectx = default(aspectx, 711)
aspecty = default(aspecty, 485)
clrfmt = default(clrfmt, "")
interlaced = default(interlaced, true)
cutoff = default(cutoff, true)
debug = default(debug, false)

unitx = clrfmt == "I420" ? 4 : ((clip.IsYV12 || clip.IsYUY2 || clrfmt == "YV12" || clrfmt == "YUY2") ? 2 : 1)
unity = (interlaced || clip.IsYV12 || clrfmt == "YV12") ? 2 : 1
rleft = Floor((left + (cutoff ? unitx - 1 : 0)) / unitx) * unitx
rtop = Floor((top + (cutoff ? unity - 1 : 0)) / unity) * unity
rright = Floor((right + (cutoff ? unitx - 1 : 0)) / unitx) * unitx
rbottom = Floor((bottom + (cutoff ? unity - 1 : 0)) / unity) * unity
w = clip.Width - left - right
h = clip.Height - top - bottom
wy = w * aspecty
hx = h * aspectx
amul = cutoff ? (wy < hx ? wy : hx) : (wy < hx ? hx : wy)
wy = minwidth * aspecty
hx = minheight * aspectx
amul = amul < wy ? wy : (amul < hx ? hx : amul)
wy = clip.Width * aspecty
hx = clip.Height * aspectx
amul = amul > wy ? wy : (amul > hx ? hx : amul)
rw = amul / aspecty
rh = amul / aspectx
rw = Floor((rw + (cutoff ? (((w - rw) > 3) ? 3 : w - rw) : 3)) / 4) * 4
rh = Floor((rh + ((cutoff && rh > h) ? 0 : 1)) / 2) * 2
rw = rw < minwidth ? minwidth : rw
rh = rh < minheight ? minheight : rh
rleft = Floor((rleft + (w - rw) / 2) / unitx) * unitx
rright = clip.Width - rw - rleft
rtop = Floor((rtop + (h - rh) / 2) / unity) * unity
rbottom = clip.Height - rh - rtop

clip = clip.Crop(rleft, rtop, rw, rh)
clip = debug ? clip.SubTitle("unitx : " + String(unitx), 10, 20) : clip
clip = debug ? clip.SubTitle("unity : " + String(unity), 10, 40) : clip
clip = debug ? clip.SubTitle("left : " + String(rleft), 10, 60) : clip
clip = debug ? clip.SubTitle("top : " + String(rtop), 10, 80) : clip
clip = debug ? clip.SubTitle("right : " + String(rright), 10, 100) : clip
clip = debug ? clip.SubTitle("bottom : " + String(rbottom), 10, 120) : clip
clip = debug ? clip.SubTitle("width : " + String(clip.Width) + "(" + String(Float(amul) / aspecty) + ")", 10, 140) : clip
clip = debug ? clip.SubTitle("height : " + String(clip.Height) + "(" + String(Float(amul) / aspectx) + ")", 10, 160) : clip
return clip
}
使用例 AspectCrop(8, 0, 8, 0)
AUF
作 者 にーやん
説 明 LoadAviUtlFilterPluginの記述を少し簡略化するだけの関数。※要warpsharp.dll, aufilters.avs
書 式 AUF(clip clip, string "filter")
引 数 filter / フィルタ
関 数 function AUF(clip clip, string "filter")
{
assert(clip.IsYUY2(), "YUY2じゃないとダメなのね_| ̄|○ ・・・ガックシ")
clip = Eval("clip.ConvertYUY2ToAviUtlYC()." + filter + ".ConvertAviUtlYCToYUY2()")
return clip
}
使用例 AUF("AU_waveletNR_G(2,75,75,75,75,75,75,50,50,50,50,50,50,200,100,0,false,false,false,false)")
AutoBob
作 者 にーやん
説 明 AutoDeint(warpsharp.dll)を利用して、Bob(60fps化)デインターレースする関数 その2。kernelbobを参考に作成。※要warpsharp.dll
書 式 AutoBob(clip clip)
引 数 -
関 数 function AutoBob(clip clip)
{
org_parity = clip.GetParity()
Assert(IsYUV(clip), "AutoBob: YUY2/YV12用")
c1 = clip.AutoDeint("")
c2 = clip.SeparateFields().Trim(1, 0).Weave.AutoDeint("")
bbb = Interleave(c1, c2)
bbb = org_parity ? bbb.AssumeFrameBased().ComplementParity() :
\ bbb.AssumeFrameBased()
return bbb
}
使用例 AutoBob()
bbb
作 者 AvisynthスレPart12の642さん
説 明 AutoDeint(warpsharp.dll)を利用して、Bob(60fps化)する。※要warpsharp.dll
書 式 bbb(clip clip)
引 数 -
関 数 function bbb(clip clip)
{
c1 = clip.AutoDeint("")
c2 = clip.ComplementParity().AutoDeint("")
clip = Interleave(c1,c2)
return clip
}
使用例 bbb()
BitrateCalc
作 者 qwerpoi
説 明 ビットレート計算用関数
書 式 BitrateCalc(clip c,float "target_size",float "audio_bitrate",string "container",float "bpp_threshold")
引 数 target_size / 出力ファイルサイズ(単位:MB,デフォルト700MB)
audio_bitrate / 音声部のビットレート(単位:KB,デフォルト128KB)
container / コンテナの種類(avi/ogm/mkv,デフォルトavi)
bpp_threshold / 1ピクセルあたりに割り当てるビットレートの閾値(デフォルト0.170)
関数 function BitrateCalc(clip c,float "target_size",float "audio_bitrate",string "container",float "bpp_threshold")
{
target_size = default(target_size,700) #MB
audio_bitrate = default(audio_bitrate,128) #kB/s
container = default(container,"avi")
bpp_threshold = default(bpp_threshold,0.170)
assert((container=="avi")||(container=="ogm")||(container=="mkv"), "Valid containers are avi, ogm, or mkv")
seconds = c.framecount/c.framerate
audiosize = (audio_bitrate/8.0)*(seconds/1024.0)
overhead = (container == "avi") ? (c.framecount)*(24+24)/(1024*1024+0.0) :
\ ((container == "ogm") ? (c.framecount)*(0.069)/(1024+0.0) :
\ (c.framecount)*(0.013)/(1024+0.0))
videosize = target_size-audiosize-overhead
targetbitrate = videosize*1024*8/seconds
bpp = (targetbitrate*1024)/(c.framerate*c.width*c.height+0.0)
f = c.Subtitle("Audio Size = "+String(round(audiosize))+" MB",last_frame=1)
f = f.Subtitle("Video Size = "+String(round(videosize))+" MB"+" ("+container+" overhead = "+String(round(overhead))+" MB)",last_frame=1,y=36)
f = f.Subtitle("Target Bitrate = "+String(round(targetbitrate))+" kB/s",last_frame=1,y=72)
f = f.Subtitle("Target Filesize = "+String(floor(videosize*1024))+" kB",last_frame=1,y=90)
f = bpp > bpp_threshold ? f.Subtitle("Bits Per Pixel = "+LeftStr(String(bpp),5),last_frame=1,y=108,text_color=$00FF00) :
\ f.Subtitle("Bits Per Pixel = "+LeftStr(String(bpp),5),last_frame=1,y=108,text_color=$FF0000)
return f
}
使用例 mpeg2source("D:\something.d2v")
LanczosResize(640,480)
BitrateCalc()
BlackenField
作 者 にーやん
説 明 特定のフィールドを黒(または他の色)で塗りつぶす。
書 式 BlackenField(clip clip, int "target", bool "bf_order", int "bf_color")
引 数 target / 塗りつぶすフィールドのあるフレーム番号
bf_order / 塗りつぶすフィールドの選択。true:偶数フィールド、false:奇数フィールド
bf_color / 塗りつぶす色(デフォルトは黒)
関 数 function BlackenField(clip clip, int "target", bool "bf_order", int "bf_color")
{
#//--- デフォルト値の設定 ---//
target = default(target, 0)
bf_order = default(bf_order, true)
bf_color = default(bf_color, $000000)
#//--- チェック ---//
org_parity = clip.GetParity()
Assert((target < clip.FrameCount()), "targetが総フレーム数より大きい")
#//--- メイン ---//
c1 = target < 2 ? clip.trim(0, -1) : clip.trim(0, target-1)
c2 = clip.Trim(target, -1)
c3 = clip.Trim(target+1, 0)
c2 = (bf_order && org_parity) || ((bf_order == false) && (org_parity == false)) ?
\ c2.SeparateFields().SelectOdd() : c2.SeparateFields().SelectEven()
bf = BlankClip(clip, length=1, height=clip.Height()/2, color=bf_color)
c2bf = (bf_order && org_parity) || ((bf_order == false) && (org_parity == false)) ?
\ Interleave(bf, c2) : Interleave(c2, bf)
c2bf = org_parity ? c2bf.AssumeFieldBased().ComplementParity().Weave() :
\ c2bf.AssumeFieldBased().Weave()
c = (target == 0) ? c2bf + c3 : (target == clip.FrameCount()-1) ? c1 + c2bf :
\ c1 + c2bf + c3
c = AudioDub(c,clip)
return c
}
使用例 BlackenField(0,true) #0フレームの偶数フィールドを黒で塗りつぶす
CopyField
作 者 -(AvisynthスレPart13より)
説 明 あるフィールドに別のフィールドをコピーする。
書 式 CopyField(clip clip, int "field_No", int "copyfield_No")
引 数 field_No / コピー先フィールドNo
Copyfield_No / コピー元フィールドNo(省略時は同フレーム内の別フィールドをコピーする)
関 数 function CopyField(clip clip, int "field_No", int "copyfield_No")
{
copyfield_No = default(copyfield_No, (field_No/2)*2+1-(field_No%2))
clip = clip.separatefields
clip = clip.freezeframe(field_No, field_No, copyfield_No)
clip = clip.weave
return clip
}
使用例 CopyField2(10*2+1,10*2) #CopyField2(21,20)と同じ。21番目のフィールドに20番目のフィールドをコピー
Crop2
作 者 にーやん
説 明 AviUtl98の縁塗りつぶしライクな関数Clippingにエラーチェックを追加。※AviSynth2.07以降のみ。
書 式 Crop2(clip clip, int "top", int "bottom", int "left", int "right", bool "tenchi", bool "sayuu", bool "interlace")
引 数 top / 上
bottom / 下
left / 左
right / 右
tenchi / true:上下を塗りつぶし,false上下を塗りつぶさない
sayuu / true:左右を塗りつぶし,false:左右を塗りつぶさない
interlace / true:インターレース,false:ノンインターレース(省略時、false)
関 数 function Crop2(clip clip, int "top", int "bottom", int "left", int "right",
\ bool "tenchi", bool "sayuu", bool "interlace")
{
#//---- 初期設定 ----//
tenchi = default(tenchi, false)
sayuu = default(sayuu, false)
interlace = default(interlace, false)
color_space = clip.IsYUY2() ? "YUY2" : clip.IsRGB() ||
\ clip.IsRGB24() || clip.IsRGB32() ? "RGB" : "YV12"
add_top = (top+bottom)%2 == 1 && top > bottom ? (top+bottom+1)/2 :
\ (top+bottom)%2 == 1 && top < bottom ? (top+bottom+1)/2-1 : (top+bottom)/2
add_bottom = (top+bottom)%2 == 1 && top > bottom ? (top+bottom+1)/2-1 :
\ (top+bottom)%2 == 1 && top < bottom ? (top+bottom+1)/2 : (top+bottom)/2
add_left = (left+right)%2 == 1 && left > right ? (left+right+1)/2 :
\ (left+right)%2 == 1 && left < right ? (left+right+1)/2-1 : (left+right)/2
add_right = (left+right)%2 == 1 && left > right ? (left+right+1)/2-1 :
\ (left+right)%2 == 1 && left < right ? (left+right+1)/2 : (left+right)/2
#//---- エラーチェック ----//
check_sayuu = ((color_space == "YUY2" || color_space == "YV12") &&
\ (left%2 == 0 && right%2 == 0)) || (color_space == "RGB")
assert(check_sayuu, "左右は2の倍数でクロップしてください。")
check_goukei = ((color_space == "YUY2" || color_space == "YV12") &&
\ ((left+right)%4 == 0)) || (color_space == "RGB")
assert(check_goukei, "解像度が4の倍数になるようにクロップしてください。")
check_tenchi = (color_space == "YV12") && (((interlace == false) && (top%2 == 0) &&
\ (bottom%2 == 0)) || ((interlace == true) && (top%4 == 0) && (bottom%4 == 0) &&
\ ((top >= 4) || (top == 0)) && ((bottom >= 4) || (bottom == 0)))) ||
\ ((color_space == "YUY2") && (interlace ==false)) || ((color_space == "YUY2") &&
\ (interlace ==true) && ((top%2 == 0) || (top == 0)) && ((bottom%2 == 0) ||
\ (bottom == 0))) || (color_space == "RGB")
pixel = ((color_space == "YUY2") && (interlace == true)) || ((color_space == "YV12")
\ && (interlace == false)) ? "2" : "4"
assert(check_tenchi, "上下は" + pixel + "の倍数でクロップしてください。")
#//---- Crop & AddBorders ----//
clip = clip.Crop(left, top, -right, -bottom)
clip = tenchi == true && sayuu == false ? clip.Addborders(0,add_top,0,add_bottom) :
\ tenchi == false && sayuu == true ? clip.Addborders(add_left,0,add_right,0) :
\ tenchi == true && sayuu == true ? clip.Addborders(add_left,add_top,add_right,add_bottom) : clip
return clip
}
使用例 Crop2(0,4,8,8,true,true) #上0(クロップせず)、下4クロップ、左右8ずつクロップ、上下左右塗りつぶし
DebugFields
作 者 にーやん
説 明 トップ・ボトムフィールドフィールド表示関数。mopu氏作トップ・ボトムフィールドフィールド表示フィルタ(AviUtl用)をヒントに作成。詳しくは「トップ・ボトムフィールド表示関数(DebugFields)」のページを参照。
書 式 DebugFields(clip clip, string "filter", int "matrix", int "x", bool "enlarge")
引 数 filter / フィルタ
matrix / 表示方法の切り替え(0〜5)
x / 表示位置の調整(0〜画像の幅の1/2まで)
関 数 function DebugFields(clip clip, string "filter", int "matrix", int "x")
{
#//--- デフォルト値の設定 ---//
filter = default(filter,"")
matrix = default(matrix, 0)
x = default(x, 0)
font = "MS P Gothic"
fcolor = $ffffff
size = 16
tff = GetParity(clip)
width = Width(clip)
height = Height(clip)
#//--- エラーチェック ---//
assert(x%2==0,"xの値は2の倍数にしてください。")
assert(x<=width/2,"xの値は画像の幅の2分の1以下にしてください。")
#//--- メイン ---//
c1 = clip.SeparateFields()
e1 = tff ? SelectEven(c1) : SelectOdd(c1)
o1 = tff ? SelectOdd(c1) : SelectEven(c1)
e3 = Crop(e1,x,0,width/2,height/2)
o3 = Crop(o1,x,0,width/2,height/2)
c2 = (filter == "") ? clip : Eval("clip." + filter)
c3 = c2.SeparateFields()
e2 = tff ? SelectEven(c3) : SelectOdd(c3)
o2 = tff ? SelectOdd(c3) : SelectEven(c3)
e4 = Crop(e2,x,0,width/2,height/2)
o4 = Crop(o2,x,0,width/2,height/2)
e1 = Subtitle(e1,"フィルタ適用前(トップフィールド)",font=font,size=size,text_color=fcolor)
e2 = Subtitle(e2,"フィルタ適用後(トップフィールド)",font=font,size=size,text_color=fcolor)
e3 = Subtitle(e3,"フィルタ適用前(トップフィールド)",font=font,size=size,text_color=fcolor)
e4 = Subtitle(e4,"フィルタ適用後(トップフィールド)",font=font,size=size,text_color=fcolor)
o1 = Subtitle(o1,"フィルタ適用前(ボトムフィールド)",font=font,size=size,text_color=fcolor)
o2 = Subtitle(o2,"フィルタ適用後(ボトムフィールド)",font=font,size=size,text_color=fcolor)
o3 = Subtitle(o3,"フィルタ適用前(ボトムフィールド)",font=font,size=size,text_color=fcolor)
o4 = Subtitle(o4,"フィルタ適用後(ボトムフィールド)",font=font,size=size,text_color=fcolor)
f1 = Crop(clip,x,0,width/2,height)
f1 = Subtitle(f1,"フィルタ適用前(フレーム)",font=font,size=size,text_color=fcolor)
f2 = Crop(c2,x,0,width/2,height)
f2 = Subtitle(f2,"フィルタ適用後(フレーム)",font=font,size=size,text_color=fcolor)
clip = (matrix == 1) ? StackHorizontal(f1,StackVertical(e3,o3)) :
\ (matrix == 2) ? StackHorizontal(f1,f2) :
\ (matrix == 3) ? StackVertical(e1,e2) :
\ (matrix == 4) ? StackVertical(o1,o2) :
\ (matrix == 5) ? StackHorizontal(StackVertical(e3,o3),StackVertical(e4,o4)) :
\ StackHorizontal(f2,StackVertical(e4,o4))
return clip
}
使用例 DebugFields("KenKunNR(256,3,40)")
EasyClipping
作 者 にーやん
説 明 Cropのパラメータを上下左右の順に変更した(並べ替えた)だけの関数。
書 式 EasyClipping(clip clip, int "top", int "bottom", int "left", int "right")
引 数 top / 上
bottom / 下
left / 左
right / 右
関 数 function EasyClipping(clip clip, int "top", int "bottom", int "left", int "right")
{
clip = clip.Crop(left, top, clip.width-(left+right), clip.height-(top+bottom))
return clip
}
使用例 EasyClipping(0,0,8,8) #上下0(クロップせず)、左右8ずつクロップ
FadeIn2Ex
作 者 kiraru2002
説 明 FadeIn2機能拡張版(色指定可)
書 式 FadeIn2Ex(clip clip, int "n", int "color", int "addframes")
引 数 n / フェード対象フレーム数
color / 色指定(16進数)
addframes / 追加するフレーム数
関 数 function FadeIn2Ex(clip clip, int "n", int "color", int "addframes") # "addframes" valid in ver.2.0
{
color=default(color,$000000)
n=default(n,round(clip.framerate))
n=(clip.framecount>n)?n:clip.framecount
addframes=default(addframes,0)
newclip=(addframes>0)?clip.Loop(addframes+1,clip.framecount-1,clip.framecount-1):clip
newclip=(addframes>0)?clip.Loop(addframes+1,0,0):clip
newclip=newclip.DelayAudio(addframes/newclip.framerate)
newclip=(addframes>1)?newclip.trim(0,addframes-1).Amplify(0)+newclip.trim(addframes,0):newclip
return Dissolve(newclip.BlankClip(n+2,color=color),newclip,n)
}
使用例 FadeIn2Ex(20,$ffffff,0)
FadeOut2Ex
作 者 kiraru2002
説 明 FadeOut2機能拡張版(色指定可)
書 式 FadeOut2Ex(clip clip, int "n", int "color", int "addframes")
引 数 n / フェード対象フレーム数
color / 色指定(16進数)
addframes / 追加するフレーム数
関 数 function FadeOut2Ex(clip clip, int "n", int "color", int "addframes") # "addframes" valid in ver.2.0
{
color=default(color,$000000)
n=default(n,round(clip.framerate))
n=(clip.framecount>n)?n:clip.framecount
addframes=default(addframes,0)
newclip=(addframes>0)?clip.Loop(addframes+1,clip.framecount-1,clip.framecount-1):clip
return Dissolve(newclip,newclip.BlankClip(n+2,color=color),n)
}
使用例 FadeOut2Ex(20,$ffffff,0)
FilterRange
作 者 minamina(オリジナル) / にーやん(改造版)
説 明 指定範囲にフィルターをかける関数の改造版。オリジナル版については、nullinfoさんを参照。
書 式 FilterRange(clip clip, int "start", int "end", string "filter")
引 数 start / 開始フレーム
end / 終了フレーム
filter / フィルタ
関 数 function FilterRange(clip clip, int "start", int "end", string "filter")
{
final_frame = clip.FrameCount()-1
Assert(end <= final_frame, "end が最終フレームよりも大きい")
c1 = start < 2 ? clip.trim(0, -1) : clip.trim(0, start - 1)
c2 = Eval("clip.trim(start, end)." + filter)
c3 = clip.trim(end + 1, 0)
c = start == 0 ? c2 : c1 + c2
c = ((end == 0) || (end == final_frame)) ? c : c + c3
return c
}
使用例 FilterRange(1234,5678,"KenKunNR(256,2,24)")
FPAUF
作 者 にーやん
説 明 フィールド別処理未対応のAviUtlフィルタをフィールド別にフィルタ処理するようにする。※要warpsharp.dll, aufilters.avs。
書 式 FPAUF(clip clip, string "filter")
引 数 filter / フィルタ
関 数 function FPAUF(clip clip, string "filter")
{
assert(clip.IsYUY2(), "YUY2じゃないとダメぽ(´Д`;)")
clip = clip.SeparateFields()
even = clip.SelectEven()
odd = clip.SelectOdd()
even = Eval("even.ConvertYUY2ToAviUtlYC()." + filter + ".ConvertAviUtlYCToYUY2()")
odd = Eval("odd.ConvertYUY2ToAviUtlYC()." + filter + ".ConvertAviUtlYCToYUY2()")
clip = InterLeave(even, odd)
clip = clip.Weave()
return clip
}
使用例 FPAUF("AU_waveletNR_G(2,75,75,75,75,75,75,50,50,50,50,50,50,200,100,0,false,false,false,false)")
FPDust
作 者 にーやん
説 明 Dust専用フィールド別ノイズ除去関数。※AviSynth2.5.4以降のみ対応。
書 式 FPDust(clip clip, string "dust_filter", int "strength", string "mode", string "dust_dir")
引 数 dust_filter / フィルタ。"FearyDust","SpaceDust","PixieDust","GoldDust"のいずれか。
strength / Dustのlimit
mode / Dustのoutput
dust_dir / DustV5.dllのコピーまでのパス。
※通常のプラグインディレクトリ以外の場所にもう一つコピーしておく。
apply / フィルタの適用度。0-1までの小数で指定。1で100%。省略可。
関 数 function FPDust(clip clip, string "dust_filter", int "strength", string "mode",
\ string "dust_dir", float "apply")
{
#//--- YV12チェック ---//
color_space = clip.IsYUY2() ? "YUY2" : clip.IsRGB24() ? "RGB24" :
\ clip.IsRGB32() ? "RGB32" : "YV12"
clip = (color_space == "YV12") ? clip.ConvertToYUY2(interlaced = true) : clip

#//--- デフォルト値の設定 ---//
dust_filter = default(dust_filter, "FaeryDust")
strength = (dust_filter == "PixieDust") ? default(strength, 5) :
\ (dust_filter == "GoldDust") ? default(strength, 8) : default(strength, 2)
mode = (color_space == "YV12") ? default(mode, "YUY2") :
\ default(mode, color_space)
dust_dir = default(dust_dir, "None")
Assert(dust_dir != "None", "dust_dirを指定してください。")
apply = default(apply, -1)

#//--- Odd用Dust5関数 ---//
function Dust5(clip clip, string "dust_filter", int "strength",
\ string "mode", string "dust_dir")
{
LoadPlugin(dust_dir + "DustV5.dll")
clip = Eval("clip." + dust_filter + "(strength, mode)")
return clip
}

#//--- メイン ---//
base_clip = clip.Trim(0,FrameCount(clip)-1)
field_base = base_clip.SeparateFields()
even = field_base.SelectEven()
odd = field_base.SelectOdd()
even = even + even.Trim(FrameCount(even)-1,-1)
odd = odd + odd.Trim(FrameCount(odd)-1,-1)
even = Eval("even."+ dust_filter + "(strength, mode)")
odd = odd.Dust5(dust_filter, strength, mode, dust_dir)
filtered = Interleave(even, odd)
filtered = filtered.Weave()
filtered = filtered.Trim(0,FrameCount(base_clip)-2)

#//--- フィルタ適用度の調整 ---//
applied = (apply < 0) ? filtered : OverLay(clip, filtered, opacity=apply)

#//--- YV12だった場合のみ元に戻す ---//
return_clip = (color_space == "YV12") ? applied.ConvertToYV12(interlaced = true) :
\ applied

#//--- return文 ---//
return return_clip
}
使用例1 FPDust("FaeryDust",2,"YUY2","C:\AviSynth\DLL\")
使用例2 FPDust("FaeryDust", dust_dir="C:\AviSynth\DLL\") #dust_dirは必須。
使用例3 FPDust(dust_dir="C:\AviSynth\DLL\", apply=0.75)
FPFilter
作 者 -(関数化:にーやん)
説 明 フィールド分解してフィルタ処理する。フィールド単位でフィルタリングのページを参照。
書 式 FPFilter(clip clip, string "filter")
引 数 filter / フィルタ
関 数 function FPFilter(clip clip, string "filter")
{
clip = clip.SeparateFields
clip = Eval("clip." + filter)
clip = clip.Weave
return clip
}
使用例 FPFilter("KenKunNR(256,2,6)")
FPNR
作 者 -(関数化:にーやん)
説 明 フィールド別にフィルタ処理する。フィールド単位でフィルタリングのページを参照。
書 式 FPNR(clip clip, string "filter")
引 数 filter / フィルタ
関 数 function FPNR(clip clip, string "filter")
{
clip = clip.SeparateFields
Top = clip.SelectEven
Bottom = clip.SelectOdd
Top = Eval("Top." + filter)
Bottom = Eval("Bottom." + filter)
clip = Interleave(Top, Bottom)
clip = clip.Weave
return clip
}
使用例 FPNR("KenKunNRT(256,2,20)")
FPResize
作 者 にーやん
説 明 Bobを利用してインターレースを保持したままリサイズする。
書 式 FPResize(clip clip, string "filter", string "bob_filter")
引 数 resize_filter / 使用したいフィルタの指定。
bob_filter / 使用したいBobフィルタの指定(省略時、内蔵Bob使用)。
関 数 function FPResize(clip clip, string "resize_filter", string "bob_filter")
{
org_parity = clip.GetParity()
bob_filter = default(bob_filter, "Bob(b=0, c=0.5)")
clip = Eval("clip." + bob_filter)
clip = Eval("clip." + resize_filter)
clip = org_parity ? clip.AssumeTFF() : clip.AssumeBFF()
clip = clip.SeparateFields()
clip = clip.SelectEvery(4, 0, 3)
clip = clip.Weave()
return clip
}
使用例 FPResize("BilinearResize(512,384)", "bbb()")
FPSAdjust
作 者 にーやん
説 明 音声の長さに合わせてFPS調整し、元のフレームレートにFPS変換する。※テスト版
書 式 FPSAdjust(clip clip, bool "method", bool "debug")
引 数 method / true:ChangeFPSでFPS変換、false:ConvertFPSでFPS変換。
debug / true:デバッグモード、false:通常モード(デフォルト)
関 数 function FPSAdjust(clip clip, bool "method", bool "debug")
{
#//--- チェック ---//
Assert(clip.IsYUY2(), "YUY2 Only")
#//--- デフォルト値の設定 ---//
method = default(method, true)
debug = default(debug, false)
#//--- フレームレート等の取得 ---//
a_length = Float(clip.AudioLength())
a_rate = clip.AudioRate()
v_framecount = clip.FrameCount()
v_framerate = clip.FrameRate()
v_time = v_framecount/v_framerate
a_time = a_length/a_rate
diff_time = a_time - v_time
#//--- メイン ---//
clip = clip.AssumeFPS(v_framecount/a_time)
adjusted_framerate = clip.FrameRate()
clip = method ? clip.ChangeFPS(v_framerate) : clip.ConvertFPS(v_framerate)
new_framerate = clip.FrameRate()
new_framecount = clip.FrameCount()
#//--- デバッグモード ---//
debug_clip = clip.Subtitle(y=18,"Video Length(sec) : " + String(v_time))
debug_clip = debug_clip.Subtitle(y=36,"Audio Length(sec) : " + String(a_time))
debug_clip = debug_clip.Subtitle(y=54,"Difference of Time(sec) : " + String(diff_time))
debug_clip = debug_clip.Subtitle(y=72,"Original FrameRate : " + String(v_framerate))
debug_clip = debug_clip.Subtitle(y=90,"Adjusted FrameRate : " + String(adjusted_framerate))
debug_clip = debug_clip.Subtitle(y=108,"OutPut FrameRate : " + String(new_framerate))
debug_clip = debug_clip.Subtitle(y=126,"Original FrameCount : " + String(v_framecount))
debug_clip = debug_clip.Subtitle(y=144,"OutPut FrameCount : " + String(new_framecount))
#//--- クリップを戻す ---//
clip = (debug == true) ? debug_clip : clip
return clip
}
使用例 FPSAdjust() #ChangeFPSでFPS変換
HScrollTitle
作 者 にーやん
説 明 テロップを右から左へ流す。VScrollTitleを参考に作成。
書 式 HScrollTitle(clip clip, int "sf", float "time", string "text", string "font", int "size", int "fc", int "hc")
引 数 sf / テロップの開始フレーム
time / テロップが流れるのに要する時間
text / テロップ(表示したい文字)
font / フォント
size / フォントの大きさ
fc / フォントの色
hc / フォントの周りを縁取る色
関 数 function HScrollTitle(clip clip, int "sf", float "time", string "text",
\ string "font", int "size", int "fc", int "hc")
{
font = default(font,"MS Gothic") ef = sf + Int(time * clip.FrameRate)
clip = clip.Animate(sf, ef, "Subtitle",
\ text,clip.width,clip.height-Int(clip.height/10),sf,ef,font,size,fc,hc,5,0,
\ text,0,clip.height-Int(clip.height/10),sf,ef,font,size,fc,hc,5,0)
return clip
}
使用例 HScrollTitle(0, 1.5, "本日は晴天なり。", "MS P ゴシック", 24, $ffffff, $000000)
#0フレームから1.5秒かけて右から左へテロップを流す。
info_modoki
作 者 Kiraru2002
説 明 AviSynth2.0/2.5両用Infoもどき。
書 式 info_modoki(clip clip)
引 数 -
関 数 function info_modoki(clip clip) {
_size = "width: " + string(clip.width) + " height:" + string(clip.height)
_frame = string(clip.framecount) + " frames " + string(clip.framerate) + " fps"
time = clip.framecount / clip.framerate
hours = int(time/3600)
minutes = int(time/60)-(hours*60)
seconds = time-hours*60*60-minutes*60
_length = "time: " + string(hours) + ":" + ((minutes<10)? "0"+string(minutes) : string(minutes))
\ + ":" + ((seconds<10)? "0"+string(seconds) : string(seconds))
_colorspace = clip.IsYUY2() ? "YUY2" : clip.IsRGB32() ? "RGB32" : clip.IsRGB24() ? "RGB24" : "UnKnown"
_colorspace = ((VersionNumber>=2.5) && (_colorspace=="Unknown")) ? "YV12" : _colorspace
_parity = "field order:" + (clip.GetParity() ? "TFF" : "BFF")
_audiobits =
\ ((VersionNumber<2.5) ? string(clip.AudioBits)+" bit" : string(clip.AudioBits() * 8))+" bit"
_audiochannels = (clip.AudioChannels()==2) ? " stereo" : " mono"
_audiorate = string(clip.AudioRate) + "Hz"
_audioLength = string(clip.AudioLength) + " samples"
clip = clip.subtitle( VersionString + " VersionNo:" + string(VersionNumber) )
clip = clip.subtitle("ColorSpace: " + _colorspace, y=32)
clip = clip.subtitle(_size, y=48)
clip = clip.subtitle(_frame, y=64)
clip = clip.subtitle(_length, y=80)
clip = clip.subtitle(_parity, y=96)
clip = (clip.AudioLength()==0) ? clip.subtitle("No Audio", y=112)
\ : clip.subtitle(_audiobits+" "+_audiochannels+" "+_audiorate+" "+_audiolength, y=112)
return clip
}
使用例 info_modoki()
ProduceClip
作 者 にーやん
説 明 同一フォルダにある同一名のビデオクリップとオーディオクリップを読み込んで合成する。※AviSynth2.0.7以降のみ対応。
書 式 ProduceClip(string "video_name")
引 数 video_name / ビデオクリップの名前。拡張子まで記述すること。
関 数 function ProduceClip(string "video_name")
{
dot_position = FindStr(video_name, ".")
audio_name = LeftStr(video_name, dot_position)
clip = (RightStr(video_name, 3) == "d2v") ?
\ AudioDub(MPEG2Source(video_name),
\ WavSource(audio_name + "wav")) :
\ (RightStr(video_name, 3) == "avi") ?
\ AudioDub(AVISource(video_name, audio = false),
\ WavSource(audio_name + "wav")) :
\ AudioDub(MPEG2VIDEO(video_name),
\ WavSource(audio_name + "wav"))
return clip
}
使用例 ProduceClip("Source.d2v")
ShiftField
作 者 にーやん
説 明 フィールドを1ライン前にずらして、フィールドオーダーを反転させる。
書 式 ShiftField(clip clip, int "target")
引 数 target / 0:偶数プフィールドをずらす,1:奇数フィールドをずらす,2:SwapFields。省略時、0。
関 数 function ShiftField(clip clip, int "target")
{
function ShiftFieldT(clip clip)
{
clip = clip.SeparateFields()
Top = clip.SelectEven
Bottom = clip.SelectOdd
Top = Top.DeleteFrame(0)
clip = Interleave(Top,Bottom)
clip = clip.Weave
return clip
}
function ShiftFieldB(clip clip)
{
clip = clip.SeparateFields()
Top = clip.SelectEven
Bottom = clip.SelectOdd
Bottom = Bottom.DeleteFrame(0)
clip = Interleave(Top,Bottom)
clip = clip.Weave
return clip
}
target = default( target, 0 )
clip = target == 1 ? clip.ShiftFieldB() :
\ target == 2 ? clip.SwapFields() : clip.ShiftFieldT()
return clip
}
使用例 ShiftField() #偶数フィールドをずらす
最終更新日 2004年10月19日