mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-06 05:47:14 -04:00
vary bitrate params depending on input resolution requested
This commit is contained in:
parent
b28df9a3af
commit
20c711b248
@ -305,27 +305,39 @@ namespace MediaBrowser.Api.Playback
|
||||
{
|
||||
var param = string.Empty;
|
||||
|
||||
var hasFixedResolution = state.VideoRequest.HasFixedResolution;
|
||||
|
||||
if (string.Equals(videoCodec, "libx264", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
switch (GetQualitySetting())
|
||||
{
|
||||
case EncodingQuality.HighSpeed:
|
||||
param = "-preset ultrafast -crf 18";
|
||||
param = "-preset ultrafast";
|
||||
break;
|
||||
case EncodingQuality.HighQuality:
|
||||
param = "-preset superfast -crf 18";
|
||||
param = "-preset superfast";
|
||||
break;
|
||||
case EncodingQuality.MaxQuality:
|
||||
param = "-preset superfast -crf 18";
|
||||
param = "-preset superfast";
|
||||
break;
|
||||
}
|
||||
|
||||
if (!hasFixedResolution)
|
||||
{
|
||||
param += " crf18";
|
||||
}
|
||||
}
|
||||
|
||||
// webm
|
||||
else if (string.Equals(videoCodec, "libvpx", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
// http://www.webmproject.org/docs/encoder-parameters/
|
||||
param = "-speed 16 -quality good -profile:v 0 -slices 8 -crf 18";
|
||||
param = "-speed 16 -quality good -profile:v 0 -slices 8";
|
||||
|
||||
if (!hasFixedResolution)
|
||||
{
|
||||
param += " crf18";
|
||||
}
|
||||
}
|
||||
|
||||
else if (string.Equals(videoCodec, "mpeg4", StringComparison.OrdinalIgnoreCase))
|
||||
@ -941,21 +953,37 @@ namespace MediaBrowser.Api.Playback
|
||||
|
||||
if (bitrate.HasValue)
|
||||
{
|
||||
var hasFixedResolution = state.VideoRequest.HasFixedResolution;
|
||||
|
||||
if (isHls)
|
||||
{
|
||||
return string.Format(" -b:v {0} -maxrate ({0}*.80) -bufsize {0}", bitrate.Value.ToString(UsCulture));
|
||||
}
|
||||
|
||||
// With vpx when crf is used, b:v becomes a max rate
|
||||
// https://trac.ffmpeg.org/wiki/vpxEncodingGuide
|
||||
if (string.Equals(videoCodec, "libvpx", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
if (hasFixedResolution)
|
||||
{
|
||||
return string.Format(" -minrate:v ({0}*.90) -maxrate:v ({0}*1.10) -bufsize:v {0} -b:v {0}", bitrate.Value.ToString(UsCulture));
|
||||
}
|
||||
|
||||
// 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));
|
||||
}
|
||||
|
||||
if (string.Equals(videoCodec, "msmpeg4", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return string.Format(" -b:v {0}", bitrate.Value.ToString(UsCulture));
|
||||
}
|
||||
|
||||
|
||||
// H264
|
||||
if (hasFixedResolution)
|
||||
{
|
||||
return string.Format(" -b:v {0}", bitrate.Value.ToString(UsCulture));
|
||||
}
|
||||
|
||||
return string.Format(" -maxrate {0} -bufsize {1}",
|
||||
bitrate.Value.ToString(UsCulture),
|
||||
(bitrate.Value * 2).ToString(UsCulture));
|
||||
|
@ -157,5 +157,17 @@ namespace MediaBrowser.Api.Playback
|
||||
/// <value>The level.</value>
|
||||
[ApiMember(Name = "Level", Description = "Optional. Specify a level for the h264 profile, e.g. 3, 3.1.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
|
||||
public string Level { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether this instance has fixed resolution.
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if this instance has fixed resolution; otherwise, <c>false</c>.</value>
|
||||
public bool HasFixedResolution
|
||||
{
|
||||
get
|
||||
{
|
||||
return Width.HasValue || Height.HasValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user