示例#1
0
        public static AviContainer Load(string fileName)
        {
            var container = new AviContainer();

            container._fileName = fileName;
            container._reader   = new BinaryReader(new FileStream(fileName, FileMode.Open, FileAccess.ReadWrite, FileShare.Read));
            return(container);
        }
示例#2
0
        static void Main(string[] args)
        {
            const string fileName = @"F:\Downloads\avi_h264_mp3.avi";

            var container = AviContainer.Load(fileName);

            foreach (var item in container)
            {
                if (item is AviListChunk)
                {
                    Console.Write("".PadLeft(container.Level, '\t'));
                    Console.WriteLine((item as AviListChunk).ListChunk.fcc);
                }
                if (item is AviSubChunk)
                {
                    Console.Write("".PadLeft(container.Level, '\t'));
                    Console.WriteLine((item as AviSubChunk).Chunk.fcc);
                }
            }

            //byte[] data = File.ReadAllBytes(fileName);

            //unsafe
            //{
            //    int offset;
            //    int length;

            //    offset = 0;
            //    length = Marshal.SizeOf(typeof(RIFFLIST));

            //    byte[] riffListData =
            //        data.Skip(offset)
            //            .Take(length)
            //            .ToArray();

            //    fixed (byte* p = riffListData)
            //    {
            //        var riffChunk = (RIFFLIST*)p;
            //    }

            //    offset += length;
            //    length = Marshal.SizeOf(typeof(RIFFLIST));

            //    byte[] listData =
            //        data.Skip(offset)
            //            .Take(length)
            //            .ToArray();

            //    fixed (byte* p = listData)
            //    {
            //        var riffChunk = (RIFFLIST*)p;
            //    }

            //    offset += length;
            //    length = Marshal.SizeOf(typeof(AVIMAINHEADER));

            //    byte[] mainHeaderData =
            //        data.Skip(offset)
            //            .Take(length)
            //            .ToArray();

            //    fixed (byte* p = mainHeaderData)
            //    {
            //        var mainHeader = (AVIMAINHEADER*)p;
            //    }
            //}
        }