mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-08 20:38:24 +02:00
don't request a higher bitrate than source content
This commit is contained in:
parent
5fc327c232
commit
e031c7bcaa
2 changed files with 17 additions and 8 deletions
|
@ -158,9 +158,14 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||||
|
|
||||||
if (state.VideoRequest.VideoBitRate.HasValue)
|
if (state.VideoRequest.VideoBitRate.HasValue)
|
||||||
{
|
{
|
||||||
args += string.Format(" -b:v {0}", state.VideoRequest.VideoBitRate.Value);
|
// Make sure we don't request a bitrate higher than the source
|
||||||
}
|
var currentBitrate = state.VideoStream == null ? state.VideoRequest.VideoBitRate.Value : state.VideoStream.BitRate ?? state.VideoRequest.VideoBitRate.Value;
|
||||||
|
|
||||||
|
var bitrate = Math.Min(currentBitrate, state.VideoRequest.VideoBitRate.Value);
|
||||||
|
|
||||||
|
args += string.Format(" -b:v {0}", bitrate);
|
||||||
|
}
|
||||||
|
|
||||||
// Add resolution params, if specified
|
// Add resolution params, if specified
|
||||||
if (state.VideoRequest.Width.HasValue || state.VideoRequest.Height.HasValue || state.VideoRequest.MaxHeight.HasValue || state.VideoRequest.MaxWidth.HasValue)
|
if (state.VideoRequest.Width.HasValue || state.VideoRequest.Height.HasValue || state.VideoRequest.MaxHeight.HasValue || state.VideoRequest.MaxWidth.HasValue)
|
||||||
{
|
{
|
||||||
|
|
|
@ -160,8 +160,7 @@ namespace MediaBrowser.Api.Playback.Progressive
|
||||||
args += string.Format(" -r {0}", request.Framerate.Value);
|
args += string.Format(" -r {0}", request.Framerate.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the audio bitrate
|
var qualityParam = GetVideoQualityParam(state, codec);
|
||||||
var qualityParam = GetVideoQualityParam(request, codec);
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(qualityParam))
|
if (!string.IsNullOrEmpty(qualityParam))
|
||||||
{
|
{
|
||||||
|
@ -256,10 +255,10 @@ namespace MediaBrowser.Api.Playback.Progressive
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the video bitrate to specify on the command line
|
/// Gets the video bitrate to specify on the command line
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="request">The request.</param>
|
/// <param name="state">The state.</param>
|
||||||
/// <param name="videoCodec">The video codec.</param>
|
/// <param name="videoCodec">The video codec.</param>
|
||||||
/// <returns>System.String.</returns>
|
/// <returns>System.String.</returns>
|
||||||
private string GetVideoQualityParam(VideoStreamRequest request, string videoCodec)
|
private string GetVideoQualityParam(StreamState state, string videoCodec)
|
||||||
{
|
{
|
||||||
var args = string.Empty;
|
var args = string.Empty;
|
||||||
|
|
||||||
|
@ -284,9 +283,14 @@ namespace MediaBrowser.Api.Playback.Progressive
|
||||||
args = "-mbd rd -flags +mv4+aic -trellis 2 -cmp 2 -subcmp 2 -bf 2";
|
args = "-mbd rd -flags +mv4+aic -trellis 2 -cmp 2 -subcmp 2 -bf 2";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request.VideoBitRate.HasValue)
|
if (state.VideoRequest.VideoBitRate.HasValue)
|
||||||
{
|
{
|
||||||
args += " -b:v " + request.VideoBitRate;
|
// Make sure we don't request a bitrate higher than the source
|
||||||
|
var currentBitrate = state.VideoStream == null ? state.VideoRequest.VideoBitRate.Value : state.VideoStream.BitRate ?? state.VideoRequest.VideoBitRate.Value;
|
||||||
|
|
||||||
|
var bitrate = Math.Min(currentBitrate, state.VideoRequest.VideoBitRate.Value);
|
||||||
|
|
||||||
|
args += " -b:v " + bitrate;
|
||||||
}
|
}
|
||||||
|
|
||||||
return args.Trim();
|
return args.Trim();
|
||||||
|
|
Loading…
Reference in a new issue