diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2017-05-10 22:57:48 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2017-05-10 22:57:48 -0400 |
| commit | e915ceda1b1b57f8b04f7f28b3efe2a84bd4cdd9 (patch) | |
| tree | a87652dca39e2cf1151ba4e6d5b5f25ba4edf28d | |
| parent | 0f198dc818300b6d8b8e85858274b0821ec70a20 (diff) | |
dummy up audio bitrates when needed
| -rw-r--r-- | MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs | 34 | ||||
| -rw-r--r-- | MediaBrowser.Model/Drawing/ImageSize.cs | 6 |
2 files changed, 40 insertions, 0 deletions
diff --git a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs index 8b20dca1b..6270b87c6 100644 --- a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs +++ b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs @@ -176,6 +176,14 @@ namespace MediaBrowser.MediaEncoding.Probing info.Video3DFormat = Video3DFormat.FullSideBySide; } + foreach (var mediaStream in info.MediaStreams) + { + if (mediaStream.Type == MediaStreamType.Audio && !mediaStream.BitRate.HasValue) + { + mediaStream.BitRate = GetEstimatedAudioBitrate(mediaStream.Codec, mediaStream.Channels); + } + } + var videoStreamsBitrate = info.MediaStreams.Where(i => i.Type == MediaStreamType.Video).Select(i => i.BitRate ?? 0).Sum(); // If ffprobe reported the container bitrate as being the same as the video stream bitrate, then it's wrong if (videoStreamsBitrate == (info.Bitrate ?? 0)) @@ -187,6 +195,32 @@ namespace MediaBrowser.MediaEncoding.Probing return info; } + private int? GetEstimatedAudioBitrate(string codec, int? channels) + { + if (!channels.HasValue) + { + return null; + } + + var channelsValue = channels.Value; + + if (string.Equals(codec, "aac", StringComparison.OrdinalIgnoreCase) || + string.Equals(codec, "mp3", StringComparison.OrdinalIgnoreCase)) + { + if (channelsValue <= 2) + { + return 192000; + } + + if (channelsValue >= 5) + { + return 320000; + } + } + + return null; + } + private void FetchFromItunesInfo(string xml, MediaInfo info) { // Make things simpler and strip out the dtd diff --git a/MediaBrowser.Model/Drawing/ImageSize.cs b/MediaBrowser.Model/Drawing/ImageSize.cs index 8cf09da18..c2b0291bd 100644 --- a/MediaBrowser.Model/Drawing/ImageSize.cs +++ b/MediaBrowser.Model/Drawing/ImageSize.cs @@ -61,6 +61,12 @@ namespace MediaBrowser.Model.Drawing _height = height; } + public ImageSize(double width, double height) + { + _width = width; + _height = height; + } + private void ParseValue(string value) { if (!string.IsNullOrEmpty(value)) |
