diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-02-03 15:37:18 -0500 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-02-03 15:37:18 -0500 |
| commit | b7a811992ba8a660ade212e2ed37306e9d9721d9 (patch) | |
| tree | 87d51f1d8793838dddfee00f85388600ecfa415c | |
| parent | 4205dcac9db652a2576f965d80a900bd390f125c (diff) | |
limit bitrate to original file
| -rw-r--r-- | MediaBrowser.Api/Playback/BaseStreamingService.cs | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index ca3e2c050..f91a35dca 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -355,10 +355,10 @@ namespace MediaBrowser.Api.Playback param += " -crf 18"; break; case EncodingQuality.HighQuality: - param += " -crf 14"; + param += " -crf 10"; break; case EncodingQuality.MaxQuality: - param += " -crf 10"; + param += " -crf 4"; break; } } @@ -968,7 +968,35 @@ namespace MediaBrowser.Api.Playback protected int? GetVideoBitrateParamValue(StreamState state) { - return state.VideoRequest.VideoBitRate; + var bitrate = state.VideoRequest.VideoBitRate; + + if (state.VideoStream != null) + { + var isUpscaling = false; + + if (state.VideoRequest.Height.HasValue && state.VideoStream.Height.HasValue && + state.VideoRequest.Height.Value > state.VideoStream.Height.Value) + { + isUpscaling = true; + } + + if (state.VideoRequest.Width.HasValue && state.VideoStream.Width.HasValue && + state.VideoRequest.Width.Value > state.VideoStream.Width.Value) + { + isUpscaling = true; + } + + // Don't allow bitrate increases unless upscaling + if (!isUpscaling) + { + if (bitrate.HasValue && state.VideoStream.BitRate.HasValue) + { + bitrate = Math.Min(bitrate.Value, state.VideoStream.BitRate.Value); + } + } + } + + return bitrate; } protected string GetVideoBitrateParam(StreamState state, string videoCodec, bool isHls) |
