public MediaFile(List <MediaTrack> tracks, Chapters chapters, TimeSpan playTime, ContainerType container) { this.Container = container; AudioTracks = new List <AudioTrack>(); SubtitleTracks = new List <SubtitleTrack>(); foreach (MediaTrack m in tracks) { if (m is VideoTrack) { Debug.Assert(VideoTrack == null, "Only one video track per file supported"); VideoTrack = (VideoTrack)m; } if (m is AudioTrack) { AudioTracks.Add((AudioTrack)m); } if (m is SubtitleTrack) { SubtitleTracks.Add((SubtitleTrack)m); } } tracks.Sort( delegate(MediaTrack a, MediaTrack b) { return((int)a.TrackNumber - (int)b.TrackNumber); }); Tracks = tracks; Chapters = chapters; PlayTime = playTime; }
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; } }
public MediaFile(List<MediaTrack> tracks, Chapters chapters, TimeSpan playTime, ContainerType container) { this.Container = container; AudioTracks = new List<AudioTrack>(); SubtitleTracks = new List<SubtitleTrack>(); foreach (MediaTrack m in tracks) { if (m is VideoTrack) { Debug.Assert(VideoTrack == null, "Only one video track per file supported"); VideoTrack = (VideoTrack)m; } if (m is AudioTrack) AudioTracks.Add((AudioTrack)m); if (m is SubtitleTrack) SubtitleTracks.Add((SubtitleTrack)m); } tracks.Sort( delegate(MediaTrack a, MediaTrack b) { return (int)a.TrackNumber - (int)b.TrackNumber; }); Tracks = tracks; Chapters = chapters; PlayTime = playTime; }
public static MediaFile Open(string file) { try { MediaInfo m = new MediaInfo(file); // tracks List <MediaTrack> tracks = new List <MediaTrack>(); foreach (MediaInfoWrapper.VideoTrack t in m.Video) { VideoTrack v = new VideoTrack(); v.Codec = v.VCodec = getVideoCodec(t.Codec); v.Info = new MeGUI.core.details.TrackInfo(t.Language, t.Title); ulong width = ulong.Parse(t.Width); ulong height = ulong.Parse(t.Height); ulong frameCount = ulong.Parse(t.FrameCount); double fps = double.Parse(t.FrameRate); decimal?ar = easyParse <decimal>(delegate { return(decimal.Parse(t.AspectRatio)); }); Dar dar = new Dar(ar, width, height); v.StreamInfo = new VideoInfo2(width, height, dar, frameCount, fps); v.TrackNumber = uint.Parse(t.ID); tracks.Add(v); } foreach (MediaInfoWrapper.AudioTrack t in m.Audio) { AudioTrack a = new AudioTrack(); a.Codec = a.ACodec = getAudioCodec(t.Codec); a.Info = new MeGUI.core.details.TrackInfo(t.Language, t.Title); a.StreamInfo = new AudioInfo(); a.TrackNumber = uint.Parse(t.ID); tracks.Add(a); } foreach (MediaInfoWrapper.TextTrack t in m.Text) { SubtitleTrack s = new SubtitleTrack(); s.Codec = s.SCodec = getSubtitleCodec(t.Codec); s.Info = new MeGUI.core.details.TrackInfo(t.Language, t.Title); s.StreamInfo = new SubtitleInfo2(); s.TrackNumber = uint.Parse(t.ID); tracks.Add(s); } if (m.General.Count != 1) { throw new Exception("Expected one general track"); } GeneralTrack g = m.General[0]; ContainerType cType = getContainerType(g.Format, g.FormatString); TimeSpan playTime = TimeSpan.Parse(g.PlayTimeString3); Chapters chapters = null; if (m.Chapters.Count == 1) { chapters = parseChapters(m.Chapters[0]); } return(new MediaFile(tracks, chapters, playTime, cType)); } catch (Exception) { return(null); } }