Răsfoiți Sursa

Improve error message when image extraction times out

The exception will get logged higher up the call stack.
Bond_009 9 luni în urmă
părinte
comite
95200ad225

+ 1 - 1
MediaBrowser.MediaEncoding/Encoder/EncodingUtils.cs

@@ -42,7 +42,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
             // If there's more than one we'll need to use the concat command
             // If there's more than one we'll need to use the concat command
             if (inputFiles.Count > 1)
             if (inputFiles.Count > 1)
             {
             {
-                var files = string.Join("|", inputFiles.Select(NormalizePath));
+                var files = string.Join('|', inputFiles.Select(NormalizePath));
 
 
                 return string.Format(CultureInfo.InvariantCulture, "concat:\"{0}\"", files);
                 return string.Format(CultureInfo.InvariantCulture, "concat:\"{0}\"", files);
             }
             }

+ 3 - 9
MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs

@@ -719,8 +719,6 @@ namespace MediaBrowser.MediaEncoding.Encoder
 
 
             using (var processWrapper = new ProcessWrapper(process, this))
             using (var processWrapper = new ProcessWrapper(process, this))
             {
             {
-                bool ranToCompletion;
-
                 using (await _thumbnailResourcePool.LockAsync(cancellationToken).ConfigureAwait(false))
                 using (await _thumbnailResourcePool.LockAsync(cancellationToken).ConfigureAwait(false))
                 {
                 {
                     StartProcess(processWrapper);
                     StartProcess(processWrapper);
@@ -734,22 +732,18 @@ namespace MediaBrowser.MediaEncoding.Encoder
                     try
                     try
                     {
                     {
                         await process.WaitForExitAsync(TimeSpan.FromMilliseconds(timeoutMs)).ConfigureAwait(false);
                         await process.WaitForExitAsync(TimeSpan.FromMilliseconds(timeoutMs)).ConfigureAwait(false);
-                        ranToCompletion = true;
                     }
                     }
-                    catch (OperationCanceledException)
+                    catch (OperationCanceledException ex)
                     {
                     {
                         process.Kill(true);
                         process.Kill(true);
-                        ranToCompletion = false;
+                        throw new FfmpegException(string.Format(CultureInfo.InvariantCulture, "ffmpeg image extraction timed out for {0} after {1}ms", inputPath, timeoutMs), ex);
                     }
                     }
                 }
                 }
 
 
-                var exitCode = ranToCompletion ? processWrapper.ExitCode ?? 0 : -1;
                 var file = _fileSystem.GetFileInfo(tempExtractPath);
                 var file = _fileSystem.GetFileInfo(tempExtractPath);
 
 
-                if (exitCode == -1 || !file.Exists || file.Length == 0)
+                if (processWrapper.ExitCode > 0 || !file.Exists || file.Length == 0)
                 {
                 {
-                    _logger.LogError("ffmpeg image extraction failed for {Path}", inputPath);
-
                     throw new FfmpegException(string.Format(CultureInfo.InvariantCulture, "ffmpeg image extraction failed for {0}", inputPath));
                     throw new FfmpegException(string.Format(CultureInfo.InvariantCulture, "ffmpeg image extraction failed for {0}", inputPath));
                 }
                 }