注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

分享,态度 ·~~

—— 十年太长,五年;如果可以回到五年前,你最想对那时候的自己说什么?

 
 
 

日志

 
 

WMA文件的文件头结构  

2010-06-30 15:36:07|  分类: DotNet |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

有关wma音频文件的文件结构,稍微整理一下,这些对读写wma文件信息都很有帮助。呵呵,有点乱,但是又没有时间细细解说,请见谅。如有任何指正,请留言交流。首先是几个GUID常量:

const string GUIDWmaST = "75B22630-668E-11CF-A6D9-00AA0062CE6C";
const string GUIDContentST = "75B22633-668E-11CF-A6D9-00AA0062CE6C";
const string GUIDExtContentST = "D2D0A440-E307-11D2-97F0-00A0C95EA850";
const string GUIDBrandST = "2211B3FA-BD23-11D2-B4B7-00A0C955FC6E";
const string GUIDFilePropertiesST = "8CABDCA1-A947-11CF-8EE4-00C00C205365";

结构图:

WMA文件的文件头结构 - 乂乂 - 一个人,一支烟  ·~~

写入ExtContent信息示例(读取类似):

                    //no ExtContent Block we need add it
                    nNewHeaderObjects++;
                    int ExtContentPos = 16 + 8 + 4 + 2; // 设定ExtContent开始的位置
                    byte[] bLastData = new byte[fs.Length - ExtContentPos];
                    fs.Seek(ExtContentPos, SeekOrigin.Begin);
                    fs.Read(bLastData, 0, bLastData.Length);

                    //write new Header object count
                    fs.Seek(24, SeekOrigin.Begin);
                    byte[] bHeaderObjects = BitConverter.GetBytes(nNewHeaderObjects);
                    fs.Write(bHeaderObjects, 0, bHeaderObjects.Length);
                    bHeaderObjects = null;

                    int nAddLength = 0;
                    //we need add 'WM/AlbumTitle\0' tag
                    Int16 NewContents = 1;
                    byte[] bContents = BitConverter.GetBytes(NewContents);
                    nAddLength += 2;

                    string TagString = "WM/AlbumTitle\0";
                    byte[] bTagString = Encoding.Unicode.GetBytes(TagString);
                    Int16 nTagLen = (Int16)bTagString.Length;
                    nAddLength += 2;
                    nAddLength += (Int16)bTagString.Length;

                    Int16 nFlag = 0;
                    byte[] bFlag = BitConverter.GetBytes(nFlag);
                    nAddLength += 2;

                    byte[] bValueString = Encoding.Unicode.GetBytes(mInfo.AlbumeName + "\0");
                    Int16 nValueLen = (Int16)bValueString.Length;
                    nAddLength += 2;
                    nAddLength += bValueString.Length;

                    Int64 BlockLen = nAddLength + 24;
                    NewMaxSize += BlockLen;

                    //fs.Seek(NewMaxSize, SeekOrigin.Begin);
                    fs.Seek(ExtContentPos, SeekOrigin.Begin);

                    WriteGUID(fs, GUIDExtContentST);
                    //write new ExtContents block size
                    byte[] bnewLen = BitConverter.GetBytes(BlockLen);
                    fs.Write(bnewLen, 0, bnewLen.Length);
                    bnewLen = null;

                    //write content num
                    fs.Write(bContents, 0, bContents.Length);
                    bContents = null;

                    //write name len & name string
                    bnewLen = BitConverter.GetBytes(nTagLen);
                    fs.Write(bnewLen, 0, bnewLen.Length);
                    bnewLen = null;
                    fs.Write(bTagString, 0, bTagString.Length);
                    bTagString = null;

                    //write 2 byts flag
                    fs.Write(bFlag, 0, bFlag.Length);
                    bFlag = null;

                    //write value len & value strint
                    bnewLen = BitConverter.GetBytes(nValueLen);
                    fs.Write(bnewLen, 0, bnewLen.Length);
                    bnewLen = null;
                    fs.Write(bValueString, 0, bValueString.Length);
                    bValueString = null;

                    //write last data
                    fs.Write(bLastData, 0, bLastData.Length);
                    bLastData = null;

  评论这张
 
阅读(3386)| 评论(3)
推荐 转载

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017