예제 #1
0
        private MediaInfoData GetMediaInfo(string location, MediaType mediaType)
        {
            Logger.ReportInfo("Getting media info from " + location);
            MediaInfoLib.MediaInfo mediaInfo = new MediaInfoLib.MediaInfo();
            mediaInfo.Option("ParseSpeed", "0.2");
            int i = mediaInfo.Open(location);
            MediaInfoData mediaInfoData = null;
            if (i != 0)
            {
                string subtitles = mediaInfo.Get(StreamKind.General, 0, "Text_Language_List");
                string scanType = mediaInfo.Get(StreamKind.Video, 0, "ScanType");
                int width;
                Int32.TryParse(mediaInfo.Get(StreamKind.Video, 0, "Width"), out width);
                int height;
                Int32.TryParse(mediaInfo.Get(StreamKind.Video, 0, "Height"), out height);
                int videoBitRate;
                Int32.TryParse(mediaInfo.Get(StreamKind.Video, 0, "BitRate"), out videoBitRate);

                int audioBitRate;
                string aBitRate = mediaInfo.Get(StreamKind.Audio, 0, "BitRate");
                int ABindex = aBitRate.IndexOf(" /");
                if (ABindex > 0)
                    aBitRate = aBitRate.Remove(ABindex);
                Int32.TryParse(aBitRate, out audioBitRate);

                int runTime;
                Int32.TryParse(mediaInfo.Get(StreamKind.General, 0, "PlayTime"), out runTime);
                int streamCount;
                Int32.TryParse(mediaInfo.Get(StreamKind.Audio, 0, "StreamCount"), out streamCount);

                string audioChannels = mediaInfo.Get(StreamKind.Audio, 0, "Channel(s)");
                int ACindex = audioChannels.IndexOf(" /");
                if (ACindex > 0)
                    audioChannels = audioChannels.Remove(ACindex);

                string audioLanguages = mediaInfo.Get(StreamKind.General, 0, "Audio_Language_List");

                string videoFrameRate = mediaInfo.Get(StreamKind.Video, 0, "FrameRate");

                string audioProfile = mediaInfo.Get(StreamKind.Audio, 0, "Format_Profile");
                int APindex = audioProfile.IndexOf(" /");
                if (APindex > 0)
                    audioProfile = audioProfile.Remove(APindex);

                mediaInfoData = new MediaInfoData
                {
                    PluginData = new MediaInfoData.MIData()
                    {
                        VideoCodec = mediaInfo.Get(StreamKind.Video, 0, "Codec/String"),
                        VideoBitRate = videoBitRate,
                        //MI.Get(StreamKind.Video, 0, "DisplayAspectRatio")),
                        Height = height,
                        Width = width,
                        //MI.Get(StreamKind.Video, 0, "Duration/String3")),
                        AudioFormat = mediaInfo.Get(StreamKind.Audio, 0, "Format"),
                        AudioBitRate = audioBitRate,
                        RunTime = (runTime / 60000),
                        AudioStreamCount = streamCount,
                        AudioChannelCount = audioChannels.Trim(),
                        AudioProfile = audioProfile.Trim(),
                        VideoFPS = videoFrameRate,
                        AudioLanguages = audioLanguages,
                        Subtitles = subtitles,
                        ScanType = scanType
                    }
                };
            }
            else
            {
                Logger.ReportInfo("Could not extract media information from " + location);
            }
            if (mediaType == MediaType.DVD && i != 0)
            {
                mediaInfo.Close();
                location = location.Replace("0.IFO", "1.vob");
                Logger.ReportInfo("Getting additional media info from " + location);
                mediaInfo.Option("ParseSpeed", "0.0");
                i = mediaInfo.Open(location);
                if (i != 0)
                {
                    int videoBitRate;
                    Int32.TryParse(mediaInfo.Get(StreamKind.Video, 0, "BitRate"), out videoBitRate);

                    int audioBitRate;
                    string aBitRate = mediaInfo.Get(StreamKind.Audio, 0, "BitRate");
                    int ABindex = aBitRate.IndexOf(" /");
                    if (ABindex > 0)
                        aBitRate = aBitRate.Remove(ABindex);
                    Int32.TryParse(aBitRate, out audioBitRate);
                    string scanType = mediaInfo.Get(StreamKind.Video, 0, "ScanType");

                    mediaInfoData.PluginData.AudioBitRate = audioBitRate;
                    mediaInfoData.PluginData.VideoBitRate = videoBitRate;
                    mediaInfoData.PluginData.ScanType = scanType;
                }
                else
                {
                    Logger.ReportInfo("Could not extract additional media info from " + location);
                }
            }
            mediaInfo.Close();
            return mediaInfoData;
        }
예제 #2
0
 private MediaInfoData Merge(MediaInfoData original, MediaInfoData acquired)
 {
     if (original == null) return acquired;
     if (original.PluginData.AudioBitRate == 0) original.PluginData.AudioBitRate = acquired.AudioBitRate;
     if (original.PluginData.AudioChannelCount == "") original.PluginData.AudioChannelCount = acquired.AudioChannelCount;
     if (original.PluginData.AudioFormat == "")
     {
         original.PluginData.AudioProfile = acquired.AudioProfile;
         original.PluginData.AudioFormat = acquired.AudioFormat;
     }
     if (original.PluginData.AudioStreamCount == 0) original.PluginData.AudioStreamCount = acquired.AudioStreamCount;
     if (original.PluginData.AudioLanguages == "") original.PluginData.AudioLanguages = acquired.AudioLanguages;
     if (original.PluginData.Height == 0) original.PluginData.Height = acquired.Height;
     if (original.PluginData.RunTime == 0) original.PluginData.RunTime = acquired.RunTime;
     if (original.PluginData.Subtitles == "") original.PluginData.Subtitles = acquired.Subtitles;
     if (original.PluginData.VideoBitRate == 0) original.PluginData.VideoBitRate = acquired.VideoBitRate;
     if (original.PluginData.VideoCodec == "") original.PluginData.VideoCodec = acquired.VideoCodec;
     if (original.PluginData.VideoFPS == "") original.PluginData.VideoFPS = acquired.VideoFPS;
     if (original.PluginData.ScanType == "") original.PluginData.ScanType = acquired.ScanType;
     if (original.PluginData.Width == 0) original.PluginData.Width = acquired.Width;
     return original;
 }
예제 #3
0
 private MediaInfoData GetMediaInfo(string location)
 {
     Logger.ReportInfo("getting media info from " + location);
     MediaInfo mediaInfo = new MediaInfo();
     int i = mediaInfo.Open(location);
     MediaInfoData mediaInfoData = null;
     if (i != 0)
     {
         int width;
         Int32.TryParse(mediaInfo.Get(StreamKind.Video, 0, "Width"), out width);
         int height;
         Int32.TryParse(mediaInfo.Get(StreamKind.Video, 0, "Height"), out height);
         int videoBitRate;
         Int32.TryParse(mediaInfo.Get(StreamKind.Video, 0, "BitRate"), out videoBitRate);
         int audioBitRate;
         Int32.TryParse(mediaInfo.Get(StreamKind.Audio, 0, "BitRate"), out audioBitRate);
         mediaInfoData = new MediaInfoData
         {
             VideoCodec = mediaInfo.Get(StreamKind.Video, 0, "CodecID/Hint"),
             VideoBitRate = videoBitRate,
             //MI.Get(StreamKind.Video, 0, "DisplayAspectRatio")),
             Height = height,
             Width = width,
             //MI.Get(StreamKind.Video, 0, "Duration/String3")),
             AudioFormat = mediaInfo.Get(StreamKind.Audio, 0, "Format"),
             AudioBitRate = audioBitRate
         };
     }
     else
     {
         Logger.ReportInfo("Could not extract media information from " + location);
     }
     mediaInfo.Close();
     return mediaInfoData;
 }