private void GetInfo() { try { tbxInfo.ToolTip = null; //Чтоб не мешался if (infomode == InfoMode.MediaInfo) { //http://mediainfo.sourceforge.net/en/Support/SDK/More_Info //краткая инфа MediaInfoWrapper media = new MediaInfoWrapper(); media.Open(infilepath); media.Option("Complete", ""); media.Option("Language", " Config_Text_ColumnSize;" + Settings.MI_ColumnSize); tbxInfo.Text = media.Option("Info_Version", "") + "\r\n\r\n"; tbxInfo.Text += media.Inform(); media.Close(); } else if (infomode == InfoMode.MediaInfoFull) { //полная инфа MediaInfoWrapper media = new MediaInfoWrapper(); media.Open(infilepath); media.Option("Complete", "1"); media.Option("Language", " Config_Text_ColumnSize;" + Settings.MI_ColumnSize); tbxInfo.Text = media.Option("Info_Version", "") + "\r\n\r\n"; tbxInfo.Text += media.Inform(); media.Close(); } else if (infomode == InfoMode.MP4BoxInfo) { encoderProcess = new Process(); ProcessStartInfo info = new ProcessStartInfo(); info.FileName = Calculate.StartupPath + "\\apps\\MP4Box\\MP4Box.exe"; info.WorkingDirectory = Path.GetDirectoryName(info.FileName); info.UseShellExecute = false; info.RedirectStandardOutput = false; info.RedirectStandardError = true; info.CreateNoWindow = true; info.Arguments = "-info \"" + infilepath + "\""; encoderProcess.StartInfo = info; encoderProcess.Start(); tbxInfo.Text = encoderProcess.StandardError.ReadToEnd(); } else if (infomode == InfoMode.MKVInfo) { encoderProcess = new Process(); ProcessStartInfo info = new ProcessStartInfo(); info.FileName = Calculate.StartupPath + "\\apps\\MKVtoolnix\\mkvinfo.exe"; info.WorkingDirectory = Path.GetDirectoryName(info.FileName); info.UseShellExecute = false; info.StandardOutputEncoding = System.Text.Encoding.UTF8; info.RedirectStandardOutput = true; info.RedirectStandardError = false; info.CreateNoWindow = true; info.Arguments = "\"" + infilepath + "\" --output-charset UTF-8"; encoderProcess.StartInfo = info; encoderProcess.Start(); tbxInfo.Text = encoderProcess.StandardOutput.ReadToEnd(); } else if (infomode == InfoMode.FFmpegInfo) { ff = new FFInfo(); ff.Open(infilepath); if (ff.info.Length > 0) { string sortedinfo = ""; string[] lines = ff.info.ToString().Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); foreach (string line in lines) { if (!line.StartsWith("At least one output")) { sortedinfo += line + Environment.NewLine; } } tbxInfo.Text = sortedinfo + "\r\n\r\n"; } else { tbxInfo.Clear(); } //Размер файла string size_s = ""; double size = (new FileInfo(infilepath).Length) / 1048576.0; if (size > 1024) { size_s = (size / 1024.0).ToString("0.##", new System.Globalization.CultureInfo("en-US")) + " Gb\r\n"; } else { size_s = size.ToString("0.##", new System.Globalization.CultureInfo("en-US")) + " Mb\r\n"; } //Общая инфа tbxInfo.Text += "General:\r\n"; tbxInfo.Text += "Total streams : " + ff.StreamsCount() + " (Video: " + ff.VideoStreams().Count + ", Audio: " + ff.AudioStreams().Count + ")\r\n"; tbxInfo.Text += "Total duration : " + ff.Timeline() + " (" + ff.Duration().TotalSeconds.ToString("0.##", new System.Globalization.CultureInfo("en-US")) + " seconds)\r\n"; tbxInfo.Text += "Total bitrate : " + ff.TotalBitrate() + " Kbps\r\n"; tbxInfo.Text += "Total size : " + size_s; //Видео треки int v_count = ff.VideoStreams().Count, v_num = 1; foreach (int num in ff.VideoStreams()) { tbxInfo.Text += "\r\nVideo stream #" + v_num + ":\r\n"; tbxInfo.Text += "ID : 0." + num + Environment.NewLine; tbxInfo.Text += "Codec : " + ff.StreamCodec(num) + Environment.NewLine; tbxInfo.Text += "Width : " + ff.StreamW(num) + " pixels\r\n"; tbxInfo.Text += "Height : " + ff.StreamH(num) + " pixels\r\n"; tbxInfo.Text += "Aspect (DAR) : " + ff.StreamDAR(num) + Environment.NewLine; tbxInfo.Text += "Aspect (SAR) : " + ff.StreamSAR(num) + Environment.NewLine; tbxInfo.Text += "Colorspace : " + ff.StreamColor(num) + Environment.NewLine; tbxInfo.Text += "Framerate : " + ff.StreamFramerate(num) + " fps\r\n"; tbxInfo.Text += "Bitrate : " + ff.VideoBitrate(num) + " Kbps\r\n"; v_num += 1; } //Аудио треки int a_count = ff.AudioStreams().Count, a_num = 1; foreach (int num in ff.AudioStreams()) { tbxInfo.Text += "\r\nAudio stream #" + a_num + ":\r\n"; tbxInfo.Text += "ID : 0." + num + Environment.NewLine; tbxInfo.Text += "Codec : " + ff.StreamCodec(num) + Environment.NewLine; tbxInfo.Text += "Channels : " + ff.StreamChannels(num) + Environment.NewLine; tbxInfo.Text += "Samplerate : " + ff.StreamSamplerate(num) + " Hz\r\n"; tbxInfo.Text += "Language : " + ff.StreamLanguage(num) + Environment.NewLine; tbxInfo.Text += "Bitrate : " + ff.AudioBitrate(num) + " Kbps\r\n"; tbxInfo.Text += "Bits : " + ff.StreamBits(num) + Environment.NewLine; a_num += 1; } } } catch (Exception ex) { ErrorException(ex); } finally { CloseEXE(); CloseFFInfo(); } }
private void GetInfo() { try { tbxInfo.ToolTip = null; //Чтоб не мешался if (infomode == InfoMode.MediaInfo) { //http://mediainfo.sourceforge.net/en/Support/SDK/More_Info //краткая инфа MediaInfoWrapper media = new MediaInfoWrapper(); media.Open(infilepath); media.Option("Complete", ""); media.Option("Language", " Config_Text_ColumnSize;" + Settings.MI_ColumnSize); tbxInfo.Text = media.Option("Info_Version", "") + "\r\n\r\n"; tbxInfo.Text += media.Inform(); media.Close(); } else if (infomode == InfoMode.MediaInfoFull) { //полная инфа MediaInfoWrapper media = new MediaInfoWrapper(); media.Open(infilepath); media.Option("Complete", "1"); media.Option("Language", " Config_Text_ColumnSize;" + Settings.MI_ColumnSize); tbxInfo.Text = media.Option("Info_Version", "") + "\r\n\r\n"; tbxInfo.Text += media.Inform(); media.Close(); } else if (infomode == InfoMode.MP4BoxInfo) { encoderProcess = new Process(); ProcessStartInfo info = new ProcessStartInfo(); info.FileName = Calculate.StartupPath + "\\apps\\MP4Box\\MP4Box.exe"; info.WorkingDirectory = Path.GetDirectoryName(info.FileName); info.UseShellExecute = false; info.RedirectStandardOutput = false; info.RedirectStandardError = true; info.CreateNoWindow = true; info.Arguments = "-info \"" + infilepath + "\""; encoderProcess.StartInfo = info; encoderProcess.Start(); tbxInfo.Text = encoderProcess.StandardError.ReadToEnd(); } else if (infomode == InfoMode.MKVInfo) { encoderProcess = new Process(); ProcessStartInfo info = new ProcessStartInfo(); info.FileName = Calculate.StartupPath + "\\apps\\MKVtoolnix\\mkvinfo.exe"; info.WorkingDirectory = Path.GetDirectoryName(info.FileName); info.UseShellExecute = false; info.StandardOutputEncoding = System.Text.Encoding.UTF8; info.RedirectStandardOutput = true; info.RedirectStandardError = false; info.CreateNoWindow = true; info.Arguments = "\"" + infilepath + "\" --output-charset UTF-8"; encoderProcess.StartInfo = info; encoderProcess.Start(); tbxInfo.Text = encoderProcess.StandardOutput.ReadToEnd(); } else if (infomode == InfoMode.FFmpegInfo) { ff = new FFInfo(); ff.Open(infilepath); if (ff.info.Length > 0) { string sortedinfo = ""; string[] lines = ff.info.ToString().Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); foreach (string line in lines) { if (!line.StartsWith("At least one output")) sortedinfo += line + Environment.NewLine; } tbxInfo.Text = sortedinfo + "\r\n\r\n"; } else tbxInfo.Clear(); //Размер файла string size_s = ""; double size = (new FileInfo(infilepath).Length) / 1048576.0; if (size > 1024) size_s = (size / 1024.0).ToString("0.##", new System.Globalization.CultureInfo("en-US")) + " Gb\r\n"; else size_s = size.ToString("0.##", new System.Globalization.CultureInfo("en-US")) + " Mb\r\n"; //Общая инфа tbxInfo.Text += "General:\r\n"; tbxInfo.Text += "Total streams : " + ff.StreamsCount() + " (Video: " + ff.VideoStreams().Count + ", Audio: " + ff.AudioStreams().Count + ")\r\n"; tbxInfo.Text += "Total duration : " + ff.Timeline() + " (" + ff.Duration().TotalSeconds.ToString("0.##", new System.Globalization.CultureInfo("en-US")) + " seconds)\r\n"; tbxInfo.Text += "Total bitrate : " + ff.TotalBitrate() + " Kbps\r\n"; tbxInfo.Text += "Total size : " + size_s; //Видео треки int v_count = ff.VideoStreams().Count, v_num = 1; foreach (int num in ff.VideoStreams()) { tbxInfo.Text += "\r\nVideo stream #" + v_num + ":\r\n"; tbxInfo.Text += "ID : 0." + num + Environment.NewLine; tbxInfo.Text += "Codec : " + ff.StreamCodec(num) + Environment.NewLine; tbxInfo.Text += "Width : " + ff.StreamW(num) + " pixels\r\n"; tbxInfo.Text += "Height : " + ff.StreamH(num) + " pixels\r\n"; tbxInfo.Text += "Aspect (DAR) : " + ff.StreamDAR(num) + Environment.NewLine; tbxInfo.Text += "Aspect (SAR) : " + ff.StreamSAR(num) + Environment.NewLine; tbxInfo.Text += "Colorspace : " + ff.StreamColor(num) + Environment.NewLine; tbxInfo.Text += "Framerate : " + ff.StreamFramerate(num) + " fps\r\n"; tbxInfo.Text += "Bitrate : " + ff.VideoBitrate(num) + " Kbps\r\n"; v_num += 1; } //Аудио треки int a_count = ff.AudioStreams().Count, a_num = 1; foreach (int num in ff.AudioStreams()) { tbxInfo.Text += "\r\nAudio stream #" + a_num + ":\r\n"; tbxInfo.Text += "ID : 0." + num + Environment.NewLine; tbxInfo.Text += "Codec : " + ff.StreamCodec(num) + Environment.NewLine; tbxInfo.Text += "Channels : " + ff.StreamChannels(num) + Environment.NewLine; tbxInfo.Text += "Samplerate : " + ff.StreamSamplerate(num) + " Hz\r\n"; tbxInfo.Text += "Language : " + ff.StreamLanguage(num) + Environment.NewLine; tbxInfo.Text += "Bitrate : " + ff.AudioBitrate(num) + " Kbps\r\n"; tbxInfo.Text += "Bits : " + ff.StreamBits(num) + Environment.NewLine; a_num += 1; } } } catch (Exception ex) { ErrorException(ex); } finally { CloseEXE(); CloseFFInfo(); } }