admin 管理员组文章数量: 1086019
2024年4月19日发(作者:各种颜色代码大全高清)
iPad中的OPlayer只支持srt格式的字幕,而动画一般使用的是ass/ssa格式的字幕,
所以需要将ass/ssa批量转换srt。
Google了一下,在《ass2srt[ass/ssa批量转换srt]》中找到一个脚本,
内容如下:
82936
3738394647484956e(rg,""); rg =/(; t3 =
e(rg,"{" + "$1"); } </Script> <script language="VBScript"> set
ad=CreateObject("") set af=CreateObject("") set
ass=CreateObject("") t=cInput
t=cOutput t=cOutput Set objArgs = nts For I
= 0 to - 1 omFile(objArgs(I)) z=0
gg=left(objArgs(I),len(objArgs(I))-3)&"srt" Do While <> True ss
=xt(-2) if left(ss,8)="Dialogue" then ss=replace(ss,",,",",d,")
z=z+1 ext
rrr
z,1 t3=replace(t3,"n",vbcrlf) t3=replace(t3,"N",vbcrlf)
ext t1 & " --> " & t2,1 ext t3 & vbcrlf &
vbcrlf else ext ss,1 end if Loop file gg,2 file
gg&".style",2 Next if i=0 then msgbox "Please drag files to me!",,"Error!" else
msgbox "Converted "&i&" file(s).",,"All Over!" end if </Script>
</job>
Windows 脚本 (.wsf) 文件是一个包含可扩展标记语言(XML)代码的文本文档,它结
合了若干功能,提高了脚本编程的灵活性。由于 Windows 脚本文件并不局限于特定的引
擎,它们能够包含所有遵循 ActiveX(R)规范的脚本引擎的脚本。
上面的脚本文件同时包含了JScript和VBScript的代码。问题在于,有这个必要么?
单纯用JScript或者VBScript都可以实现,为什么要混用不同的语言呢?JScript在代码中
的作用仅仅是正则表达式而已,一个合理的推断是作者不会VBScript的正则表达式,或者
嫌VBScript的正则表达式太麻烦。就算撇开语言混杂不说,上面代码的风格实在是不敢恭
维。
下面是我写的,也许比上面的代码好一点点罢。
82936
373839464748495657585966676869
76 Option Explicit Const Encoding = "unicode" 'assume unicode
'Author: Demon 'Website: 'Date: 2012/6/16 Dim shell, folder, fso, ext, i, args Set
shell = CreateObject("ation") Set fso =
CreateObject("stemobject") Set args = nts If
= 0 Then Set folder = ForFolder(0, "请选择ASS字幕所在的
文件夹", 1) If folder Is Nothing Then For Each i In
der().Files ext = LCase(ensionName()) If
ext = "ass" Or ext = "ssa" Then ASS2SRT , Encoding End If NextElse For i = 0
To - 1 ASS2SRT args(i), Encoding NextEnd If MsgBox CInt(i) & "
file(s) Converted!", vbInformation Function ASS2SRT(path, charset) Const
adTypeText = 2 Const adReadLine = -2 Const adSaveCreateOverWrite = 2 Dim ass,
srt, re, str, arr, s, e, t, i Set ass = CreateObject("") Set srt =
CreateObject("") Set re = New RegExp = True
Case = True n = "{.*?}" = adTypeText t =
charset omFile path = adTypeText t =
"utf-8" i = 0 Do Until str = xt(adReadLine) If Left(str, 8)
= "Dialogue" Then i = i + 1 arr = Split(str, ",", 10) s = "0" & arr(1) & "0"
'Start time e = "0" & arr(2) & "0" 'End time t = arr(9) 'Text s = Replace(s,
".", ",") e = Replace(e, ".", ",") t = e(t, "") t = Replace(t, "n", vbCrLf) t =
Replace(t, "N", vbCrLf) ext i & vbCrLf ext s & " -->
" & e & vbCrLf ext t & vbCrLf & vbCrLf End If Loop
path = Left(path, Len(path) - 3) & "srt" File path,
adSaveCreateOverWrite End Function
把上面代码保存为,然后将需要转换的ass/ssa字幕拖动到
脚本上即可。如果需要批量转换的ass/ssa字幕比较多,可以先把它们放到同一个文件夹
里,然后直接双击运行,选择字幕所在的文件夹即可。
更多信息请查看IT技术专栏
版权声明:本文标题:ass2srt.vbs(ass-ssa批量转换srt的脚本) 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.roclinux.cn/b/1713479979a636744.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论