# デフォルト設定値 global WIDTH = 1280 global HEIGHT = 720 global FPS = 24 global VERSION="" global PREVIEW=false SetMemoryMax(3072) SetFilterMtMode("LanczosResize", 2) SetFilterMtMode("Overlay", 2) # 設定ファイルからロード 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, int "x_offset", int "y_offset", int "bg_color") { x_offset = Default(x_offset, 0) y_offset = Default(y_offset, 0) bg_color = Default(bg_color, color_black) # 表示位置 x = Int(WIDTH / 2 + x_offset) y = Int(70 * (HEIGHT / 1080.0) + y_offset) size = Int(70 * (HEIGHT / 1080.0)) 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(x - bg.width / 2), y = Int(70 * (HEIGHT / 1080.0)), level=100) clip = clip.ScriptClip( "Subtitle(GetTimeCode(current_frame, FrameRate()), " \ + "x=" + String(x) + ", " \ + "y=" + String(y) + ", " \ + "size=" + String(size) + ", " \ + "font=" + Chr(34) + "Migu 1P"+ Chr(34) + "," \ + "text_color=color_white, " \ + "halo_color=$FF000000, " \ + "align=8" \ + ")") return clip } function GetTimeCode(float current_frame, float frame_rate) { current_time = current_frame / frame_rate h = Int(current_time / 3600) m = Int(Int(current_time) % 3600 / 60) s = Int(Int(current_time) % 60) fr = (current_time - Int(current_time)) * frame_rate timecode = String(frame_rate, "%0.2f") + "fps/TCR " + String(h, "%02.0f") + ":" + String(m, "%02.0f") + ":" + String(s, "%02.0f") + ":" + String(fr, "%02.0f") return timecode } function LoadAVI(string filepath) { AVISource(filepath) KillAudio() LanczosResize(WIDTH, HEIGHT) if (PREVIEW) { Subtitle(filepath, align=1, x=0, y=20, size=20) ShowSMPTE(x = WIDTH - 50, y = 20, size = 20) } return last }