diff options
| author | Gary Wilber <Spacetech326@gmail.com> | 2020-11-19 18:44:16 -0800 |
|---|---|---|
| committer | Gary Wilber <Spacetech326@gmail.com> | 2020-11-19 18:44:16 -0800 |
| commit | 4a22380565bbf5909ad064461ae9cb59a410a063 (patch) | |
| tree | 6bbc22a8979d6544f2d373413f7f75255945e9a3 /MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs | |
| parent | d6585e7ff2e14234201e3fe6a75a5af2170c7804 (diff) | |
| parent | 90e4066b12e3b39124f9f4efcb20a0e51499a038 (diff) | |
Merge remote-tracking branch 'upstream/master' into library_scan_speed
Diffstat (limited to 'MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs')
| -rw-r--r-- | MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs index 5846a603a..a115179e8 100644 --- a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs +++ b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs @@ -63,7 +63,7 @@ namespace MediaBrowser.Controller.MediaEncoding { // Only use alternative encoders for video files. // When using concat with folder rips, if the mfx session fails to initialize, ffmpeg will be stuck retrying and will not exit gracefully - // Since transcoding of folder rips is expiremental anyway, it's not worth adding additional variables such as this. + // Since transcoding of folder rips is experimental anyway, it's not worth adding additional variables such as this. if (state.VideoType == VideoType.VideoFile) { var hwType = encodingOptions.HardwareAccelerationType; @@ -247,7 +247,7 @@ namespace MediaBrowser.Controller.MediaEncoding return null; } - // Seeing reported failures here, not sure yet if this is related to specfying input format + // Seeing reported failures here, not sure yet if this is related to specifying input format if (string.Equals(container, "m4v", StringComparison.OrdinalIgnoreCase)) { return null; @@ -2329,7 +2329,8 @@ namespace MediaBrowser.Controller.MediaEncoding /// <summary> /// Gets the number of threads. /// </summary> - public int GetNumberOfThreads(EncodingJobInfo state, EncodingOptions encodingOptions, string outputVideoCodec) +#nullable enable + public static int GetNumberOfThreads(EncodingJobInfo? state, EncodingOptions encodingOptions, string? outputVideoCodec) { if (string.Equals(outputVideoCodec, "libvpx", StringComparison.OrdinalIgnoreCase)) { @@ -2339,17 +2340,21 @@ namespace MediaBrowser.Controller.MediaEncoding return Math.Max(Environment.ProcessorCount - 1, 1); } - var threads = state.BaseRequest.CpuCoreLimit ?? encodingOptions.EncodingThreadCount; + var threads = state?.BaseRequest.CpuCoreLimit ?? encodingOptions.EncodingThreadCount; // Automatic - if (threads <= 0 || threads >= Environment.ProcessorCount) + if (threads <= 0) { return 0; + } + else if (threads >= Environment.ProcessorCount) + { + return Environment.ProcessorCount; } return threads; } - +#nullable disable public void TryStreamCopy(EncodingJobInfo state) { if (state.VideoStream != null && CanStreamCopyVideo(state, state.VideoStream)) @@ -2752,7 +2757,7 @@ namespace MediaBrowser.Controller.MediaEncoding var videoType = state.MediaSource.VideoType ?? VideoType.VideoFile; // Only use alternative encoders for video files. // When using concat with folder rips, if the mfx session fails to initialize, ffmpeg will be stuck retrying and will not exit gracefully - // Since transcoding of folder rips is expiremental anyway, it's not worth adding additional variables such as this. + // Since transcoding of folder rips is experimental anyway, it's not worth adding additional variables such as this. if (videoType != VideoType.VideoFile) { return null; |
