From 833a1da355f7e1d4c734df94d1e286015403427b Mon Sep 17 00:00:00 2001 From: NotSaifA <69015839+NotSaifA@users.noreply.github.com> Date: Sat, 25 May 2024 11:46:19 -0400 Subject: Backport pull request #11790 from jellyfin/release-10.9.z Trickplay: kill ffmpeg when task is cancelled Original-merge: 4a344bebc08303edf888000bf52e64b1a4e8036f Merged-by: crobibero Backported-by: Joshua M. Boniface --- MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'MediaBrowser.MediaEncoding/Encoder') diff --git a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs index b84baaa38..79abb13ac 100644 --- a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs +++ b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs @@ -943,7 +943,7 @@ namespace MediaBrowser.MediaEncoding.Encoder var timeoutMs = _configurationManager.Configuration.ImageExtractionTimeoutMs; timeoutMs = timeoutMs <= 0 ? DefaultHdrImageExtractionTimeout : timeoutMs; - while (isResponsive) + while (isResponsive && !cancellationToken.IsCancellationRequested) { try { @@ -957,8 +957,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; @@ -967,7 +965,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); } } -- cgit v1.2.3