From 4a344bebc08303edf888000bf52e64b1a4e8036f Mon Sep 17 00:00:00 2001 From: NotSaifA <69015839+NotSaifA@users.noreply.github.com> Date: Fri, 24 May 2024 09:50:55 -0400 Subject: [PATCH] Trickplay: kill ffmpeg when task is cancelled (#11790) --- CONTRIBUTORS.md | 1 + MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 47c06998c0..76d57a4783 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -183,6 +183,7 @@ - [btopherjohnson](https://github.com/btopherjohnson) - [GeorgeH005](https://github.com/GeorgeH005) - [Vedant](https://github.com/viktory36/) + - [NotSaifA](https://github.com/NotSaifA) # Emby Contributors diff --git a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs index cdef2bedf0..80ef6ecf77 100644 --- a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs +++ b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs @@ -959,7 +959,7 @@ namespace MediaBrowser.MediaEncoding.Encoder var timeoutMs = _configurationManager.Configuration.ImageExtractionTimeoutMs; timeoutMs = timeoutMs <= 0 ? DefaultHdrImageExtractionTimeout : timeoutMs; - while (isResponsive) + while (isResponsive && !cancellationToken.IsCancellationRequested) { try { @@ -973,8 +973,6 @@ namespace MediaBrowser.MediaEncoding.Encoder // We don't actually expect the process to be finished in one timeout span, just that one image has been generated. } - cancellationToken.ThrowIfCancellationRequested(); - var jpegCount = _fileSystem.GetFilePaths(targetDirectory).Count(); isResponsive = jpegCount > lastCount; @@ -983,7 +981,12 @@ namespace MediaBrowser.MediaEncoding.Encoder if (!ranToCompletion) { - _logger.LogInformation("Stopping trickplay extraction due to process inactivity."); + if (!isResponsive) + { + _logger.LogInformation("Trickplay process unresponsive."); + } + + _logger.LogInformation("Stopping trickplay extraction."); StopProcess(processWrapper, 1000); } }