From 2e2562fefca8181349d67c8cfc93d35a13c4f2f7 Mon Sep 17 00:00:00 2001 From: stax76 Date: Sat, 4 Jun 2022 00:17:56 +0200 Subject: [PATCH] shorter media info to better fit on screen --- src/Misc/Commands.cs | 54 ++++++++++++++++++++------------------------ src/Misc/Player.cs | 36 +++++++++++++++++++++-------- 2 files changed, 51 insertions(+), 39 deletions(-) diff --git a/src/Misc/Commands.cs b/src/Misc/Commands.cs index 318c907..f438fa3 100644 --- a/src/Misc/Commands.cs +++ b/src/Misc/Commands.cs @@ -426,39 +426,35 @@ namespace mpvnet } string path = Core.GetPropertyString("path"); + string text = ""; - if (File.Exists(path) && !path.Contains(@"\\.\pipe\")) + bool full = args.Contains("full"); + bool raw = args.Contains("raw"); + bool editor = args.Contains("editor"); + bool osd = args.Contains("osd"); + + if (App.MediaInfo && !osd && File.Exists(path) && !path.Contains(@"\\.\pipe\")) + using (MediaInfo mediaInfo = new MediaInfo(path)) + text = Regex.Replace(mediaInfo.GetSummary(full, raw), "Unique ID.+", ""); + else { - string text = ""; + Core.UpdateExternalTracks(); + lock (Core.MediaTracksLock) + foreach (MediaTrack track in Core.MediaTracks) + text += track.Text + BR; + } - bool full = args.Contains("full"); - bool raw = args.Contains("raw"); - bool editor = args.Contains("editor"); - bool osd = args.Contains("osd"); + text = text.TrimEx(); - if (App.MediaInfo && !osd) - using (MediaInfo mediaInfo = new MediaInfo(path)) - text = Regex.Replace(mediaInfo.GetSummary(full, raw), "Unique ID.+", ""); - else - { - Core.UpdateExternalTracks(); - lock (Core.MediaTracksLock) - foreach (MediaTrack track in Core.MediaTracks) - text += track.Text + BR; - } - - text = text.TrimEx(); - - if (editor) - ShowTextWithEditor("media-info", text); - else if (osd) - ShowText(text.Replace("\r", ""), 5000, 15); - else - { - MsgBoxEx.MessageBoxEx.MsgFontFamily = new FontFamily("Consolas"); - Msg.ShowInfo(text); - MsgBoxEx.MessageBoxEx.MsgFontFamily = new FontFamily("Segoe UI"); - } + if (editor) + ShowTextWithEditor("media-info", text); + else if (osd) + ShowText(text.Replace("\r", ""), 5000, 17); + else + { + MsgBoxEx.MessageBoxEx.MsgFontFamily = new FontFamily("Consolas"); + Msg.ShowInfo(text); + MsgBoxEx.MessageBoxEx.MsgFontFamily = new FontFamily("Segoe UI"); } }); diff --git a/src/Misc/Player.cs b/src/Misc/Player.cs index 5e638b4..79b3b7b 100644 --- a/src/Misc/Player.cs +++ b/src/Misc/Player.cs @@ -1480,8 +1480,13 @@ namespace mpvnet if (type == "video") { + string codec = GetPropertyString($"track-list/{i}/codec").ToUpperEx(); + if (codec == "MPEG2VIDEO") + codec = "MPEG2"; + else if (codec == "DVVIDEO") + codec = "DV"; MediaTrack track = new MediaTrack(); - Add(track, GetPropertyString($"track-list/{i}/codec").ToUpperEx()); + Add(track, codec); Add(track, GetPropertyString($"track-list/{i}/demux-w") + "x" + GetPropertyString($"track-list/{i}/demux-h")); Add(track, GetPropertyString($"track-list/{i}/demux-fps").Replace(".000000", "") + " FPS"); Add(track, GetPropertyBool($"track-list/{i}/default") ? "Default" : null); @@ -1492,10 +1497,13 @@ namespace mpvnet } else if (type == "audio") { + string codec = GetPropertyString($"track-list/{i}/codec").ToUpperEx(); + if (codec.Contains("PCM")) + codec = "PCM"; MediaTrack track = new MediaTrack(); Add(track, GetLanguage(GetPropertyString($"track-list/{i}/lang"))); - Add(track, GetPropertyString($"track-list/{i}/codec").ToUpperEx()); - Add(track, GetPropertyInt($"track-list/{i}/audio-channels") + " channels"); + Add(track, codec); + Add(track, GetPropertyInt($"track-list/{i}/audio-channels") + " ch"); Add(track, GetPropertyInt($"track-list/{i}/demux-samplerate") / 1000 + " kHz"); Add(track, GetPropertyBool($"track-list/{i}/forced") ? "Forced" : null); Add(track, GetPropertyBool($"track-list/{i}/default") ? "Default" : null); @@ -1509,12 +1517,16 @@ namespace mpvnet } else if (type == "sub") { - string codec = GetPropertyString($"track-list/{i}/codec"); - if (codec.Contains("pgs")) - codec = "pgs"; + string codec = GetPropertyString($"track-list/{i}/codec").ToUpperEx(); + if (codec.Contains("PGS")) + codec = "PGS"; + else if (codec == "DVB_SUBTITLE") + codec = "DVB"; + else if (codec == "DVD_SUBTITLE") + codec = "VOB"; MediaTrack track = new MediaTrack(); Add(track, GetLanguage(GetPropertyString($"track-list/{i}/lang"))); - Add(track, codec.ToUpperEx()); + Add(track, codec); Add(track, GetPropertyBool($"track-list/{i}/forced") ? "Forced" : null); Add(track, GetPropertyBool($"track-list/{i}/default") ? "Default" : null); Add(track, GetPropertyBool($"track-list/{i}/external") ? "External" : null); @@ -1524,7 +1536,6 @@ namespace mpvnet track.ID = GetPropertyInt($"track-list/{i}/id"); track.External = external; tracks.Add(track); - Debug.WriteLine(GetPropertyString($"track-list/{i}/codec")); } } @@ -1558,11 +1569,16 @@ namespace mpvnet for (int i = 0; i < videoCount; i++) { + string fps = mi.GetVideo(i, "FrameRate"); + + if (float.TryParse(fps, NumberStyles.Float, CultureInfo.InvariantCulture, out float result)) + fps = result.ToString(CultureInfo.InvariantCulture); + MediaTrack track = new MediaTrack(); Add(track, mi.GetVideo(i, "Format")); Add(track, mi.GetVideo(i, "Format_Profile")); Add(track, mi.GetVideo(i, "Width") + "x" + mi.GetVideo(i, "Height")); - Add(track, mi.GetVideo(i, "FrameRate") + " FPS"); + Add(track, fps + " FPS"); Add(track, mi.GetVideo(i, "Language/String")); Add(track, mi.GetVideo(i, "Forced") == "Yes" ? "Forced" : ""); Add(track, mi.GetVideo(i, "Default") == "Yes" ? "Default" : ""); @@ -1582,7 +1598,7 @@ namespace mpvnet Add(track, mi.GetAudio(i, "Format")); Add(track, mi.GetAudio(i, "Format_Profile")); Add(track, mi.GetAudio(i, "BitRate/String")); - Add(track, mi.GetAudio(i, "Channel(s)/String")); + Add(track, mi.GetAudio(i, "Channel(s)") + " ch"); Add(track, mi.GetAudio(i, "SamplingRate/String")); Add(track, mi.GetAudio(i, "Forced") == "Yes" ? "Forced" : ""); Add(track, mi.GetAudio(i, "Default") == "Yes" ? "Default" : "");