# デフォルト設定値 global WIDTH = 1280 global HEIGHT = 720 global FPS = 24 global VERSION="" global PREVIEW=false global AUDIO_DELAY=0.0 SetMemoryMax(3072) SetFilterMtMode("LanczosResize", 2) SetFilterMtMode("Overlay", 2) SetFilterMTMode("AviSource",3) SetFilterMTMode("LWLibavAudioSource",3) SetFilterMTMode("LWLibavVideoSource",3) # 設定ファイルからロード if(Exist(ScriptDir() + "config.avs")) { Import(ScriptDir() + "config.avs") } if(Exist(ScriptDir() + "version.avs")) { Import(ScriptDir() + "version.avs") } # 関数 function AdjustLength(clip clip) { alen = clip.AudioDuration vlen = 1.0 * clip.FrameCount / clip.FrameRate video = clip.KillAudio() audio = clip.KillVideo() if (vlen > alen) { d = Int((vlen - alen) * video.FrameRate) audio = audio + clip.BlankClip(length=d).KillVideo() } if (vlen < alen) { d = Int((alen - vlen) * video.FrameRate) video = video + video.BlankClip(length=d) } return AudioDub(video, audio) } function TimeCode(clip clip) { bg_color = color_black bg = clip.BlankClip(width = Int(710 * (WIDTH / 1920.0)), height = Int(75 * (HEIGHT / 1080.0)), color=bg_color).ConvertToRGB24().ConvertToRGB32() clip = clip.layer(bg, op="mul", x = Int(clip.Width / 2 - bg.Width / 2), y = Int(70 * (HEIGHT / 1080.0)), level=100) start=1 end=clip.FrameCount clip = clip.Animate(start, end, "_MainTimeCode", start, end) return clip } function BlankClipStandard(int len) { return BlankClip(length= len, fps = FPS, width = WIDTH, height = HEIGHT, pixel_type="RGB32").KillAudio() } function LoadAVI(string filepath) { AVISource(filepath) KillAudio() LanczosResize(WIDTH, HEIGHT) if (PREVIEW) { Subtitle(filepath, align=1, x=5, y=20, size=20) start=1 end=last.FrameCount x = WIDTH - 100 y = 20 size = 20 Animate(start, end, "_SubTimeCode", start, x, y, size, end, x, y, size) } return last } function ShowSceneTimeCodeIfPreview(clip clip, string scene) { clip if (PREVIEW) { Subtitle(scene, align=1, x=5, y=HEIGHT - 5, size = 20) start=1 end=clip.FrameCount x = WIDTH - 100 y = HEIGHT - 5 size = 20 Animate(start, end, "_SubTimeCode", start, x, y, size, end, x, y, size) } return last } function _MainTimeCode(clip clip, int index) { index = index - 1 #ゼロベースに変換 current_time = 1.0 * index / FPS h = Int(current_time / 3600) + 1 #1Hスタート m = Int(Int(current_time) % 3600 / 60) s = Int(Int(current_time) % 60) fr = index % 24 timecode = String(FPS, "%0.2f") + "fps/TCR " + String(h, "%02.0f") + ":" + String(m, "%02.0f") + ":" + String(s, "%02.0f") + ":" + String(fr, "%02.0f") size = Int(70 * (HEIGHT / 1080.0)) blank = clip.BlankClip(color=$000000, length=clip.FrameCount, width = WIDTH, height=75, pixel_type="RGB32") text = blank.Subtitle(timecode, x=-1, y=0, size=size, font="Migu 1P", text_color=color_white, halo_color=$FF000000, align=8) return Layer(clip, text.Mask(text), x=0, y=Int(70 * (HEIGHT / 1080.0)) ) } function _SubTimeCode(clip clip, int index, int x, int y, int size) { index = index - 1 #ゼロベースに変換 current_time = 1.0 * index / FPS h = Int(current_time / 3600) m = Int(Int(current_time) % 3600 / 60) s = Int(Int(current_time) % 60) fr = index % 24 margin = 5 timecode = String(h, "%02.0f") + ":" + String(m, "%02.0f") + ":" + String(s, "%02.0f") + ":" + String(fr, "%02.0f") blank = clip.BlankClip(color=$000000, length=clip.FrameCount, width = size * 11 + margin * 2, height=size + margin * 2, pixel_type="RGB32") mask = blank.Subtitle(timecode, align = 7, x = margin, y = margin, size = size, text_color=$FFFFFF, halo_color=$FFFFFF) text = blank.Subtitle(timecode, align = 7, x = margin, y = margin, size = size) return Layer(clip, text.Mask(mask), x = x - margin, y = y - size - margin) }