Пример #1
0
        public MediaInfoResult GetVideoInfo(string path)
        {
            var lib = new MediaInfo();

            lib.Open(path);

            var result = new MediaInfoResult();

            // TODO: Don't hardcode
            var videoStreamIndex = 0;

            var text = GetValue(lib, videoStreamIndex, new[] { "ScanType", "Scan type", "ScanType/String" });

            if (!string.IsNullOrWhiteSpace(text))
            {
                result.IsInterlaced = text.IndexOf("interlac", StringComparison.OrdinalIgnoreCase) != -1;
            }

            text = GetValue(lib, videoStreamIndex, new[] { "Format_Settings_CABAC", "Format_Settings_CABAC/String" });
            if (!string.IsNullOrWhiteSpace(text))
            {
                result.IsCabac = string.Equals(text, "yes", StringComparison.OrdinalIgnoreCase);
            }

            int bitDepth;

            text = GetValue(lib, videoStreamIndex, new[] { "BitDepth", "BitDepth/String" });

            if (!string.IsNullOrWhiteSpace(text) && int.TryParse(text.Split(' ').First(), NumberStyles.Any, CultureInfo.InvariantCulture, out bitDepth))
            {
                result.BitDepth = bitDepth;
            }

            int refFrames;

            text = GetValue(lib, videoStreamIndex, new[] { "Format_Settings_RefFrames", "Format_Settings_RefFrames/String" });

            if (!string.IsNullOrWhiteSpace(text) && int.TryParse(text.Split(' ').First(), NumberStyles.Any, CultureInfo.InvariantCulture, out refFrames))
            {
                result.RefFrames = refFrames;
            }

            return(result);
        }
Пример #2
0
        public MediaInfoResult GetVideoInfo(string path)
        {
            var lib = new MediaInfo();

            lib.Open(path);

            var result = new MediaInfoResult();

            // TODO: Don't hardcode
            var videoStreamIndex = 0;

            var text = GetValue(lib, videoStreamIndex, new[] { "ScanType", "Scan type", "ScanType/String" });
            if (!string.IsNullOrWhiteSpace(text))
            {
                result.IsInterlaced = text.IndexOf("interlac", StringComparison.OrdinalIgnoreCase) != -1;
            }

            text = GetValue(lib, videoStreamIndex, new[] { "Format_Settings_CABAC", "Format_Settings_CABAC/String" });
            if (!string.IsNullOrWhiteSpace(text))
            {
                result.IsCabac = string.Equals(text, "yes", StringComparison.OrdinalIgnoreCase);
            }

            int bitDepth;
            text = GetValue(lib, videoStreamIndex, new[] { "BitDepth", "BitDepth/String" });

            if (!string.IsNullOrWhiteSpace(text) && int.TryParse(text.Split(' ').First(), NumberStyles.Any, CultureInfo.InvariantCulture, out bitDepth))
            {
                result.BitDepth = bitDepth;
            }

            int refFrames;
            text = GetValue(lib, videoStreamIndex, new[] { "Format_Settings_RefFrames", "Format_Settings_RefFrames/String" });

            if (!string.IsNullOrWhiteSpace(text) && int.TryParse(text.Split(' ').First(), NumberStyles.Any, CultureInfo.InvariantCulture, out refFrames))
            {
                result.RefFrames = refFrames;
            }

            return result;
        }