In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces "how to achieve ass/ssa batch conversion srt script", in the daily operation, I believe that many people have doubts on how to achieve ass/ssa batch conversion srt script. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubt of "how to achieve ass/ssa batch conversion srt script". Next, please follow the editor to study!
OPlayer in iPad only supports subtitles in srt format, while animations generally use subtitles in ass/ssa format, so you need to convert ass/ssa into srt in batches.
Google for a while, and find an ass2srt.wsf script in "ass2srt [ass/ssa batch conversion srt]", as follows:
CInput= "unicode"; / / You can find them from: cOutput= "utf-8" / / HKEY_CLASSES_ROOT\ MIME\ Database\ Charset function rrr () {re = / Dialogue: [^,.] * [0-9] *, ([1-9]? [0-9] *: [0-9] *: [0-9] *), ([1-9]? [0-9] *: [0-9] *: [0-9] *. [0-9] *), [^,.] *, [^,.] * [0-9] *, [0-9] *, [0-9] *, [^,.] *, (. *) / gi Rv = ss.match (re); T1 = RegExp.$1; T2 = RegExp.$2; T3 = RegExp.$3; rg = /\ {[^}.] * (\\ pos\ ([0-9] *, [0-9] *\)) [^}.] *} / gi; T3 = t3.replace (rg, "$1" + "}"); rg = /\ {[^}.] *} / gi; T3 = t3.replace (rg, "") Rg = / (\\ pos\ ([0-9] *, [0-9] *\)}) / gi; T3 = t3.replace (rg, "{" + "$1") } set ad=CreateObject ("adodb.stream") set af=CreateObject ("adodb.stream") set ass=CreateObject ("adodb.stream") ad.open af.open ass.open ad.Charset=cInput af.Charset=cOutput ass.Charset=cOutput Set objArgs = WScript.Arguments For I = 0 to objArgs.Count-1 ad.LoadFromFile (objArgs (I)) zroom0 gg=left (objArgs (I), len (objArgs (I))-3) & "srt" Do While ad.eos True ss= ad.ReadText (- 2) if left (ss 8) = "Dialogue" then ss=replace (ss, ", d,") rrr t3=replace (T3, "\ n", vbcrlf) t3=replace (T3, "\ N", vbcrlf) z=z+1 af.writetext z af.writetext T1 & "- >" & T2 af.writetext T3 & vbcrlf & vbcrlf else ass.writetext ss,1 end if Loop af.savetofile gg 2 ass.savetofile gg& ".style", 2 Next if iTunes 0 then msgbox "Please drag files to me!", "Error!" Else msgbox "Converted" & I & "file (s).", "All Over!" End if
The Windows script (.wsf) file is a text document containing Extensible markup language (XML) code that combines several functions to improve the flexibility of script programming. Because Windows script files are not limited to specific engines, they can contain scripts for all script engines that follow the ActiveX (R) specification.
The above script file contains both JScript and VBScript code. The question is, is it necessary? It can be done simply with JScript or VBScript, so why mix different languages? The role of JScript in code is just regular expressions, and a reasonable inference is that the author can't VBScript regular expressions, or that VBScript's regular expressions are too troublesome. Despite the language mix, the style of the above code is really unflattering.
Here is my ass2srt.vbs, which may be a little better than the code above.
Option ExplicitConst Encoding = "unicode" 'assume unicode'Author: Demon'Website: http://demon.tw'Date: 2012/6/16Dim shell, folder, fso, ext, I, argsSet shell = CreateObject ("Shell.Application") Set fso = CreateObject ("scripting.filesystemobject") Set args = 0 Then Set folder = shell.BrowseForFolder (0, "Please select the folder where the ASS subtitles are located" 1) If folder Is Nothing Then WScript.Quit For Each i In fso.GetFolder (folder.Self.Path). Files ext = LCase (fso.GetExtensionName (i.Path)) If ext = "ass" Or ext = "ssa" Then ASS2SRT i.Path, Encoding End If NextElse For i = 0 To args.Count-1 ASS2SRT args (I), Encoding NextEnd IfMsgBox CInt (I) & "file (s) Converted!", vbInformationFunction 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 ("ADODB.Stream") Set srt = CreateObject ("ADODB.Stream") Set re = New RegExp re.Global = True re.Pattern = "\ {. *?\}" ass.Type = adTypeText ass.Charset = charset ass.Open ass.LoadFromFile path srt.Type = adTypeText srt.Charset = "utf-8" srt.Open I = 0 Do Until ass.EOS str = ass.ReadText (adReadLine) If Left 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 = re.Replace (t,") t = Replace (t, "\ n", vbCrLf) t = Replace (t, "\ N", vbCrLf) srt.WriteText I & vbCrLf srt.WriteText s & "- >" & e & vbCrLf srt.WriteText t & vbCrLf & vbCrLf End If Loop path = Left (path, Len (path)-3) & "srt" srt.SaveToFile path, adSaveCreateOverWriteEnd Function
Save the above code as ass2srt.vbs, and then drag the ass/ssa subtitles that need to be converted onto the ass2srt.vbs script. If you need to convert more ass/ssa subtitles in batch, you can first put them in the same folder, then double-click to run ass2srt.vbs, and select the folder where the subtitles are located.
At this point, the study on "how to achieve ass/ssa batch conversion srt script" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.