お前らのショボイAvisynthスクリプト貼ってくださいpart2

このエントリーをはてなブックマークに追加
38名無しさん@編集中
問題ないようなんで貼ってみる

function inittimecode ( clip c, string "filename" ) {
global timecode_filename = default( filename, "default-timecodes.txt" )
global sourceclip = c
global prevframe = -1
global tc_implicit = false
WriteFileStart( BlankClip(length=0), timecode_filename, """ "# timecode format v1"+chr(10)+"Assume "+string(sourceclip.framerate) """ )
}

function tcimplicit ( int a, int b, string "filter", bool "avg" ) {
global tc_implicit_filter = default( filter, "noop()" )
global tc_implicit_avg = default( avg, false )
global tc_implicit = true
global tc_implicit_st = a
global tc_implicit_ed = b
}

global a24d = """Auto24FPS( drop=false,mode="blend" )"""
global it = "IT( diMode=0 )"+a24d
global a24 = """Auto24FPS( mode="blend" )"""
global a602 = "DoubleWeave().a60224()"
global pd = "DoubleWeave().Pulldown( 1,3 )"
global td = "TDeint( mode=1 )"
global bd = """AutoDeint( "blend" )"""
global tf = "TFM().TDecimate()"+a24d
global ed = "SeparateFields() EEDI2(field=-2) merge(SelectEven(),SelectOdd())"
39名無しさん@編集中:2006/11/25(土) 10:00:15 ID:oQBPEXFf
function tc ( int a, int b, string "filter", bool "avg", bool "ignore" ) {
tc_implicit && (a >= tc_implicit_st) && (a <= tc_implicit_ed) && (tc_implicit_st != a) ? \
tc_main( tc_implicit_st,a-1,tc_implicit_filter,tc_implicit_avg ) : nop()

global tc_implicit_st = tc_implicit ? b+1 : 0
tc_main( a,b,filter,avg,ignore )

return last
}

function tc_main ( int a, int b, string "filter", bool "avg", bool "ignore" ) {
init = prevframe < 0 ? true : false
global prevframe = init ? a-1 : prevframe

ignore = default( ignore, false )
avg = default( avg, false )
ignore ? nop() : Assert( prevframe+1 == a, "tc: framenumber no much, "+string(a)+" - "+string(b) )
global prevframe = b

filter = default( filter, "noop()" )
orig = sourceclip.trim( a,b )
proc = eval( "orig."+filter )
proc.framecount > 1 && (avg ? false:true) ? \
maketimecode( init ? BlankClip(length=0) : cur, orig, proc ) : \
maketimecode2( init ? BlankClip(length=0) : cur, orig, proc )

global cur = init ? proc.AssumeFPS( sourceclip.framerate ) : cur + proc.AssumeFPS( sourceclip.framerate )

global audiosource = init ? orig : audiosource + orig
return sourceclip.HasAudio() ? AudioDubEx( proc,audiosource ) : proc
}
40名無しさん@編集中:2006/11/25(土) 10:00:36 ID:oQBPEXFf
function tcdraw () {
tc_implicit && (tc_implicit_st <= tc_implicit_ed) ? \
tc_main( tc_implicit_st,tc_implicit_ed,tc_implicit_filter,tc_implicit_avg ) \
: nop()

global tc_implicit = false
return sourceclip.HasAudio() ? AudioDubEx( cur,audiosource ) : cur
}

function noop ( clip c ) { return c }

function maketimecode (clip base, clip orig, clip ivtc) {
fps = ivtc.framerate
section = base.framecount + ivtc.framecount-2
fraction = fracivtc( orig, ivtc )
tc = string(base.framecount) + "," + string(section) + "," + string(fps) + chr(10) + string(section+1) + "," + string(section+1) + "," + string(1000 / (1000/fps + fraction))
WriteFileStart( orig, timecode_filename, "tc", append=true )
}

function fracivtc ( clip orig, clip ivtc ) {
originaltime = 1000 / orig.framerate * orig.framecount
ivtctime = 1000 / ivtc.framerate * ivtc.framecount
return originaltime - ivtctime
}
41名無しさん@編集中:2006/11/25(土) 10:00:58 ID:oQBPEXFf
function maketimecode2 (clip base, clip orig, clip ivtc) {
fps = ivtcfps( orig, ivtc )
tc = string(base.framecount) + "," + string(base.framecount+ivtc.framecount-1) + "," + string(fps)
WriteFileStart( orig, timecode_filename, "tc", append=true )
}

function ivtcfps ( clip orig, clip ivtc ) {
originaltime = 1000 / orig.framerate * orig.framecount
return 1000 / (originaltime / ivtc.framecount)
}

ここまで
ユーザ側で使うのは inittimecode, tc, tcimplicit, tcdraw の4つ

inittimecode ( clip c, string "filename" )
c ソースクリップ.このクリップが操作対象になる
filename 出力されるタイムコードファイル名

tc ( int a, int b, string "filter", bool "avg", bool "ignore" )
a 開始フレーム番号
b 終了フレーム番号
filter 区間(a から b)に掛けるフィルタ.主にIVTC
フィルタ後のフレーム数に合わせたタイムコードが出力されるので,ある程度自由にフレーム数を変えられる
"DoubleWeave().SelectEvery( 10, 0,5 )" とか,動かない場面なら "trim(0,-1)" でもいい
フィルタ後のクリップは勝手に保存される

tcdraw ()
tc() で保存してたクリップを引き出す.とりあえず最後に置く

42名無しさん@編集中:2006/11/25(土) 10:01:17 ID:oQBPEXFf
使用例
--
prefix="foo"
episode="1"
file=prefix+".d2v"
wav = prefix+" T01 48K 16bit 2ch.wav"

v = mpeg2source( file ).AssumeTFF()
a = WavSource( wav )
AudioDub( v,a )
inittimecode( prefix+episode+"-timecodes.txt" )
tc( 0,432,tf )
tc( 433,976,td )
tc( 977,1324,tf )
tc( 1325,1403,pd )
tc( 1404,1500,tf )
tcdraw()

crop( 8,0,-8,0 )
KenKunNRT()
return last
--

tcimplicit を使うと上のはこう書ける
--
inittimecode( prefix+episode+"-timecodes.txt" )
tcimplicit( 0,1500,tf )
tc( 433,976,td )
tc( 1325,1403,pd )
tcdraw()
--
43名無しさん@編集中:2006/11/25(土) 13:06:04 ID:aR3nnS3S
長いって言うから100レスくらい使うのかと思ってたのに