1、提取 swf中的声音文件程序源代码(Extract SWF sound file source code)-以下为程序代码-单位 swfblue_u1;接口使用Windows消息,SysUtils、变体、类、图形、控件、窗体,对话框,actnlist,StdActns,StdCtrls,按钮,ShlObj,Zlib;类型tmain =类(平台)b_open:TButton;按钮:TButton;标签:TLabel;TLabel label2;中的代码块为 label3:TLabel;opendialog1:topendialog;label4:TLabel;e_dir:TEdit;speedb
2、utton1:TSpeedButton;程序 b_openclick(发件人:TObject) ;程序 button3click(发件人:TObject) ;程序 formshow(发件人:TObject) ;程序 speedbutton1click(发件人:TObject) ;私有的私人声明公众的公共声明文件长度:LongWord;/ / SWF 文件尺寸filebuf:数组的字节;/ /将 SWF文件读入内存存放结束;VaR主营:tmain;实施 $ R * DFM 。程序 tmain b_openclick(发件人:TObject) ;VaRf:文件;FWS:弦 3 ;/标示信息版本:字
3、节;/ / SWF 文件版本号b,B1,B2:字节;巴夫:数组的字节;帧率:/ /速率房;帧数:词;/ /总帧数S:字符串;TagID:字;/ /标签标示taglength:LongWord;/ /标签长度currentpos,filelengthpos,tagpos,tmppos:整数;/ / currentpos记录当前读写位置/ / filelengthpos记录文件长度参数位置/ / tagpos记录当前 tagid位置文件名:字符串;/ /存放 SWF文件名(去掉了路径和扩展名)L:LongWord;SoundID:字;/ /事件声音的声音 IDSoundInfo:字节;/ /事件声
4、音的声音信息soundsamplecount:LongWord;streamheadb1,streamheadb2:字节;/ /流声音的声音信息StreamSoundSampleCount:字;音乐档案:字符串;/ /记录生成的声音文件的扩展名,根据没有、ADPCM和 MP3不同分为。WAV MP3 和。soundcount:词;/ /流声音类型的文件计数文件名;unknow1:字;unknow2:LongWord;开始如果不 opendialog1执行然后退出;我不 fmopenread:=;assignfile(F,opendialog1。文件名) ;复位(F,1) ;设置缓冲区的长度(f
5、ilebuf,文件大小(F) ) ;blockread(F,filebuf 0 ,文件大小(F) ) ;/将文件读入内存关闭一个打开的文件(F) ;/ /下面为读取 SWF文件的文件头头部分currentpos:= 0;/ /读取fws”标示规定长度(FWS,3) ;移动(filebuf currentpos ,和 1 ,3) ;公司(currentpos,3) ;如果 FWS 0 做:=复制(S,1,POS(。,S)- 1) ;文件名;规定长度(buf,0) ;音乐档案:=“.wav” ;soundcount:= 1;重复TagPos:= currentpos;/ /读取 tagid并得到
6、taglength移动(filebuf currentpos ,TagID,Sizeof(tagid) ) ;公司(currentpos,Sizeof(tagid) ) ;taglength:= tagid 美元和 3f;TagID:= tagid SHR 6;/ /如果是 longtag则读取下面的 taglength如果 taglength = $ 3f然后开始移动(filebuf currentpos ,TagLength,Sizeof(taglength) );公司(currentpos,Sizeof(taglength) ) ;结束;案例 TagID24:开始/ /是否有 SWF保护
7、设置/ /如果有则将该标签去掉,将后面的标签搬过来覆盖掉 tagid为24的部分移动(filebuf currentpos + taglength ,filebuf tagpos ,文件长度-(currentpos + taglength)+ 1) ;/ /相应的,要减去文件长度文件长度文件长度:=文件长度-(Sizeof(tagid)+ taglength) ;currentpos:= tagpos;结束;14:开始/ /读取事件声音移动(filebuf currentpos ,SoundID,Sizeof(soundid) ) ;公司(currentpos,Sizeof(soundid)
8、) ;tmppos:= currentpos;移动(filebuf currentpos ,SoundInfo,Sizeof(soundinfo) );公司(currentpos,Sizeof(soundinfo) ) ;移动(filebuf currentpos ,SoundSampleCount,Sizeof(soundsamplecount) ) ;公司(currentpos,Sizeof(soundsamplecount) ) ;案例 soundinfo SHR 40:=“wav” ;2:S =;结束;L:= TagLength Sizeof(soundid) ;/ /将标签的数据部分
9、作为声音数据存盘assignfile(FW,e_dir。文字+文件名+ _sound +IntToStr(soundid)+ S) ;重写(FW,1) ;blockwrite(FW,filebuf tmppos ,L) ;关闭一个打开的文件(FW) ;currentpos:= tmppos + L;结束;18:开始/ /读取流声音的数据头/ id = 18属于 soundstreamhead/ /先检查前面是否已有了流声音,如果有则先存盘如果长度(BUF) 0 然后开始assignfile(FW,e_dir。文字+文件名+ _streamsound +IntToStr(SoundCount)+
10、音乐档案) ;重写(FW,1) ;blockwrite(FW,但是 0 ,长度(BUF) ) ;关闭一个打开的文件(FW) ;公司(soundcount) ;结束;规定长度(buf,0) ;移动(filebuf currentpos ,streamheadb1,sizeof(streamheadb1) ) ;公司(currentpos,sizeof(streamheadb1) ) ;移动(filebuf currentpos ,streamheadb2,sizeof(streamheadb2) ) ;公司(currentpos,sizeof(streamheadb2) ) ;移动(filebu
11、f currentpos ,StreamSoundSampleCount,Sizeof(streamsoundsamplecount) ) ;公司(currentpos,Sizeof(streamsoundsamplecount) ) ;/ /不同于 ID = 18,此处没有 unknow1数据案例 streamheadb2 SHR 40:音乐档案:=“wav” ;2:=“MP3 音乐文件;结束;结束;19:开始1 /将每帧(位于每 1个 ID = 19的标签数据中)的声音数据读取并组合在一起1 /此处有个 unknow2数据,占 32位,没有用处移动(filebuf currentpos ,
12、unknow2,Sizeof(unknow2) ) ;公司(currentpos,Sizeof(unknow2) ) ;L:=长度(BUF) ;/ /求出缓冲区现在长度规定长度(buf,L + TagLength Sizeof(unknow2) ) ;/将缓冲区加长/ /顺序存放移动(filebuf currentpos ,而是我,TagLength Sizeof(unknow2) ) ;公司(currentpos,TagLength Sizeof(unknow2) ) ;结束;0:开始/ /结尾处检查前面是否有流声音,如果有则存盘如果长度(BUF)”开始shgetpathfromidlist(P,buf) ;S:= BUF 的长度;如果(S) 然后 S = S + ;e_dir。正文:= S;结束;结束;结束。