| function ShowTimeCode(clip c, int "x", int "y", string "font", int "size",
\ int "text_color", int "halo_color", int "align", int "spc",
\ float "offset", bool "nowtime", string "mode", int "ms_digit"){
global stc_x = default(x, 8)
global stc_y = default(y, 18)
global stc_font = default(font, "Arial")
global stc_size = default(size, 18)
global stc_text_color = default(text_color, $FFFF00)
global stc_halo_color = default(halo_color, $000000)
global stc_align = default(align, 4)
global stc_spc = default(spc, 0)
global stc_mode = default(mode, "hh:mm:ss:ms")
global stc_ms_digit = default(ms_digit, 2)
offset = default(offset, 0.0)
nowtime = default(nowtime, false)
Assert((stc_ms_digit>=1)&&(stc_ms_digit<=3), "Error: ms_digit must be between 1 and 3.")
system_time = (nowtime == true) ? Int(Value(Time("%H")))*60*60 +
\ Int(Value(Time("%M")))*60 + Int(Value(Time("%S"))) : NOP
global stc_offset = (nowtime == true) ? offset + system_time : offset
return ScriptClip(c, "get_time = (current_frame)/FrameRate()" +
\ "total_time = GetTimeCode(get_time, stc_offset, stc_mode, stc_ms_digit)" +
\ "Subtitle(total_time, stc_x, stc_y, current_frame, current_frame,
\ stc_font, stc_size, stc_text_color, stc_halo_color, stc_align, stc_spc)")
}
function ShowTimeCodeEx(clip c, int "x", int "y", string "font",
\ string "effects", int "size", int "textcolor", int "halocolor",
\ float "offset", bool "nowtime", string "mode", int "ms_digit"){
global stcex_x = default(x, Round(-Width(c)*0.11))
global stcex_y = default(y, Round(-Height(c)*0.17))
global stcex_font = default(font, "Arial")
global stcex_effects = default(effects, "b")
global stcex_size = default(size, 36)
global stcex_textcolor = default(textcolor, $00FFFFFF)
global stcex_halocolor = default(halocolor, $00000000)
global stcex_mode = default(mode, "hh:mm:ss:ms")
global stcex_ms_digit = default(ms_digit, 2)
offset = default(offset, 0.0)
nowtime = default(nowtime, false)
Assert((stcex_ms_digit>=1)&&(stcex_ms_digit<=3), "Error: ms_digit must be between 1 and 3.")
system_time = (nowtime == true) ? Int(Value(Time("%H")))*60*60 +
\ Int(Value(Time("%M")))*60 + Int(Value(Time("%S"))) : NOP
global stcex_offset = (nowtime == true) ? offset + system_time : offset
return ScriptClip(c, "get_time = (current_frame)/FrameRate()" +
\ "total_time = GetTimeCode(get_time, stcex_offset, stcex_mode, stcex_ms_digit)" +
\ "SubtitleEx(total_time, stcex_x, stcex_y, current_frame, current_frame,
\ stcex_font, stcex_effects, stcex_size, stcex_textcolor, stcex_halocolor)")
}
function GetTimeCode(float get_time, float offset, string mode, int ms_digit){
factor = Pow(10, ms_digit) ms_int = Round(get_time*factor) % Int(factor) ms = String(ms_int, "%0"+String(ms_digit)+".0f")
int_time = Round(get_time-(Value(ms)/factor))
ss = String(int_time%60)
ss = RightStr("0" + ss, 2)
mm = String((int_time/60)%60)
mm = RightStr("0" + mm, 2)
hh = ((int_time/60)/60)%60
hh_multiplier = hh/24
hh = (hh >= 24) ? hh - (24*hh_multiplier) : hh
hh = (hh < 10) ? "0" + String(hh) : String(hh)
separation = (RightStr(mode, 2) == "ms") ? LeftStr(RightStr(mode, 3), 1) : NOP
timecode =
\ (mode == "ts") ? String(int_time) :
\ ((mode == "ts.ms")||(mode == "ts:ms")) ? String(int_time) + separation + ms :
\ (mode == "ss") ? ss :
\ ((mode == "ss.ms")||(mode == "ss:ms")) ? ss + separation + ms :
\ ((mode == "mm:ss.ms")||(mode == "mm:ss:ms")) ? mm + ":" + ss + separation + ms :
\ ((mode == "hh:mm:ss.ms")||(mode == "hh:mm:ss:ms")) ?
\ hh + ":" + mm + ":" + ss + separation + ms :
\ (mode == "mm:ss") ? mm + ":" + ss :
\ (mode == "hh:mm:ss") ? hh + ":" + mm + ":" + ss :
\ "Invalid"
Assert(timecode != "Invalid" , """Error: such "mode" doesn't exist.""")
return timecode
}
|