public IRemoteUrl GetParsedUrlInfo() { if (URLInfo == null) { return(null); } IVideoInfo[] vis = VideoInfos.Where(dvi => dvi.Checked).ToArray(); return(new RemoteUrl(URLInfo.SourceIp, URLInfo.SourcePort, URLInfo.BeginTime, URLInfo.EndTime, vis, null)); }
private void doStartDownloadCmd() { if (URLInfo == null) { MessageBox.Show("解析到无效的URL。"); return; } DownloadVideoInfo[] dvis = VideoInfos.Where(dvi => dvi.Checked).ToArray(); if (dvis.Length == 0) { MessageBox.Show("未选中任何视频。"); return; } if (string.IsNullOrWhiteSpace(DownloadName)) { MessageBox.Show("无效的保存名称。"); return; } OnStartDownload(); }
public FileInfo(string url) { #if DEBUG var length = new System.IO.FileInfo(url).Length; var sw = new Stopwatch(); sw.Start(); #endif MediaInfo MI = null; try { MI = new MediaInfo(); MI.Open(url); MI.Option("Complete"); Summary = MI.Inform(); GeneralInfo.Filename = Path.GetFileNameWithoutExtension(url); GeneralInfo.FullPath = url; GeneralInfo.Format = MI.Get(StreamKind.General, 0, "Format"); GeneralInfo.Bitrate = MI.Get(StreamKind.General, 0, "OverallBitRate").TryParseAsInt() / 1000; GeneralInfo.VideoCount = MI.Get(StreamKind.General, 0, "VideoCount").TryParseAsInt(); GeneralInfo.AudioCount = MI.Get(StreamKind.General, 0, "AudioCount").TryParseAsInt(); GeneralInfo.TextCount = MI.Get(StreamKind.General, 0, "TextCount").TryParseAsInt(); switch (MI.Get(StreamKind.General, 0, "MenuCount").TryParseAsInt()) { case 0: GeneralInfo.ChapterCount = 0; break; case 1: GeneralInfo.ChapterCount = MI.Get(StreamKind.Menu, 0, "Chapters_Pos_End").TryParseAsInt() - MI.Get(StreamKind.Menu, 0, "Chapters_Pos_Begin").TryParseAsInt(); break; default: GeneralInfo.ChapterCount = -1; break; } for (var i = 0; i < GeneralInfo.VideoCount; i++) { VideoInfos.Add(new VideoInfo { Format = MI.Get(StreamKind.Video, i, "Format"), FormatProfile = MI.Get(StreamKind.Video, i, "Format_Profile"), FpsMode = MI.Get(StreamKind.Video, i, "FrameRate_Mode"), Fps = MI.Get(StreamKind.Video, i, "FrameRate/String").Replace(" FPS", ""), Bitrate = MI.Get(StreamKind.Video, i, "BitRate").TryParseAsInt() / 1000, BitDepth = MI.Get(StreamKind.Video, i, "BitDepth").TryParseAsInt(), Duration = MI.Get(StreamKind.Video, i, "Duration").TryParseAsInt(), Height = MI.Get(StreamKind.Video, i, "Height").TryParseAsInt(), Width = MI.Get(StreamKind.Video, i, "Width").TryParseAsInt(), Language = MI.Get(StreamKind.Video, i, "Language/String3").ToUpper(), Delay = MI.Get(StreamKind.Audio, i, "Delay").TryParseAsInt(), Profile = new ProfileInfo(MI.Get(StreamKind.Video, i, "Format_Profile")) }); #if DEBUG Debug.WriteLine(MI.Get(StreamKind.Video, i, "Stored_Width")); Debug.WriteLine(MI.Get(StreamKind.Video, i, "Stored_Height")); Debug.WriteLine(MI.Get(StreamKind.Video, i, "Sampled_Width")); Debug.WriteLine(MI.Get(StreamKind.Video, i, "Sampled_Height")); Debug.WriteLine(MI.Get(StreamKind.Video, i, "PixelAspectRatio")); Debug.WriteLine(MI.Get(StreamKind.Video, i, "PixelAspectRatio/String")); Debug.WriteLine(MI.Get(StreamKind.Video, i, "PixelAspectRatio_Original")); Debug.WriteLine("ScanType:" + MI.Get(StreamKind.Video, i, "ScanType")); Debug.WriteLine("ScanType/String:" + MI.Get(StreamKind.Video, i, "ScanType/String")); Debug.WriteLine("FormatProfile:" + MI.Get(StreamKind.Video, i, "Format_Profile")); Debug.WriteLine("FormatLevel:" + MI.Get(StreamKind.Video, i, "Format_Level")); Debug.WriteLine("FormatTier:" + MI.Get(StreamKind.Video, i, "Format_Tier")); #endif } for (var i = 0; i < GeneralInfo.AudioCount; i++) { AudioInfos.Add(new AudioInfo { Format = MI.Get(StreamKind.Audio, i, "Format"), BitDepth = MI.Get(StreamKind.Audio, i, "BitDepth").TryParseAsInt(), Bitrate = MI.Get(StreamKind.Audio, i, "BitRate").TryParseAsInt() / 1000, Duration = MI.Get(StreamKind.Audio, i, "Duration").TryParseAsInt(), Language = MI.Get(StreamKind.Audio, i, "Language/String3").ToUpper(), Delay = MI.Get(StreamKind.Audio, i, "Delay").TryParseAsInt() }); } if (GeneralInfo.ChapterCount > 0) { for (var i = MI.Get(StreamKind.Menu, 0, "Chapters_Pos_Begin").TryParseAsInt(); i < MI.Get(StreamKind.Menu, 0, "Chapters_Pos_End").TryParseAsInt(); i++) { var a = GeneralInfo.Format == "Matroska" ? MI.Get(StreamKind.Menu, 0, i, InfoKind.Text).Split(new[] { ':' }, 2) : new[] { "", MI.Get(StreamKind.Menu, 0, i, InfoKind.Text) }; ChapterInfos.Add(new ChapterInfo { Timespan = MI.Get(StreamKind.Menu, 0, i, InfoKind.Name).TryParseAsMillisecond(), Language = a[0], Name = a[1] }); } } } finally { MI?.Close(); } #if DEBUG sw.Stop(); Debug.WriteLine($"Loading: {url}\r\nCost {sw.ElapsedMilliseconds}ms! Length: {length}bytes"); #endif }