diff options
| author | Bond_009 <bond.009@outlook.com> | 2019-01-02 01:01:36 +0100 |
|---|---|---|
| committer | Vasily <JustAMan@users.noreply.github.com> | 2019-01-02 16:21:24 +0300 |
| commit | 96ad22a00931ffea7dba828d5a677dac3d45d83c (patch) | |
| tree | 8f323d6954779408ef8f0eb3c6a119a081a3b00b | |
| parent | 68715bb1dc592924c1ff81c364e807d861da0696 (diff) | |
Reduce log spam and clean up EncoderValidator
| -rw-r--r-- | MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs b/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs index fb131f304..0f24a2370 100644 --- a/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs +++ b/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.Globalization; using MediaBrowser.Model.Diagnostics; using Microsoft.Extensions.Logging; @@ -73,7 +72,7 @@ namespace MediaBrowser.MediaEncoding.Encoder private List<string> GetDecoders(string encoderAppPath) { - string output = string.Empty; + string output = null; try { output = GetProcessOutput(encoderAppPath, "-decoders"); @@ -83,7 +82,11 @@ namespace MediaBrowser.MediaEncoding.Encoder _logger.LogError(ex, "Error detecting available decoders"); } - var found = new List<string>(); + if (string.IsNullOrWhiteSpace(output)) + { + return new List<string>(); + } + var required = new[] { "mpeg2video", @@ -101,17 +104,19 @@ namespace MediaBrowser.MediaEncoding.Encoder "hevc" }; + var found = new List<string>(); foreach (var codec in required) { var srch = " " + codec + " "; if (output.IndexOf(srch, StringComparison.OrdinalIgnoreCase) != -1) { - _logger.LogInformation("Decoder available: " + codec); found.Add(codec); } } + _logger.LogInformation("Available decoders: {Codecs}", found); + return found; } @@ -122,11 +127,16 @@ namespace MediaBrowser.MediaEncoding.Encoder { output = GetProcessOutput(encoderAppPath, "-encoders"); } - catch + catch (Exception ex) { + _logger.LogError(ex, "Error getting encoders"); + } + + if (string.IsNullOrWhiteSpace(output)) + { + return new List<string>(); } - var found = new List<string>(); var required = new[] { "libx264", @@ -151,26 +161,19 @@ namespace MediaBrowser.MediaEncoding.Encoder "ac3" }; - output = output ?? string.Empty; - - var index = 0; - + var found = new List<string>(); foreach (var codec in required) { var srch = " " + codec + " "; if (output.IndexOf(srch, StringComparison.OrdinalIgnoreCase) != -1) { - if (index < required.Length - 1) - { - _logger.LogInformation("Encoder available: " + codec); - } - found.Add(codec); } - index++; } + _logger.LogInformation("Available encoders: {Codecs}", found); + return found; } |
