SubtitleT= "002.ssa"
SubtitleB= "003.ssa"
要填出路徑
比如放在 c:\ 的話
就是
SubtitleT= "c:\002.ssa"
SubtitleB= "c:\003.ssa"
最新版請用下面的...
使用時可發現字幕不會完全落在黑邊上,這時請編輯一下字幕檔的
[V4+ Styles] / [V4 Styles] 的 MarginV (字幕高度) 填 0 如太低慢慢試試加大(建議值 10)
比如原本 .ssa
[V4 Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, TertiaryColour, BackColour, Bold, Italic, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, AlphaLevel, Encoding
Style: Default,新細明體,26,&H00FF00,&HFCC4A5,&H000008,&H000008,0,0,1,2,1,2,10,30,
30,3,1
改成
Style: Default,新細明體,26,&H00FF00,&HFCC4A5,&H000008,&H000008,0,0,1,2,1,2,10,30,
10,3,1
###########################################################
## 此腳本效果是加上字幕於黑邊上 ##
## 原始影像分辨率需大於 PAL_W*PAL_H,否則會有變形之結果 ##
###########################################################
sClip=avisource("l:\test.avi") #.BilinearResize(512,384) ##測試用
#sClip.Width=512 ##註示用
#sClip.Height=384 ##註示用
## 使用者調整參數 ##
FontSize=25 #字幕大小
SubtitleT= "陸上防衛隊"#上字幕
SubtitleB= "l:\test.ass"#下字幕(文字請勿使用'\'),亦可填寫的是字幕檔案(此時請註上路徑比如 c:\a.aas)
PAL_W= 352 #水平分辨率,請盡量使用4的倍數
PAL_H= 288 #垂直分辨率,請盡量使用4的倍數
mux_mode="add" #合成模式
BorderRevision=0 #寬度裁減修正值
SubtitleFirst_frame=0 #字幕顯示的開始"時間"(請以frame編號填寫),預設值 0
SubtitleLast_frame=framecount(sClip)-1 #字幕顯示的結束"時間"(請以frame編號填寫),預設值 framecount(sClip)-1
####################
## A 11:9 = 1.222222
## B 12:9 = 1.333333
## 銀幕寬不變時,
## A->B 要先在A時減少水平分辨率才可以一比一轉換,
## B->A 則反過來在B時增加水平分辨率,
## 反過來說就是一比一轉換後要乘以修正值A->B 是A/B,B->A 是B/A。
## PAR = DAR * (水平分辨率/垂直分辨率)
## 此例PAR 等於 Float(PAL_W)/PAL_H * Float(sClip.Width)/sClip.Height
## 當想使用PAL <-> NTSC 轉換時請除去下方 #PN# ※用於在TV看片時
#PN#sDAR= Float(sClip.Width)/sClip.Height
#PN#dDAR= Float(PAL_W)/PAL_H
#PN#PAR= (sDAR==dDAR) ? 1 : ((sDAR
New_H= PAL_H-((BorderRevision+FontSize)*2) #=248
## for resize filter 作修正
temp= New_H % 4
New_H= (temp == 0) ? New_H : New_H-temp
New_W= Ceil(Float(New_H)/sClip.Height *sClip.Width)
#PN#New_W= Ceil(New_W *PAR)
## for resize filter 作修正
temp= New_W % 4
New_W= (temp == 0) ? New_W : New_W-temp #=332
b= Ceil((PAL_W-New_W)/2)
#return sClip.subtitle(string(PAR)) ##除錯用
## X= b
## Y= FontSize
## 製作一個空的黑色Clip ##
MainP=NullClip(sClip, sClip.Framecount).BilinearResize(PAL_W,PAL_H).ConvertToYUY2
## 調整原影像使字幕夾擊它 ##
nClip=sClip.BilinearResize(New_W, New_H).ConvertToYUY2
#c=Layer(AudioDub(MainP,sClip), nClip, mux_mode, 255, X, Y)
c=Layer(AudioDub(MainP,sClip), nClip, mux_mode, 255, b,FontSize+BorderRevision)
## 加上下字幕 ##
Loadplugin("VSfilter.dll")
c= (SubtitleT=="") ? c : c.Subtitle(SubtitleT, font="Arial", size=FontSize, align=8)
return (SubtitleB=="")||(Findstr(SubtitleB,"\")>0) ? Get_Sub_File(c,"",SubtitleB,"Auto") : c.Subtitle(SubtitleB, font="華康細圓", size=FontSize-2,align=2)
function NullClip(clip "template", Int "Len")
{
Len = Default(Len, 0)
return Blackness(template, length= Len)
}
#EX: Get_Sub_File(Video, File_Path, File_Name, Subtitle_Style)
Function Get_Sub_File (clip v, String F_P, String F_N, String S_S) {
Loadplugin("VSfilter.dll")
Function Auto_Subtitle_Load (String A_Sub_Name) {
A_Sub_Style =
\ Exist(A_Sub_Name + "IDX") ? "IDX" :
\ Exist(A_Sub_Name + "SRT") ? "SRT" :
\ Exist(A_Sub_Name + "SSA") ? "SSA" :
\ Exist(A_Sub_Name + "ASS") ? "ASS" :
\ Exist(A_Sub_Name + "SMI") ? "SMI" : "NOS"
return A_Sub_Style
}
## 求Subtitle 檔名、副檔名##
S_S_FrontNameChrNum = Get_File_Name_Info(S_S, ".")
F_N_FrontNameChrNum = Get_File_Name_Info(F_N, ".") #Findstr
S_N_Temp = LeftStr(F_N, F_N_FrontNameChrNum)
Sub_Style =
\ (UCase(S_S) == "AUTO") ?
\ Auto_Subtitle_Load(F_P + S_N_Temp) :
\ (S_S_FrontNameChrNum != 0) ?
\ UCase(RightStr(S_S, 3)) :
\ UCase(S_S)
Sub_Name =
\ (S_S_FrontNameChrNum == 0) ?
\ F_P + S_N_Temp + Sub_Style :
\ (Findstr(S_S, ":") > 0) ?
\ S_S :
\ F_P + S_S
## Subtitle File存在 #######
Temp_Sub_IDX = (Sub_Style == "IDX") ? v.VobSub(Sub_Name) : nop
Temp_Sub_SRT = (Sub_Style == "SRT") ? v.TextSub(Sub_Name) : nop
Temp_Sub_SSA = (Sub_Style == "SSA") ? v.TextSub(Sub_Name) : nop
Temp_Sub_ASS = (Sub_Style == "ASS") ? v.TextSub(Sub_Name) : nop
Temp_Sub_SMI = (Sub_Style == "SMI") ? v.TextSub(Sub_Name) : nop
#Temp_Sub_ = (Sub_Style == "") ? v.ConvertToRGB.VD_Subtitler(Sub_Name) : nop
Temp_Sub_NOS = (Sub_Style == "NOS") ? v : nop
File_Subtitle = (Sub_Style <> "") ? Eval("Temp_Sub_"+ Sub_Style) : v
return(File_Subtitle) #string().Subtitle(Sub_Name)
}
#EX: Get_File_Name_Info(StrS, "name") m:\abc.avi
Function Get_File_Name_Info (String ExWork_Movie_File, String Path_Or_Name) {
Function Do_GetStr (String ExWork_Movie_File, Int Str_Len_Num, Int Str_FilePath_necessary_word_Num, String Path_Or_Name) {
F_Str_Num = Str_Len_Num - Str_FilePath_necessary_word_Num + 1
F_Str = LeftStr(ExWork_Movie_File, F_Str_Num)
B_Str_Num = Str_FilePath_necessary_word_Num - 1
B_Str = RightStr(ExWork_Movie_File, B_Str_Num)
Return (Path_Or_Name == "PATH"?F_Str:(Path_Or_Name == "NAME")?B_Str:"")
}
Path_Or_Name = UCase(Path_Or_Name)
Str_Len_Num = StrLen(ExWork_Movie_File)
Str_FilePath_necessary_word_Num = Findstr(RevStr(ExWork_Movie_File), "\")
Str_FrontNameChrNum = (Findstr(RevStr(ExWork_Movie_File), ".") > 0)? Str_Len_Num - Findstr(RevStr(ExWork_Movie_File), ".") + 1 : 0
Return_Word =
\ (Str_FilePath_necessary_word_Num != 0) ?
\ Do_GetStr(ExWork_Movie_File, Str_Len_Num, Str_FilePath_necessary_word_Num, Path_Or_Name) : 0
return ((Path_Or_Name == ".")? Str_FrontNameChrNum : Return_Word)
}