mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-08 12:28:19 +02:00
fix really high audio encoding bitrate
This commit is contained in:
parent
6f08e2152f
commit
9b937ebb9c
2 changed files with 18 additions and 22 deletions
|
@ -1440,7 +1440,8 @@ namespace MediaBrowser.Api.Playback
|
||||||
// Make sure we don't request a bitrate higher than the source
|
// Make sure we don't request a bitrate higher than the source
|
||||||
var currentBitrate = audioStream == null ? request.AudioBitRate.Value : audioStream.BitRate ?? request.AudioBitRate.Value;
|
var currentBitrate = audioStream == null ? request.AudioBitRate.Value : audioStream.BitRate ?? request.AudioBitRate.Value;
|
||||||
|
|
||||||
return request.AudioBitRate.Value;
|
// Don't encode any higher than this
|
||||||
|
return Math.Min(384000, request.AudioBitRate.Value);
|
||||||
//return Math.Min(currentBitrate, request.AudioBitRate.Value);
|
//return Math.Min(currentBitrate, request.AudioBitRate.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -602,33 +602,20 @@ namespace MediaBrowser.Model.Dlna
|
||||||
|
|
||||||
private int GetAudioBitrate(string subProtocol, int? maxTotalBitrate, int? targetAudioChannels, string targetAudioCodec, MediaStream audioStream)
|
private int GetAudioBitrate(string subProtocol, int? maxTotalBitrate, int? targetAudioChannels, string targetAudioCodec, MediaStream audioStream)
|
||||||
{
|
{
|
||||||
var defaultBitrate = audioStream == null ? 192000 : audioStream.BitRate ?? 192000;
|
int defaultBitrate = audioStream == null ? 192000 : audioStream.BitRate ?? 192000;
|
||||||
// Reduce the bitrate if we're downmixing
|
// Reduce the bitrate if we're downmixing
|
||||||
if (targetAudioChannels.HasValue && audioStream != null && audioStream.Channels.HasValue && targetAudioChannels.Value < audioStream.Channels.Value)
|
if (targetAudioChannels.HasValue && audioStream != null && audioStream.Channels.HasValue && targetAudioChannels.Value < audioStream.Channels.Value)
|
||||||
{
|
{
|
||||||
defaultBitrate = StringHelper.EqualsIgnoreCase(targetAudioCodec, "ac3") ? 192000 : 128000;
|
defaultBitrate = StringHelper.EqualsIgnoreCase(targetAudioCodec, "ac3") ? 192000 : 128000;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (targetAudioChannels.HasValue)
|
if (StringHelper.EqualsIgnoreCase(subProtocol, "hls"))
|
||||||
{
|
{
|
||||||
if (targetAudioChannels.Value >= 5 && (maxTotalBitrate ?? 0) >= 1200000)
|
defaultBitrate = Math.Min(384000, defaultBitrate);
|
||||||
{
|
|
||||||
if (StringHelper.EqualsIgnoreCase(targetAudioCodec, "ac3"))
|
|
||||||
{
|
|
||||||
if (string.Equals(subProtocol, "hls", StringComparison.OrdinalIgnoreCase))
|
|
||||||
{
|
|
||||||
defaultBitrate = Math.Max(384000, defaultBitrate);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
defaultBitrate = Math.Max(448000, defaultBitrate);
|
defaultBitrate = Math.Min(448000, defaultBitrate);
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
defaultBitrate = Math.Max(320000, defaultBitrate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int encoderAudioBitrateLimit = int.MaxValue;
|
int encoderAudioBitrateLimit = int.MaxValue;
|
||||||
|
@ -647,6 +634,14 @@ namespace MediaBrowser.Model.Dlna
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (maxTotalBitrate.HasValue)
|
||||||
|
{
|
||||||
|
if (maxTotalBitrate.Value < 640000)
|
||||||
|
{
|
||||||
|
defaultBitrate = Math.Min(128000, defaultBitrate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return Math.Min(defaultBitrate, encoderAudioBitrateLimit);
|
return Math.Min(defaultBitrate, encoderAudioBitrateLimit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue