mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-11-15 18:08:53 -07:00
Improved audio handler to only specify channels and sample rate when we're downmixing
This commit is contained in:
parent
099ac83cc3
commit
78dad0af96
@ -113,19 +113,59 @@ namespace MediaBrowser.Api.HttpHandlers
|
||||
audioTranscodeParams.Add("-ab " + bitrate.Value);
|
||||
}
|
||||
|
||||
if (AudioChannels.HasValue)
|
||||
int? channels = GetNumAudioChannelsParam();
|
||||
|
||||
if (channels.HasValue)
|
||||
{
|
||||
audioTranscodeParams.Add("-ac " + AudioChannels.Value);
|
||||
audioTranscodeParams.Add("-ac " + channels.Value);
|
||||
}
|
||||
|
||||
if (AudioSampleRate.HasValue)
|
||||
int? sampleRate = GetSampleRateParam();
|
||||
|
||||
if (sampleRate.HasValue)
|
||||
{
|
||||
audioTranscodeParams.Add("-ar " + AudioSampleRate.Value);
|
||||
audioTranscodeParams.Add("-ar " + sampleRate.Value);
|
||||
}
|
||||
|
||||
audioTranscodeParams.Add("-f " + outputFormat);
|
||||
|
||||
return "-i \"" + LibraryItem.Path + "\" -vn " + string.Join(" ", audioTranscodeParams.ToArray()) + " -";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of audio channels to specify on the command line
|
||||
/// </summary>
|
||||
private int? GetNumAudioChannelsParam()
|
||||
{
|
||||
// If the user requested a max number of channels
|
||||
if (AudioChannels.HasValue)
|
||||
{
|
||||
// Only specify the param if we're going to downmix
|
||||
if (AudioChannels.Value < LibraryItem.Channels)
|
||||
{
|
||||
return AudioChannels.Value;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of audio channels to specify on the command line
|
||||
/// </summary>
|
||||
private int? GetSampleRateParam()
|
||||
{
|
||||
// If the user requested a max value
|
||||
if (AudioSampleRate.HasValue)
|
||||
{
|
||||
// Only specify the param if we're going to downmix
|
||||
if (AudioSampleRate.Value < LibraryItem.SampleRate)
|
||||
{
|
||||
return AudioSampleRate.Value;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user