;使用方法 s := silenceDetect("test.wav",30) ;检测test.wav中响度低于-30db的静音区 ;返回数组,单个值包含键值:start开始时间,end结束时间, duration:时长 silenceDetect(file,db := 40){ out_file := A_ScriptDir "\tmp\" GUID() ".wav" ;注意脚本目录下要有tmp文件夹 ret := cmd("""" A_ScriptDir "\tools\ffmpeg64.exe"" -i """ file """ -af silencedetect=n=-" db "dB:d=1 -y """ out_file """","UTF-8") s := [] l := StrSplit(ret,"`r","`n") for k,v in l { if RegExMatch(v,"\[silencedetect[^\]]*\]\ssilence_start:\s([0-9\.]*)",m) s.push({"start":floor(m1*1000)}) else if RegExMatch(v,"\[silencedetect[^\]]*\]\ssilence_end:\s([0-9\.]*)\s\|\ssilence_duration:\s([0-9\.]*)",m) s[s.maxindex()].end := floor(m1*1000), s[s.maxindex()].duration := floor(m2*1000) } FileDelete % out_file return s } GUID(){ shellobj := ComObjCreate("Scriptlet.TypeLib") ret := shellobj.GUID uuid := RegExReplace(ret,"(\{|\}|-)","") return uuid }
61 queries in 1.923 seconds |