From a1f92f3de3b28e63d6f63bb63fae12073826fb36 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 10 Jan 2015 22:06:16 -0500 Subject: [PATCH] configure h265 params --- .../Playback/BaseStreamingService.cs | 48 ++++++------------- .../Encoder/BaseEncoder.cs | 46 ++++++------------ .../Intros/DefaultIntroProvider.cs | 5 ++ .../FFMpeg/FFmpegValidator.cs | 1 + 4 files changed, 35 insertions(+), 65 deletions(-) diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index 8662e64b4f..034f5c56b9 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -279,32 +279,7 @@ namespace MediaBrowser.Api.Playback return Math.Max(Environment.ProcessorCount - 1, 2); } - // Use more when this is true. -re will keep cpu usage under control - if (state.ReadInputAtNativeFramerate) - { - if (isWebm) - { - return Math.Max(Environment.ProcessorCount - 1, 2); - } - - return 0; - } - - // Webm: http://www.webmproject.org/docs/encoder-parameters/ - // The decoder will usually automatically use an appropriate number of threads according to how many cores are available but it can only use multiple threads - // for the coefficient data if the encoder selected --token-parts > 0 at encode time. - - switch (GetQualitySetting()) - { - case EncodingQuality.HighSpeed: - return 2; - case EncodingQuality.HighQuality: - return 2; - case EncodingQuality.MaxQuality: - return isWebm ? Math.Max(Environment.ProcessorCount - 1, 2) : 0; - default: - throw new Exception("Unrecognized MediaEncodingQuality value."); - } + return 0; } protected string H264Encoder @@ -338,31 +313,38 @@ namespace MediaBrowser.Api.Playback var qualitySetting = GetQualitySetting(); - if (string.Equals(videoCodec, H264Encoder, StringComparison.OrdinalIgnoreCase)) + if (string.Equals(videoCodec, "libx264", StringComparison.OrdinalIgnoreCase)) { + param = "-preset superfast"; + switch (qualitySetting) { case EncodingQuality.HighSpeed: - param = "-preset superfast"; + param += " -crf 23"; break; case EncodingQuality.HighQuality: - param = "-preset superfast"; + param += " -crf 20"; break; case EncodingQuality.MaxQuality: - param = "-preset superfast"; + param += " -crf 18"; break; } + } + + else if (string.Equals(videoCodec, "libx265", StringComparison.OrdinalIgnoreCase)) + { + param = "-preset fast"; switch (qualitySetting) { case EncodingQuality.HighSpeed: - param += " -crf 23"; + param += " -crf 28"; break; case EncodingQuality.HighQuality: - param += " -crf 20"; + param += " -crf 25"; break; case EncodingQuality.MaxQuality: - param += " -crf 18"; + param += " -crf 21"; break; } } diff --git a/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs index efe2a89e32..ecf5d72d5a 100644 --- a/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs +++ b/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs @@ -317,32 +317,7 @@ namespace MediaBrowser.MediaEncoding.Encoder return Math.Max(Environment.ProcessorCount - 1, 2); } - // Use more when this is true. -re will keep cpu usage under control - if (job.ReadInputAtNativeFramerate) - { - if (isWebm) - { - return Math.Max(Environment.ProcessorCount - 1, 2); - } - - return 0; - } - - // Webm: http://www.webmproject.org/docs/encoder-parameters/ - // The decoder will usually automatically use an appropriate number of threads according to how many cores are available but it can only use multiple threads - // for the coefficient data if the encoder selected --token-parts > 0 at encode time. - - switch (GetQualitySetting()) - { - case EncodingQuality.HighSpeed: - return 2; - case EncodingQuality.HighQuality: - return 2; - case EncodingQuality.MaxQuality: - return isWebm ? Math.Max(Environment.ProcessorCount - 1, 2) : 0; - default: - throw new Exception("Unrecognized MediaEncodingQuality value."); - } + return 0; } protected EncodingQuality GetQualitySetting() @@ -650,29 +625,36 @@ namespace MediaBrowser.MediaEncoding.Encoder if (string.Equals(videoCodec, "libx264", StringComparison.OrdinalIgnoreCase)) { + param = "-preset superfast"; + switch (qualitySetting) { case EncodingQuality.HighSpeed: - param = "-preset superfast"; + param += " -crf 23"; break; case EncodingQuality.HighQuality: - param = "-preset superfast"; + param += " -crf 20"; break; case EncodingQuality.MaxQuality: - param = "-preset superfast"; + param += " -crf 18"; break; } + } + + else if (string.Equals(videoCodec, "libx265", StringComparison.OrdinalIgnoreCase)) + { + param = "-preset fast"; switch (qualitySetting) { case EncodingQuality.HighSpeed: - param += " -crf 23"; + param += " -crf 28"; break; case EncodingQuality.HighQuality: - param += " -crf 20"; + param += " -crf 25"; break; case EncodingQuality.MaxQuality: - param += " -crf 18"; + param += " -crf 21"; break; } } diff --git a/MediaBrowser.Server.Implementations/Intros/DefaultIntroProvider.cs b/MediaBrowser.Server.Implementations/Intros/DefaultIntroProvider.cs index fd1cc94842..a113e8d5ef 100644 --- a/MediaBrowser.Server.Implementations/Intros/DefaultIntroProvider.cs +++ b/MediaBrowser.Server.Implementations/Intros/DefaultIntroProvider.cs @@ -37,6 +37,11 @@ namespace MediaBrowser.Server.Implementations.Intros public async Task> GetIntros(BaseItem item, User user) { + if (!user.Configuration.EnableCinemaMode) + { + return new List(); + } + var config = GetOptions(); if (item is Movie) diff --git a/MediaBrowser.Server.Startup.Common/FFMpeg/FFmpegValidator.cs b/MediaBrowser.Server.Startup.Common/FFMpeg/FFmpegValidator.cs index 81ba1dc3a1..124a7f74b3 100644 --- a/MediaBrowser.Server.Startup.Common/FFMpeg/FFmpegValidator.cs +++ b/MediaBrowser.Server.Startup.Common/FFMpeg/FFmpegValidator.cs @@ -88,6 +88,7 @@ namespace MediaBrowser.Server.Startup.Common.FFMpeg var required = new[] { "libx264", + "libx265", "mpeg4", "msmpeg4", "libvpx",