From c7320dc1898f3fb5c4b1b1f62026865b0926b0b5 Mon Sep 17 00:00:00 2001 From: Bond-009 Date: Thu, 4 Sep 2025 05:12:24 +0200 Subject: [PATCH] Add more robust error handling for AudioNormalizationTask (#14728) --- .../Tasks/AudioNormalizationTask.cs | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/Emby.Server.Implementations/ScheduledTasks/Tasks/AudioNormalizationTask.cs b/Emby.Server.Implementations/ScheduledTasks/Tasks/AudioNormalizationTask.cs index 4245c9b12c7..a28f280afd8 100644 --- a/Emby.Server.Implementations/ScheduledTasks/Tasks/AudioNormalizationTask.cs +++ b/Emby.Server.Implementations/ScheduledTasks/Tasks/AudioNormalizationTask.cs @@ -122,7 +122,14 @@ public partial class AudioNormalizationTask : IScheduledTask } finally { - File.Delete(tempFile); + try + { + File.Delete(tempFile); + } + catch (Exception ex) + { + _logger.LogError(ex, "Failed to delete concat file: {FileName}.", tempFile); + } } } } @@ -232,11 +239,10 @@ public partial class AudioNormalizationTask : IScheduledTask }, }) { + _logger.LogDebug("Starting ffmpeg with arguments: {Arguments}", args); try { - _logger.LogDebug("Starting ffmpeg with arguments: {Arguments}", args); process.Start(); - process.PriorityClass = ProcessPriorityClass.BelowNormal; } catch (Exception ex) { @@ -244,6 +250,15 @@ public partial class AudioNormalizationTask : IScheduledTask return null; } + try + { + process.PriorityClass = ProcessPriorityClass.BelowNormal; + } + catch (Exception ex) + { + _logger.LogWarning(ex, "Error setting ffmpeg process priority"); + } + using var reader = process.StandardError; float? lufs = null; await foreach (var line in reader.ReadAllLinesAsync(cancellationToken).ConfigureAwait(false))