From e14e0895604e15d101bb63968fd2d8a531fef0dd Mon Sep 17 00:00:00 2001 From: Alexander Vinogradov Date: Sat, 24 Oct 2026 00:23:03 +0300 Subject: [PATCH 1/2] Fix culture-dependent video rotation parsing --- QuickLook.Plugin/QuickLook.Plugin.VideoViewer/Plugin.cs | 8 +++----- .../QuickLook.Plugin.VideoViewer/ViewerPanel.xaml.cs | 6 ++---- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/Plugin.cs b/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/Plugin.cs index 311c725c7..2cb24820a 100644 --- a/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/Plugin.cs +++ b/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/Plugin.cs @@ -19,6 +19,7 @@ using QuickLook.MediaInfo; using QuickLook.MediaInfo.Core; using System; +using System.Globalization; using System.IO; using System.Reflection; using System.Windows; @@ -90,11 +91,8 @@ public void Prepare(string path, ContextObject context) { int.TryParse(_mediaInfo.Get(StreamKind.Video, 0, "Width"), out var width); int.TryParse(_mediaInfo.Get(StreamKind.Video, 0, "Height"), out var height); - double.TryParse(_mediaInfo.Get(StreamKind.Video, 0, "Rotation"), out var rotation); - - // Correct rotation: on some machine the value "90" becomes "90000" by some reason - if (rotation > 360) - rotation /= 1e3; + // Parse "90.000" as 90 in every culture, avoiding 90000 (de-DE) or 0 (ru-RU). + double.TryParse(_mediaInfo.Get(StreamKind.Video, 0, "Rotation"), NumberStyles.Float, CultureInfo.InvariantCulture, out var rotation); var windowSize = new Size { diff --git a/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/ViewerPanel.xaml.cs b/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/ViewerPanel.xaml.cs index 6d7c5a489..c1b8b4eac 100644 --- a/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/ViewerPanel.xaml.cs +++ b/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/ViewerPanel.xaml.cs @@ -25,6 +25,7 @@ using System; using System.ComponentModel; using System.Diagnostics; +using System.Globalization; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; @@ -473,10 +474,7 @@ public void LoadAndPlay(string path, MediaInfoNative info) UpdateMeta(path, info); // detect rotation - _ = double.TryParse(info?.Get(StreamKind.Video, 0, "Rotation"), out var rotation); - // Correct rotation: on some machine the value "90" becomes "90000" by some reason - if (rotation > 360d) - rotation /= 1e3; + _ = double.TryParse(info?.Get(StreamKind.Video, 0, "Rotation"), NumberStyles.Float, CultureInfo.InvariantCulture, out var rotation); if (Math.Abs(rotation) > 0.1d) mediaElement.LayoutTransform = new RotateTransform(rotation, 0.5d, 0.5d); From cfebd9687c5c3330ed074cf92931f7adb26f02ac Mon Sep 17 00:00:00 2001 From: Alexander Vinogradov Date: Sat, 24 Oct 2026 03:14:48 +0300 Subject: [PATCH 2/2] Document video preview preparation and playback --- QuickLook.Plugin/QuickLook.Plugin.VideoViewer/Plugin.cs | 3 +++ .../QuickLook.Plugin.VideoViewer/ViewerPanel.xaml.cs | 3 +++ 2 files changed, 6 insertions(+) diff --git a/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/Plugin.cs b/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/Plugin.cs index 2cb24820a..02014b085 100644 --- a/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/Plugin.cs +++ b/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/Plugin.cs @@ -84,6 +84,9 @@ public bool CanHandle(string path) return false; } + /// + /// Configures the preview window, accounting for video dimensions and rotation. + /// public void Prepare(string path, ContextObject context) { string videoCodec = _mediaInfo.Get(StreamKind.Video, 0, "Format"); diff --git a/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/ViewerPanel.xaml.cs b/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/ViewerPanel.xaml.cs index c1b8b4eac..d926e9152 100644 --- a/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/ViewerPanel.xaml.cs +++ b/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/ViewerPanel.xaml.cs @@ -456,6 +456,9 @@ private void HardwareAccelerationModeChanged(bool enable) } } + /// + /// Loads media for playback and applies video rotation from its metadata. + /// public void LoadAndPlay(string path, MediaInfoNative info) { // Detect whether it is other playback formats