OSDN Git Service

マージの競合解決
[kosys/kosys-ep02.git] / common.avs
1\83f\83t\83H\83\8b\83g\90Ý\92è\92l\r
2 global WIDTH = 1280\r
3 global HEIGHT = 720\r
4 global FPS = 24\r
5 global VERSION=""\r
6 global PREVIEW=false\r
7 \r
8 SetMemoryMax(3072)\r
9 SetFilterMtMode("LanczosResize", 2)\r
10 SetFilterMtMode("Overlay", 2)\r
11 \r
12 \r
13\90Ý\92è\83t\83@\83C\83\8b\82©\82ç\83\8d\81[\83h\r
14 if(Exist(ScriptDir() + "config.avs")) {\r
15         Import(ScriptDir() + "config.avs")\r
16 }\r
17 if(Exist(ScriptDir() + "version.avs")) {\r
18         Import(ScriptDir() + "version.avs")\r
19 }\r
20 \r
21\8aÖ\90\94\r
22 \r
23 function AdjustLength(clip clip)\r
24 {\r
25         alen = clip.AudioDuration\r
26         vlen = 1.0 * clip.FrameCount / clip.FrameRate\r
27 \r
28         video = clip.KillAudio()\r
29         audio = clip.KillVideo()\r
30 \r
31         if (vlen > alen) {\r
32                 d = Int((vlen - alen) * video.FrameRate)\r
33                 audio = audio + clip.BlankClip(length=d).KillVideo()\r
34         }\r
35         \r
36         if (vlen < alen) {\r
37                 d = Int((alen - vlen) * video.FrameRate)\r
38                 video = video + video.BlankClip(length=d)\r
39         }\r
40         \r
41         return AudioDub(video, audio)\r
42 \r
43 }\r
44 \r
45 function TimeCode(clip clip, int "x_offset", int "y_offset", int "bg_color")\r
46 {\r
47         x_offset = Default(x_offset, 0)\r
48         y_offset = Default(y_offset, 0)\r
49         bg_color = Default(bg_color, color_black)\r
50         \r
51         # \95\\8e¦\88Ê\92u\r
52         x = Int(WIDTH / 2                               + x_offset) \r
53         y = Int(70 * (HEIGHT / 1080.0)  + y_offset) \r
54         size = Int(70 * (HEIGHT / 1080.0))\r
55         \r
56         bg = clip.BlankClip(width = Int(710 * (WIDTH / 1920.0)), height = Int(75 * (HEIGHT / 1080.0)), color=bg_color).ConvertToRGB24().ConvertToRGB32()\r
57         \r
58         \r
59         clip = clip.layer(bg, op="mul", x = Int(x - bg.width / 2), y = Int(70 * (HEIGHT / 1080.0)), level=100)\r
60         \r
61         clip = clip.ScriptClip(   "Subtitle(GetTimeCode(current_frame, FrameRate()), " \\r
62                                                         + "x=" + String(x) + ", " \\r
63                                                         + "y=" + String(y) + ", " \\r
64                                                         + "size=" + String(size) + ", " \\r
65                                                         + "font=" + Chr(34) + "Migu 1P"+ Chr(34) + "," \\r
66                                                         + "text_color=color_white, " \\r
67                                                         + "halo_color=$FF000000, " \\r
68                                                         + "align=8" \\r
69                                                         + ")")\r
70         \r
71         return clip\r
72 }\r
73 \r
74 \r
75 function GetTimeCode(float current_frame, float frame_rate) {\r
76 \r
77         current_time = current_frame / frame_rate\r
78         h = Int(current_time / 3600)\r
79         m = Int(Int(current_time) % 3600 / 60)\r
80         s = Int(Int(current_time) % 60)\r
81         fr = (current_time - Int(current_time)) * frame_rate\r
82 \r
83 \r
84 \r
85         timecode = String(frame_rate, "%0.2f") + "fps/TCR " + String(h, "%02.0f") + ":" + String(m, "%02.0f") + ":" + String(s, "%02.0f") + ":" + String(fr, "%02.0f")\r
86         \r
87         \r
88         return timecode\r
89 }\r
90 \r
91 function LoadAVI(string filepath)\r
92 {\r
93         AVISource(filepath)\r
94         KillAudio()\r
95         LanczosResize(WIDTH, HEIGHT)\r
96         if (PREVIEW) \r
97         {\r
98                 Subtitle(filepath, align=1, x=0, y=20, size=20)\r
99                 ShowSMPTE(x = WIDTH - 50, y = 20, size = 20)\r
100         }\r
101         return last\r
102 }\r