mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-05 21:37:10 -04:00
update video audio encoding
This commit is contained in:
parent
159e622cf8
commit
a5ffea5752
@ -870,33 +870,47 @@ namespace MediaBrowser.Api.Playback
|
|||||||
inputChannels = null;
|
inputChannels = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
int? resultChannels = null;
|
int? transcoderChannelLimit = null;
|
||||||
var codec = outputAudioCodec ?? string.Empty;
|
var codec = outputAudioCodec ?? string.Empty;
|
||||||
|
|
||||||
if (codec.IndexOf("wma", StringComparison.OrdinalIgnoreCase) != -1)
|
if (codec.IndexOf("wma", StringComparison.OrdinalIgnoreCase) != -1)
|
||||||
{
|
{
|
||||||
// wmav2 currently only supports two channel output
|
// wmav2 currently only supports two channel output
|
||||||
resultChannels = Math.Min(2, inputChannels ?? 2);
|
transcoderChannelLimit = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (request.MaxAudioChannels.HasValue)
|
else if (codec.IndexOf("mp3", StringComparison.OrdinalIgnoreCase) != -1)
|
||||||
{
|
{
|
||||||
var channelLimit = codec.IndexOf("mp3", StringComparison.OrdinalIgnoreCase) != -1
|
// libmp3lame currently only supports two channel output
|
||||||
? 2
|
transcoderChannelLimit = 2;
|
||||||
: 6;
|
}
|
||||||
|
else
|
||||||
if (inputChannels.HasValue)
|
{
|
||||||
{
|
// If we don't have any media info then limit it to 6 to prevent encoding errors due to asking for too many channels
|
||||||
channelLimit = Math.Min(channelLimit, inputChannels.Value);
|
transcoderChannelLimit = 6;
|
||||||
}
|
|
||||||
|
|
||||||
// If we don't have any media info then limit it to 5 to prevent encoding errors due to asking for too many channels
|
|
||||||
resultChannels = Math.Min(request.MaxAudioChannels.Value, channelLimit);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request.TranscodingMaxAudioChannels.HasValue && !string.Equals(codec, "copy", StringComparison.OrdinalIgnoreCase))
|
var isTranscodingAudio = !string.Equals(codec, "copy", StringComparison.OrdinalIgnoreCase);
|
||||||
|
|
||||||
|
int? resultChannels = null;
|
||||||
|
if (isTranscodingAudio)
|
||||||
{
|
{
|
||||||
resultChannels = Math.Min(request.TranscodingMaxAudioChannels.Value, resultChannels ?? inputChannels ?? request.TranscodingMaxAudioChannels.Value);
|
resultChannels = request.TranscodingMaxAudioChannels;
|
||||||
|
}
|
||||||
|
resultChannels = resultChannels ?? request.MaxAudioChannels ?? request.AudioChannels;
|
||||||
|
|
||||||
|
if (inputChannels.HasValue)
|
||||||
|
{
|
||||||
|
resultChannels = resultChannels.HasValue
|
||||||
|
? Math.Min(resultChannels.Value, inputChannels.Value)
|
||||||
|
: inputChannels.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isTranscodingAudio && transcoderChannelLimit.HasValue)
|
||||||
|
{
|
||||||
|
resultChannels = resultChannels.HasValue
|
||||||
|
? Math.Min(resultChannels.Value, transcoderChannelLimit.Value)
|
||||||
|
: transcoderChannelLimit.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
return resultChannels ?? request.AudioChannels;
|
return resultChannels ?? request.AudioChannels;
|
||||||
|
@ -35,6 +35,7 @@ namespace MediaBrowser.Controller.MediaEncoding
|
|||||||
|
|
||||||
public string VideoCodec { get; set; }
|
public string VideoCodec { get; set; }
|
||||||
|
|
||||||
|
public int? TranscodingMaxAudioChannels { get; set; }
|
||||||
public int? VideoBitRate { get; set; }
|
public int? VideoBitRate { get; set; }
|
||||||
public int? AudioStreamIndex { get; set; }
|
public int? AudioStreamIndex { get; set; }
|
||||||
public int? VideoStreamIndex { get; set; }
|
public int? VideoStreamIndex { get; set; }
|
||||||
@ -86,6 +87,7 @@ namespace MediaBrowser.Controller.MediaEncoding
|
|||||||
MaxVideoBitDepth = info.MaxVideoBitDepth;
|
MaxVideoBitDepth = info.MaxVideoBitDepth;
|
||||||
SubtitleMethod = info.SubtitleDeliveryMethod;
|
SubtitleMethod = info.SubtitleDeliveryMethod;
|
||||||
Context = info.Context;
|
Context = info.Context;
|
||||||
|
TranscodingMaxAudioChannels = info.TranscodingMaxAudioChannels;
|
||||||
|
|
||||||
if (info.SubtitleDeliveryMethod != SubtitleDeliveryMethod.External)
|
if (info.SubtitleDeliveryMethod != SubtitleDeliveryMethod.External)
|
||||||
{
|
{
|
||||||
|
@ -370,30 +370,50 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|||||||
inputChannels = null;
|
inputChannels = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int? transcoderChannelLimit = null;
|
||||||
var codec = outputAudioCodec ?? string.Empty;
|
var codec = outputAudioCodec ?? string.Empty;
|
||||||
|
|
||||||
if (codec.IndexOf("wma", StringComparison.OrdinalIgnoreCase) != -1)
|
if (codec.IndexOf("wma", StringComparison.OrdinalIgnoreCase) != -1)
|
||||||
{
|
{
|
||||||
// wmav2 currently only supports two channel output
|
// wmav2 currently only supports two channel output
|
||||||
return Math.Min(2, inputChannels ?? 2);
|
transcoderChannelLimit = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request.MaxAudioChannels.HasValue)
|
else if (codec.IndexOf("mp3", StringComparison.OrdinalIgnoreCase) != -1)
|
||||||
{
|
{
|
||||||
var channelLimit = codec.IndexOf("mp3", StringComparison.OrdinalIgnoreCase) != -1
|
// libmp3lame currently only supports two channel output
|
||||||
? 2
|
transcoderChannelLimit = 2;
|
||||||
: 6;
|
}
|
||||||
|
else
|
||||||
if (inputChannels.HasValue)
|
{
|
||||||
{
|
// If we don't have any media info then limit it to 6 to prevent encoding errors due to asking for too many channels
|
||||||
channelLimit = Math.Min(channelLimit, inputChannels.Value);
|
transcoderChannelLimit = 6;
|
||||||
}
|
|
||||||
|
|
||||||
// If we don't have any media info then limit it to 5 to prevent encoding errors due to asking for too many channels
|
|
||||||
return Math.Min(request.MaxAudioChannels.Value, channelLimit);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return request.AudioChannels;
|
var isTranscodingAudio = !string.Equals(codec, "copy", StringComparison.OrdinalIgnoreCase);
|
||||||
|
|
||||||
|
int? resultChannels = null;
|
||||||
|
if (isTranscodingAudio)
|
||||||
|
{
|
||||||
|
resultChannels = request.TranscodingMaxAudioChannels;
|
||||||
|
}
|
||||||
|
resultChannels = resultChannels ?? request.MaxAudioChannels ?? request.AudioChannels;
|
||||||
|
|
||||||
|
if (inputChannels.HasValue)
|
||||||
|
{
|
||||||
|
resultChannels = resultChannels.HasValue
|
||||||
|
? Math.Min(resultChannels.Value, inputChannels.Value)
|
||||||
|
: inputChannels.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isTranscodingAudio && transcoderChannelLimit.HasValue)
|
||||||
|
{
|
||||||
|
resultChannels = resultChannels.HasValue
|
||||||
|
? Math.Min(resultChannels.Value, transcoderChannelLimit.Value)
|
||||||
|
: transcoderChannelLimit.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return resultChannels ?? request.AudioChannels;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int? GetVideoBitrateParamValue(EncodingJobOptions request, MediaStream videoStream, string outputVideoCodec)
|
private int? GetVideoBitrateParamValue(EncodingJobOptions request, MediaStream videoStream, string outputVideoCodec)
|
||||||
|
Loading…
Reference in New Issue
Block a user