From ed2b71492afeddf1b5a6a37f7c66b42cf1d2ca85 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 3 Feb 2014 00:35:56 -0500 Subject: [PATCH] adjust streaming quality params --- .../Playback/BaseStreamingService.cs | 33 ++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index fa44a1998..ca3e2c050 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -307,9 +307,11 @@ namespace MediaBrowser.Api.Playback var hasFixedResolution = state.VideoRequest.HasFixedResolution; + var qualitySetting = GetQualitySetting(); + if (string.Equals(videoCodec, "libx264", StringComparison.OrdinalIgnoreCase)) { - switch (GetQualitySetting()) + switch (qualitySetting) { case EncodingQuality.HighSpeed: param = "-preset ultrafast"; @@ -322,9 +324,20 @@ namespace MediaBrowser.Api.Playback break; } - if (!hasFixedResolution) + if (!isHls) { - param += " -crf 18"; + switch (qualitySetting) + { + case EncodingQuality.HighSpeed: + param += " -crf 23"; + break; + case EncodingQuality.HighQuality: + param += " -crf 20"; + break; + case EncodingQuality.MaxQuality: + param += " -crf 18"; + break; + } } } @@ -336,7 +349,18 @@ namespace MediaBrowser.Api.Playback if (!hasFixedResolution) { - param += " -crf 18"; + switch (qualitySetting) + { + case EncodingQuality.HighSpeed: + param += " -crf 18"; + break; + case EncodingQuality.HighQuality: + param += " -crf 14"; + break; + case EncodingQuality.MaxQuality: + param += " -crf 10"; + break; + } } } @@ -970,6 +994,7 @@ namespace MediaBrowser.Api.Playback // With vpx when crf is used, b:v becomes a max rate // https://trac.ffmpeg.org/wiki/vpxEncodingGuide return string.Format(" -b:v {0}", bitrate.Value.ToString(UsCulture)); + //return string.Format(" -minrate:v ({0}*.95) -maxrate:v ({0}*1.05) -bufsize:v {0} -b:v {0}", bitrate.Value.ToString(UsCulture)); } if (string.Equals(videoCodec, "msmpeg4", StringComparison.OrdinalIgnoreCase))