示例#1
0
        /// gets ID from a first video stream using MediaInfo
        /// </summary>
        /// <param name="infoFile">the file to be analyzed</param>
        /// <returns>the video track ID found</returns>
        public static int getIDFromFirstVideoStream(string fileName)
        {
            MediaInfo info;
            int       TrackID = 0;

            try
            {
                info = new MediaInfo(fileName);
                if (info.VideoCount >= 0)
                {
                    MediaInfoWrapper.VideoTrack vtrack = info.Video[0];
                    TrackID = Int32.Parse(vtrack.ID);
                }
            }
            catch (Exception i)
            {
                MessageBox.Show("The following error ocurred when trying to get Media info for file " + fileName + "\r\n" + i.Message, "Error parsing mediainfo data", MessageBoxButtons.OK);
            }
            return(TrackID);
        }
示例#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);
            }
        }