From f6533e42287e997fd3ef54f6fc690208f51ce438 Mon Sep 17 00:00:00 2001 From: cvium Date: Fri, 28 Oct 2022 22:38:58 -0400 Subject: [PATCH] Backport pull request #8516 from jellyfin/release-10.8.z fix: kill ffprobe if keyframe parsing fails Original-merge: 6d23de64c093b83ba5a9c40d79b6362dd508fd62 Merged-by: Claus Vium Backported-by: Joshua M. Boniface --- .../FfProbe/FfProbeKeyframeExtractor.cs | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/Jellyfin.MediaEncoding.Keyframes/FfProbe/FfProbeKeyframeExtractor.cs b/src/Jellyfin.MediaEncoding.Keyframes/FfProbe/FfProbeKeyframeExtractor.cs index 79aa8a3549..febe9516af 100644 --- a/src/Jellyfin.MediaEncoding.Keyframes/FfProbe/FfProbeKeyframeExtractor.cs +++ b/src/Jellyfin.MediaEncoding.Keyframes/FfProbe/FfProbeKeyframeExtractor.cs @@ -38,9 +38,28 @@ public static class FfProbeKeyframeExtractor EnableRaisingEvents = true }; - process.Start(); + try + { + process.Start(); - return ParseStream(process.StandardOutput); + return ParseStream(process.StandardOutput); + } + catch (Exception) + { + try + { + if (!process.HasExited) + { + process.Kill(); + } + } + catch + { + // We do not care if this fails + } + + throw; + } } internal static KeyframeData ParseStream(StreamReader reader)