Merge pull request #4361 from ssenart/feature/4360-transcoding_flac_downsampling

Add FLAC and define the corresponding target sample rate
This commit is contained in:
Joshua M. Boniface 2020-11-17 10:29:29 -05:00 committed by GitHub
commit e0f60847c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 43 additions and 4 deletions

View File

@ -104,6 +104,7 @@
- [sorinyo2004](https://github.com/sorinyo2004)
- [sparky8251](https://github.com/sparky8251)
- [spookbits](https://github.com/spookbits)
- [ssenart] (https://github.com/ssenart)
- [stanionascu](https://github.com/stanionascu)
- [stevehayles](https://github.com/stevehayles)
- [SuperSandro2000](https://github.com/SuperSandro2000)

View File

@ -945,7 +945,10 @@ namespace Emby.Dlna.PlayTo
request.DeviceId = values.GetValueOrDefault("DeviceId");
request.MediaSourceId = values.GetValueOrDefault("MediaSourceId");
request.LiveStreamId = values.GetValueOrDefault("LiveStreamId");
request.IsDirectStream = string.Equals("true", values.GetValueOrDefault("Static"), StringComparison.OrdinalIgnoreCase);
// Be careful, IsDirectStream==true by default (Static != false or not in query).
// See initialization of StreamingRequestDto in AudioController.GetAudioStream() method : Static = @static ?? true.
request.IsDirectStream = !string.Equals("false", values.GetValueOrDefault("Static"), StringComparison.OrdinalIgnoreCase);
request.AudioStreamIndex = GetIntValue(values, "AudioStreamIndex");
request.SubtitleStreamIndex = GetIntValue(values, "SubtitleStreamIndex");

View File

@ -409,7 +409,7 @@ namespace MediaBrowser.Controller.MediaEncoding
{
// Don't exceed what the encoder supports
// Seeing issues of attempting to encode to 88200
return Math.Min(44100, BaseRequest.AudioSampleRate.Value);
return BaseRequest.AudioSampleRate.Value;
}
return null;

View File

@ -25,6 +25,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
"ac3",
"aac",
"mp3",
"flac",
"h264_qsv",
"hevc_qsv",
"mpeg2_qsv",
@ -71,6 +72,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
"libmp3lame",
"libopus",
"libvorbis",
"flac",
"srt",
"h264_amf",
"hevc_amf",

View File

@ -1438,6 +1438,32 @@ namespace MediaBrowser.Model.Dlna
break;
}
case ProfileConditionValue.AudioSampleRate:
{
if (!enableNonQualifiedConditions)
{
continue;
}
if (int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var num))
{
if (condition.Condition == ProfileConditionType.Equals)
{
item.AudioSampleRate = num;
}
else if (condition.Condition == ProfileConditionType.LessThanEqual)
{
item.AudioSampleRate = Math.Min(num, item.AudioSampleRate ?? num);
}
else if (condition.Condition == ProfileConditionType.GreaterThanEqual)
{
item.AudioSampleRate = Math.Max(num, item.AudioSampleRate ?? num);
}
}
break;
}
case ProfileConditionValue.AudioChannels:
{
if (string.IsNullOrEmpty(qualifier))

View File

@ -110,6 +110,8 @@ namespace MediaBrowser.Model.Dlna
public int? AudioBitrate { get; set; }
public int? AudioSampleRate { get; set; }
public int? VideoBitrate { get; set; }
public int? MaxWidth { get; set; }
@ -183,8 +185,10 @@ namespace MediaBrowser.Model.Dlna
continue;
}
// Be careful, IsDirectStream==true by default (Static != false or not in query).
// See initialization of StreamingRequestDto in AudioController.GetAudioStream() method : Static = @static ?? true.
if (string.Equals(pair.Name, "Static", StringComparison.OrdinalIgnoreCase) &&
string.Equals(pair.Value, "false", StringComparison.OrdinalIgnoreCase))
string.Equals(pair.Value, "true", StringComparison.OrdinalIgnoreCase))
{
continue;
}
@ -250,6 +254,7 @@ namespace MediaBrowser.Model.Dlna
list.Add(new NameValuePair("SubtitleStreamIndex", item.SubtitleStreamIndex.HasValue && item.SubtitleDeliveryMethod != SubtitleDeliveryMethod.External ? item.SubtitleStreamIndex.Value.ToString(CultureInfo.InvariantCulture) : string.Empty));
list.Add(new NameValuePair("VideoBitrate", item.VideoBitrate.HasValue ? item.VideoBitrate.Value.ToString(CultureInfo.InvariantCulture) : string.Empty));
list.Add(new NameValuePair("AudioBitrate", item.AudioBitrate.HasValue ? item.AudioBitrate.Value.ToString(CultureInfo.InvariantCulture) : string.Empty));
list.Add(new NameValuePair("AudioSampleRate", item.AudioSampleRate.HasValue ? item.AudioSampleRate.Value.ToString(CultureInfo.InvariantCulture) : string.Empty));
list.Add(new NameValuePair("MaxFramerate", item.MaxFramerate.HasValue ? item.MaxFramerate.Value.ToString(CultureInfo.InvariantCulture) : string.Empty));
list.Add(new NameValuePair("MaxWidth", item.MaxWidth.HasValue ? item.MaxWidth.Value.ToString(CultureInfo.InvariantCulture) : string.Empty));
@ -521,7 +526,9 @@ namespace MediaBrowser.Model.Dlna
get
{
var stream = TargetAudioStream;
return stream == null ? null : stream.SampleRate;
return AudioSampleRate.HasValue && !IsDirectStream
? AudioSampleRate
: stream == null ? null : stream.SampleRate;
}
}