configure h265 params

pull/702/head
Luke Pulverenti 10 years ago
parent 651f2a2aec
commit a1f92f3de3

@ -279,34 +279,9 @@ namespace MediaBrowser.Api.Playback
return Math.Max(Environment.ProcessorCount - 1, 2); 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; 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.");
}
}
protected string H264Encoder protected string H264Encoder
{ {
get get
@ -338,31 +313,38 @@ namespace MediaBrowser.Api.Playback
var qualitySetting = GetQualitySetting(); var qualitySetting = GetQualitySetting();
if (string.Equals(videoCodec, H264Encoder, StringComparison.OrdinalIgnoreCase)) if (string.Equals(videoCodec, "libx264", StringComparison.OrdinalIgnoreCase))
{ {
param = "-preset superfast";
switch (qualitySetting) switch (qualitySetting)
{ {
case EncodingQuality.HighSpeed: case EncodingQuality.HighSpeed:
param = "-preset superfast"; param += " -crf 23";
break; break;
case EncodingQuality.HighQuality: case EncodingQuality.HighQuality:
param = "-preset superfast"; param += " -crf 20";
break; break;
case EncodingQuality.MaxQuality: case EncodingQuality.MaxQuality:
param = "-preset superfast"; param += " -crf 18";
break; break;
} }
}
else if (string.Equals(videoCodec, "libx265", StringComparison.OrdinalIgnoreCase))
{
param = "-preset fast";
switch (qualitySetting) switch (qualitySetting)
{ {
case EncodingQuality.HighSpeed: case EncodingQuality.HighSpeed:
param += " -crf 23"; param += " -crf 28";
break; break;
case EncodingQuality.HighQuality: case EncodingQuality.HighQuality:
param += " -crf 20"; param += " -crf 25";
break; break;
case EncodingQuality.MaxQuality: case EncodingQuality.MaxQuality:
param += " -crf 18"; param += " -crf 21";
break; break;
} }
} }

@ -317,34 +317,9 @@ namespace MediaBrowser.MediaEncoding.Encoder
return Math.Max(Environment.ProcessorCount - 1, 2); 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; 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.");
}
}
protected EncodingQuality GetQualitySetting() protected EncodingQuality GetQualitySetting()
{ {
var quality = GetEncodingOptions().EncodingQuality; var quality = GetEncodingOptions().EncodingQuality;
@ -650,29 +625,36 @@ namespace MediaBrowser.MediaEncoding.Encoder
if (string.Equals(videoCodec, "libx264", StringComparison.OrdinalIgnoreCase)) if (string.Equals(videoCodec, "libx264", StringComparison.OrdinalIgnoreCase))
{ {
param = "-preset superfast";
switch (qualitySetting) switch (qualitySetting)
{ {
case EncodingQuality.HighSpeed: case EncodingQuality.HighSpeed:
param = "-preset superfast"; param += " -crf 23";
break; break;
case EncodingQuality.HighQuality: case EncodingQuality.HighQuality:
param = "-preset superfast"; param += " -crf 20";
break; break;
case EncodingQuality.MaxQuality: case EncodingQuality.MaxQuality:
param = "-preset superfast"; param += " -crf 18";
break; break;
} }
}
else if (string.Equals(videoCodec, "libx265", StringComparison.OrdinalIgnoreCase))
{
param = "-preset fast";
switch (qualitySetting) switch (qualitySetting)
{ {
case EncodingQuality.HighSpeed: case EncodingQuality.HighSpeed:
param += " -crf 23"; param += " -crf 28";
break; break;
case EncodingQuality.HighQuality: case EncodingQuality.HighQuality:
param += " -crf 20"; param += " -crf 25";
break; break;
case EncodingQuality.MaxQuality: case EncodingQuality.MaxQuality:
param += " -crf 18"; param += " -crf 21";
break; break;
} }
} }

@ -37,6 +37,11 @@ namespace MediaBrowser.Server.Implementations.Intros
public async Task<IEnumerable<IntroInfo>> GetIntros(BaseItem item, User user) public async Task<IEnumerable<IntroInfo>> GetIntros(BaseItem item, User user)
{ {
if (!user.Configuration.EnableCinemaMode)
{
return new List<IntroInfo>();
}
var config = GetOptions(); var config = GetOptions();
if (item is Movie) if (item is Movie)

@ -88,6 +88,7 @@ namespace MediaBrowser.Server.Startup.Common.FFMpeg
var required = new[] var required = new[]
{ {
"libx264", "libx264",
"libx265",
"mpeg4", "mpeg4",
"msmpeg4", "msmpeg4",
"libvpx", "libvpx",

Loading…
Cancel
Save