Ejemplo n.º 1
0
        public MediaInfoFile(string file)
        {
            this.file = file;
            MediaInfo info = new MediaInfo(file);

            hasVideo = (info.Video.Count > 0);
            if (hasVideo)
            {
                VideoTrack track = info.Video[0];
                width      = easyParseInt(track.Width);
                height     = easyParseInt(track.Height);
                frameCount = easyParseInt(track.FrameCount);
                fps        = easyParseDouble(track.FrameRate);
                vCodec     = getVideoCodec(track.Codec);
#warning should parse DAR properly, as commented below
                darX = width;
                darY = height;
//                darX = easyParseInt(track.AspectRatio.Substring()
            }
            aCodecs       = new AudioCodec[info.Audio.Count];
            aBitrateModes = new BitrateManagementMode[info.Audio.Count];
            int i = 0;
            foreach (AudioTrack track in info.Audio)
            {
                aCodecs[i] = getAudioCodec(track.Codec);
                if (track.BitRateMode == "VBR")
                {
                    aBitrateModes[i] = BitrateManagementMode.VBR;
                }
                else
                {
                    aBitrateModes[i] = BitrateManagementMode.CBR;
                }
            }
            if (info.General.Count < 1)
            {
                cType = null;
            }
            else
            {
                cType = getContainerType(info.General[0].Format, info.General[0].FormatString);
            }

            if (hasVideo)
            {
                vType = getVideoType(vCodec, cType);
            }
            else
            {
                vType = null;
            }

            if (aCodecs.Length == 1)
            {
                aType = getAudioType(aCodecs[0], cType);
            }
            else
            {
                aType = null;
            }
        }
Ejemplo n.º 2
0
        public MediaInfoFile(string file)
        {
            this.file = file;
            MediaInfo info = new MediaInfo(file);

            bool hasVideo = (info.Video.Count > 0);

            aCodecs       = new AudioCodec[info.Audio.Count];
            aBitrateModes = new BitrateManagementMode[info.Audio.Count];
            int i = 0;

            foreach (MediaInfoWrapper.AudioTrack track in info.Audio)
            {
                aCodecs[i] = getAudioCodec(track.Codec);
                if (track.BitRateMode == "VBR")
                {
                    aBitrateModes[i] = BitrateManagementMode.VBR;
                }
                else
                {
                    aBitrateModes[i] = BitrateManagementMode.CBR;
                }
            }
            if (info.General.Count < 1)
            {
                cType = null;
            }
            else
            {
                cType = getContainerType(info.General[0].Format, info.General[0].FormatString);
            }

            if (aCodecs.Length == 1)
            {
                aType = getAudioType(aCodecs[0], cType, file);
            }
            else
            {
                aType = null;
            }

            if (hasVideo)
            {
                MediaInfoWrapper.VideoTrack track = info.Video[0];
                checked
                {
                    ulong  width      = (ulong)easyParseInt(track.Width);
                    ulong  height     = (ulong)easyParseInt(track.Height);
                    ulong  frameCount = (ulong)easyParseInt(track.FrameCount);
                    double fps        = (easyParseDouble(track.FrameRate) ?? 25.0);
                    vCodec = getVideoCodec(track.Codec);
                    vType  = getVideoType(vCodec, cType, file);
                    Dar dar = new Dar((decimal?)easyParseDouble(track.AspectRatio), width, height);
                    this.info = new MediaFileInfo(hasVideo, width, height, dar, frameCount, fps, aCodecs.Length > 0);
                }
            }
            else
            {
                this.info = new MediaFileInfo(false, 0, 0, Dar.A1x1, 0, 0, aCodecs.Length > 0);
            }
        }