/// <summary> /// 分析amf文件头部 /// </summary> /// <param name="header">文件头字符数组</param> /// <returns></returns> public static AmfHeadInfo AnalyzeFileHeader(Byte[] header) { try { if (header.Length != 76) return null; System.IO.MemoryStream ms = new System.IO.MemoryStream(header); var temp = new AmfHeadInfo { Format = AmfTools.Byte2String(ms.ReadBytesExtend(0, 4)), FileSize = AmfTools.ConvertToInt32(header, 4) + 8, AudioFlag = AmfTools.SubArray(header, 8, 4), AudioHeadSize = AmfTools.ConvertToInt32(header, 12), AudioCodec = new Char4 { Value = AmfTools.Byte2String(ms.ReadBytesExtend(16, 4)) },//AmfTools.SubArray(header,16,4)}, AudioBitRate = AmfTools.ConvertToInt32(header, 20), ChannelCount = AmfTools.ConvertToInt32(header, 24), SamplingRate = AmfTools.ConvertToInt32(header, 28), SamplingTime = AmfTools.ConvertToInt32(header, 32), AudioFrameCount = AmfTools.ConvertToInt32(header, 36), VideoFlag = AmfTools.SubArray(header, 40, 4), VideoHeadSize = AmfTools.ConvertToInt32(header, 44), VideoCodec = new Char4 { Value = AmfTools.Byte2String(ms.ReadBytesExtend(48, 4)) },//AmfTools.SubArray(header, 48, 4), Width = AmfTools.ConvertToInt32(header, 52), Height = AmfTools.ConvertToInt32(header, 56), VideoFrameRate = AmfTools.ConvertToInt32(header, 60), VideoFrameCount = AmfTools.ConvertToInt32(header, 64), DataBlockFlag = AmfTools.SubArray(header, 68, 4), DataSize = AmfTools.ConvertToInt32(header, 72) }; ms.Close(); return temp; } catch { throw; } }