| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 813 人关注过本帖
标题:怎样读取MPG文件的媒体信息?读取WAV文件的媒体信息我有了。
只看楼主 加入收藏
g12339645
Rank: 2
等 级:论坛游民
帖 子:14
专家分:42
注 册:2011-6-17
收藏
 问题点数:0 回复次数:0 
怎样读取MPG文件的媒体信息?读取WAV文件的媒体信息我有了。
RT
程序代码:
 Private Sub getWavData(ByVal s As String)
        Try
            Dim MyFile As String = s
            Dim MyFileInfo As New (MyFile)
            Dim MyStream As  = MyFileInfo.OpenRead()
            Dim MyInfo As String = MyFile + "文件的标志信息如下:" + vbCrLf
            If (MyStream.Length >= 44) Then
                Dim MyBytes(44) As Byte
                MyStream.Read(MyBytes, 0, 44)
                System.Text.Encoding.Default.GetString(MyBytes, 0, 4)
                If ((System.Text.Encoding.Default.GetString(MyBytes, 0, 4) = "RIFF") And _
                    (System.Text.Encoding.Default.GetString(MyBytes, 8, 4) = "WAVE") And _
                    (System.Text.Encoding.Default.GetString(MyBytes, 12, 4) = "fmt ")) Then
                    MyInfo += vbCrLf + " GroupID:" + _
                            System.Text.Encoding.Default.GetString(MyBytes, 0, 4).ToString()
                    System.BitConverter.ToInt32(MyBytes, 4)
                    MyInfo += vbCrLf + " FileSize:" + _
                                        System.BitConverter.ToInt32(MyBytes, 4).ToString()
                    MyInfo += vbCrLf + " RiffType:" + _
                            System.Text.Encoding.Default.GetString(MyBytes, 8, 4).ToString()
                    MyInfo += vbCrLf + " ChunkID:" + _
                            System.Text.Encoding.Default.GetString(MyBytes, 12, 4).ToString()
                    MyInfo += vbCrLf + " ChunkSize:" + _
                                        System.BitConverter.ToInt32(MyBytes, 16).ToString()
                    MyInfo += vbCrLf + " WFormatTag:" + _
                                        System.BitConverter.ToInt16(MyBytes, 20).ToString()
                    MyInfo += vbCrLf + " WChannels:" + _
                                        System.BitConverter.ToUInt16(MyBytes, 22).ToString()
                    MyInfo += vbCrLf + " DWSamplesPerSec:" + _
                                        System.BitConverter.ToUInt32(MyBytes, 24).ToString()
                    MyInfo += vbCrLf + " DWavBytesPerSec:" + _
                                        System.BitConverter.ToUInt32(MyBytes, 28).ToString()
                    MyInfo += vbCrLf + " WBLockAlign:" + _
                                        System.BitConverter.ToUInt16(MyBytes, 32).ToString()
                    MyInfo += vbCrLf + " WBitsPerSample:" + _
                                        System.BitConverter.ToUInt16(MyBytes, 34).ToString()
                    MyInfo += vbCrLf + " DataChunkID:" + _
                            System.Text.Encoding.Default.GetString(MyBytes, 36, 4).ToString()
                    MyInfo += vbCrLf + " DataSize:" + _
                                            System.BitConverter.ToInt32(MyBytes, 40).ToString()
                End If
            End If
            MyStream.Close()
            MessageBox.Show(MyInfo, "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
        Catch ex As Exception
            MessageBox.Show(ex.Message, "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
        End Try
    End Sub

搜索更多相关主题的帖子: 信息 color 
2012-06-21 19:47
快速回复:怎样读取MPG文件的媒体信息?读取WAV文件的媒体信息我有了。
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019896 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved