From 606bec35c5cca61c47b7be3871380da2f7846f3d Mon Sep 17 00:00:00 2001 From: nyanmisaka Date: Thu, 16 Jun 2022 03:45:32 +0800 Subject: [PATCH] Fix the deadlock of ffmpeg process on Windows --- ConfusedPolarBear.Plugin.IntroSkipper/Chromaprint.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Chromaprint.cs b/ConfusedPolarBear.Plugin.IntroSkipper/Chromaprint.cs index 46854a9..0cca214 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Chromaprint.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Chromaprint.cs @@ -114,9 +114,14 @@ public static class Chromaprint var info = new ProcessStartInfo(ffmpegPath, args) { + WindowStyle = ProcessWindowStyle.Hidden, CreateNoWindow = true, + UseShellExecute = false, + ErrorDialog = false, + + // We only consume standardOutput. RedirectStandardOutput = true, - RedirectStandardError = true + RedirectStandardError = false }; var ffmpeg = new Process @@ -125,7 +130,6 @@ public static class Chromaprint }; ffmpeg.Start(); - ffmpeg.WaitForExit(timeout); using (MemoryStream ms = new MemoryStream()) { @@ -139,6 +143,8 @@ public static class Chromaprint } while (bytesRead > 0); + ffmpeg.WaitForExit(timeout); + return ms.ToArray().AsSpan(); } }