private void QueryMediaFile(string path) { MediaInfoLib.MediaInfo MI = new MediaInfoLib.MediaInfo(); MI.Open(path); int i; DIFeature difeature = new DIFeature(); difeature.Filesize = (int)(ToInt64(MI.Get(0, 0, "FileSize")) / 1024 / 1024); // MB try { difeature.Duration = TimeSpan.FromMilliseconds(Convert.ToDouble(MI.Get(0, 0, "Duration"))); // Minutes } catch { } difeature.OverallBitRate = ToInt32(MI.Get(0, 0, "OverallBitRate")) / 1000; // kbps difeature.Format = MI.Get(0, 0, "Format"); difeature.Name = path; int videostreamscount = ToInt32(MI.Get(MediaInfoLib.StreamKind.Video, 0, "StreamCount")); Console.WriteLine("\nVideo Stream Count : " + videostreamscount.ToString()); try { for (i = 0; i < videostreamscount; i++) { DIVideoStream divideostream = new DIVideoStream(); divideostream.FrameRate = (float)Convert.ToDouble(MI.Get(MediaInfoLib.StreamKind.Video, i, "FrameRate")); divideostream.Bitrate = ToInt32(MI.Get(MediaInfoLib.StreamKind.Video, i, "BitRate")) / 1000; divideostream.Resolution = new Size( ToInt32(MI.Get(MediaInfoLib.StreamKind.Video, i, "Width")), ToInt32(MI.Get(MediaInfoLib.StreamKind.Video, i, "Height"))); divideostream.Format = MI.Get(MediaInfoLib.StreamKind.Video, i, "Format"); divideostream.AspectRatio = MI.Get(MediaInfoLib.StreamKind.Video, i, "DisplayAspectRatio/String"); divideostream.ScanType = MI.Get(MediaInfoLib.StreamKind.Video, i, "ScanType"); divideostream.TitleID = ToInt32(MI.Get(MediaInfoLib.StreamKind.Video, i, "ID")); divideostream.Name = MI.Get(MediaInfoLib.StreamKind.Video, i, "Title"); difeature.VideoStreams.Add(divideostream); } } catch (Exception ex) { Utilities.DebugLine("[DiskInfo:QueryMediaFile] An error occured during file scan: {0}", ex.Message); } try { int audiostreamscount = ToInt32(MI.Get(MediaInfoLib.StreamKind.Audio, 0, "StreamCount")); Console.WriteLine("\nAudio Stream Count : " + audiostreamscount.ToString()); for (i = 0; i < audiostreamscount; i++) { DIAudioStream diaudiostream = new DIAudioStream(); diaudiostream.LanguageID = MI.Get(MediaInfoLib.StreamKind.Audio, i, "Language"); diaudiostream.BitrateMode = MI.Get(MediaInfoLib.StreamKind.Audio, i, "BitRate_Mode"); diaudiostream.Bitrate = ToInt32(MI.Get(MediaInfoLib.StreamKind.Audio, i, "BitRate")) / 1000; diaudiostream.Channels = ToInt32(MI.Get(MediaInfoLib.StreamKind.Audio, i, "Channels")); diaudiostream.AudioID = ToInt32(MI.Get(MediaInfoLib.StreamKind.Audio, i, "ID")); diaudiostream.Name = diaudiostream.Language; if (diaudiostream.Channels > 0) { diaudiostream.Name = diaudiostream.Name + " " + diaudiostream.Channels.ToString() + "ch"; } // Initialise fields diaudiostream.EncodingProfile = DIAudioEncodingProfile.Undefined; diaudiostream.SubFormat = ""; switch (MI.Get(MediaInfoLib.StreamKind.Audio, i, "Format")) { case "AC-3": diaudiostream.Encoding = DIAudioEncoding.AC3; diaudiostream.EncodingProfile = DIAudioEncodingProfile.Undefined; break; case "DTS": diaudiostream.Encoding = DIAudioEncoding.DTS; diaudiostream.EncodingProfile = DIAudioEncodingProfile.Undefined; break; case "AAC": diaudiostream.Encoding = DIAudioEncoding.AAC; diaudiostream.EncodingProfile = DIAudioEncodingProfile.Undefined; break; case "Vorbis": diaudiostream.Encoding = DIAudioEncoding.VORBIS; diaudiostream.EncodingProfile = DIAudioEncodingProfile.Undefined; break; case "MPEG Audio": switch (MI.Get(MediaInfoLib.StreamKind.Audio, i, "Format_Version")) { case "Version 1": diaudiostream.Encoding = DIAudioEncoding.MPEG1; break; case "Version 2": diaudiostream.Encoding = DIAudioEncoding.MPEG2; break; default: diaudiostream.Encoding = DIAudioEncoding.Undefined; break; } switch (MI.Get(MediaInfoLib.StreamKind.Audio, i, "Format_Profile")) { case "Layer 2": diaudiostream.EncodingProfile = DIAudioEncodingProfile.Layer2; break; case "Layer 3": diaudiostream.EncodingProfile = DIAudioEncodingProfile.Layer3; break; default: diaudiostream.EncodingProfile = DIAudioEncodingProfile.Undefined; break; } break; case "WMA2": diaudiostream.Encoding = DIAudioEncoding.WMA2; switch (MI.Get(MediaInfoLib.StreamKind.Audio, i, "Format_Profile")) { case "L1": diaudiostream.EncodingProfile = DIAudioEncodingProfile.L1; break; case "L2": diaudiostream.EncodingProfile = DIAudioEncodingProfile.L2; break; default: diaudiostream.EncodingProfile = DIAudioEncodingProfile.Undefined; break; } break; default: diaudiostream.Encoding = DIAudioEncoding.Undefined; diaudiostream.EncodingProfile = DIAudioEncodingProfile.Undefined; break; } difeature.AudioStreams.Add(diaudiostream); } } catch (Exception ex) { Utilities.DebugLine("[DiskInfo:QueryMediaFile] An error occured during file scan: {0}", ex.Message); } Console.WriteLine(MI.Count_Get(MediaInfoLib.StreamKind.Audio)); Console.WriteLine(MI.Get(MediaInfoLib.StreamKind.General, 0, "AudioCount")); Console.WriteLine(MI.Get(MediaInfoLib.StreamKind.Audio, 0, "StreamCount")); DiskFeatures.Add(difeature); MI.Close(); }
private void QueryDVD(string path) { // Check to see if any IFO files exist if (Directory.GetFiles(path, "*.ifo").Length == 0) { // No IFO Files Found // Try to see if there is a VIDEO_TS folder if (Directory.Exists(System.IO.Path.Combine(path, "VIDEO_TS"))) { path = System.IO.Path.Combine(path, "VIDEO_TS"); if (Directory.GetFiles(path, "*.ifo").Length == 0) { return; } } } DVDDiskInfo ddi = DVDDiskInfo.ParseDVD(path); foreach (DVDTitle dt in ddi.Titles) { DIFeature difeature = new DIFeature(); DIVideoStream divideostream = new DIVideoStream(); difeature.Duration = dt.Duration; difeature.Name = dt.ToString(); divideostream.AspectRatio = dt.AspectRatio.ToString(); divideostream.Name = dt.ToString(); divideostream.TitleID = dt.TitleNumber; divideostream.FrameRate = (float)dt.FPS; divideostream.Resolution = dt.Resolution; TimeSpan starttime = new TimeSpan(0); foreach (DVDChapter ch in dt.Chapters) { DIChapter dichapter = new DIChapter(); dichapter.ChapterNumber = ch.ChapterNumber; dichapter.StartTime = starttime; dichapter.Duration = ch.Duration; dichapter.Frames = ch.Frames; dichapter.TotalFrames = ch.TotalFrames; difeature.Chapters.Add(dichapter); starttime += ch.Duration; } foreach (DVDAudioTrack at in dt.AudioTracks) { DIAudioStream diaudiostream = new DIAudioStream(); diaudiostream.Name = at.ToString(); diaudiostream.Encoding = (DIAudioEncoding)at.Format; diaudiostream.EncodingProfile = DIAudioEncodingProfile.Undefined; diaudiostream.LanguageID = at.LanguageID; diaudiostream.SampleFreq = at.Frequency; diaudiostream.AudioID = at.ID; diaudiostream.Bitrate = at.Bitrate; diaudiostream.Channels = at.Channels; diaudiostream.TrackNo = at.TrackNumber; diaudiostream.SubFormat = at.SubFormat; difeature.AudioStreams.Add(diaudiostream); } difeature.VideoStreams.Add(divideostream); DiskFeatures.Add(difeature); } }