示例#1
0
        public static VideoInfo TryReadVideoInfoViaAviHeader(string fileName)
        {
            var info = new VideoInfo {
                Success = false
            };

            try
            {
                using (var rp = new RiffParser())
                {
                    if (rp.TryOpenFile(fileName) && rp.FileType == RiffParser.CkidAvi)
                    {
                        var dh = new RiffDecodeHeader(rp);
                        dh.ProcessMainAvi();
                        info.FileType          = RiffParser.FromFourCc(rp.FileType);
                        info.Width             = dh.Width;
                        info.Height            = dh.Height;
                        info.FramesPerSecond   = dh.FrameRate;
                        info.TotalFrames       = dh.TotalFrames;
                        info.TotalMilliseconds = dh.TotalMilliseconds;
                        info.TotalSeconds      = info.TotalMilliseconds / TimeCode.BaseUnit;
                        info.VideoCodec        = dh.VideoHandler;
                        info.Success           = true;
                    }
                }
            }
            catch
            {
                // ignored
            }

            return(info);
        }