From ccaf2f43a679dca056ef9512b9b260735d357948 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 20 Oct 2016 02:36:34 -0400 Subject: [PATCH 1/2] exclude mpeg4 with level -99 from vaapi --- .../Playback/BaseStreamingService.cs | 21 ++++++++++++++++++- .../Encoder/EncodingJobFactory.cs | 21 ++++++++++++++++++- .../LiveTv/LiveTvManager.cs | 2 +- 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index eb80ae89e..dc26218a5 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -317,13 +317,32 @@ namespace MediaBrowser.Api.Playback } if (string.Equals(hwType, "vaapi", StringComparison.OrdinalIgnoreCase) && !string.IsNullOrWhiteSpace(encodingOptions.VaapiDevice)) { - return GetAvailableEncoder("h264_vaapi", defaultEncoder); + if (IsVaapiSupported(state)) + { + return GetAvailableEncoder("h264_vaapi", defaultEncoder); + } } } return defaultEncoder; } + private bool IsVaapiSupported(StreamState state) + { + var videoStream = state.VideoStream; + + if (videoStream != null) + { + // vaapi will throw an error with this input + // [vaapi @ 0x7faed8000960] No VAAPI support for codec mpeg4 profile -99. + if (string.Equals(videoStream.Codec, "mpeg4", StringComparison.OrdinalIgnoreCase) && videoStream.Level == -99) + { + return false; + } + } + return true; + } + private string GetAvailableEncoder(string preferredEncoder, string defaultEncoder) { if (MediaEncoder.SupportsEncoder(preferredEncoder)) diff --git a/MediaBrowser.MediaEncoding/Encoder/EncodingJobFactory.cs b/MediaBrowser.MediaEncoding/Encoder/EncodingJobFactory.cs index b66a3ed96..f811a8d48 100644 --- a/MediaBrowser.MediaEncoding/Encoder/EncodingJobFactory.cs +++ b/MediaBrowser.MediaEncoding/Encoder/EncodingJobFactory.cs @@ -588,13 +588,32 @@ namespace MediaBrowser.MediaEncoding.Encoder } if (string.Equals(hwType, "vaapi", StringComparison.OrdinalIgnoreCase) && !string.IsNullOrWhiteSpace(options.VaapiDevice)) { - return GetAvailableEncoder(mediaEncoder, "h264_vaapi", defaultEncoder); + if (IsVaapiSupported(state)) + { + return GetAvailableEncoder(mediaEncoder, "h264_vaapi", defaultEncoder); + } } } return defaultEncoder; } + private static bool IsVaapiSupported(EncodingJob state) + { + var videoStream = state.VideoStream; + + if (videoStream != null) + { + // vaapi will throw an error with this input + // [vaapi @ 0x7faed8000960] No VAAPI support for codec mpeg4 profile -99. + if (string.Equals(videoStream.Codec, "mpeg4", StringComparison.OrdinalIgnoreCase) && videoStream.Level == -99) + { + return false; + } + } + return true; + } + internal static bool CanStreamCopyVideo(EncodingJobOptions request, MediaStream videoStream) { if (videoStream.IsInterlaced) diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs index 7c72363b0..902afb200 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs @@ -1947,7 +1947,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv } else { - timers = timers.Where(i => !(i.Item1.Status == RecordingStatus.New)); + timers = timers.Where(i => i.Item1.Status != RecordingStatus.New); } } From 821d950234ff6d4448318cadd57078b6c5442a2a Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 20 Oct 2016 14:02:42 -0400 Subject: [PATCH 2/2] allow specification of probing support --- MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs | 2 +- MediaBrowser.Api/Playback/MediaInfoService.cs | 11 +++++++---- MediaBrowser.Model/Dto/MediaSourceInfo.cs | 2 ++ MediaBrowser.Model/MediaInfo/LiveStreamRequest.cs | 2 ++ MediaBrowser.Model/MediaInfo/PlaybackInfoRequest.cs | 2 ++ .../LiveTv/LiveTvMediaSourceProvider.cs | 2 +- Nuget/MediaBrowser.Common.Internal.nuspec | 4 ++-- Nuget/MediaBrowser.Common.nuspec | 2 +- Nuget/MediaBrowser.Server.Core.nuspec | 4 ++-- 9 files changed, 20 insertions(+), 11 deletions(-) diff --git a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs index 8dea9068d..97b386d73 100644 --- a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs @@ -886,7 +886,7 @@ namespace MediaBrowser.Api.Playback.Hls var mapArgs = state.IsOutputVideo ? GetMapArgs(state) : string.Empty; var enableSplittingOnNonKeyFrames = state.VideoRequest.EnableSplittingOnNonKeyFrames && string.Equals(state.OutputVideoCodec, "copy", StringComparison.OrdinalIgnoreCase); - + enableSplittingOnNonKeyFrames = false; // TODO: check libavformat version for 57 50.100 and use -hls_flags split_by_time var hlsProtocolSupportsSplittingByTime = false; diff --git a/MediaBrowser.Api/Playback/MediaInfoService.cs b/MediaBrowser.Api/Playback/MediaInfoService.cs index 7fe7d5a21..0611adea5 100644 --- a/MediaBrowser.Api/Playback/MediaInfoService.cs +++ b/MediaBrowser.Api/Playback/MediaInfoService.cs @@ -125,7 +125,7 @@ namespace MediaBrowser.Api.Playback SetDeviceSpecificData(item, result.MediaSource, profile, authInfo, request.MaxStreamingBitrate, request.StartTimeTicks ?? 0, result.MediaSource.Id, request.AudioStreamIndex, - request.SubtitleStreamIndex, request.PlaySessionId, request.UserId); + request.SubtitleStreamIndex, request.MaxAudioChannels, request.PlaySessionId, request.UserId); } else { @@ -167,7 +167,7 @@ namespace MediaBrowser.Api.Playback { var mediaSourceId = request.MediaSourceId; - SetDeviceSpecificData(request.Id, info, profile, authInfo, request.MaxStreamingBitrate ?? profile.MaxStreamingBitrate, request.StartTimeTicks ?? 0, mediaSourceId, request.AudioStreamIndex, request.SubtitleStreamIndex, request.UserId); + SetDeviceSpecificData(request.Id, info, profile, authInfo, request.MaxStreamingBitrate ?? profile.MaxStreamingBitrate, request.StartTimeTicks ?? 0, mediaSourceId, request.AudioStreamIndex, request.SubtitleStreamIndex, request.MaxAudioChannels, request.UserId); } return ToOptimizedResult(info); @@ -230,13 +230,14 @@ namespace MediaBrowser.Api.Playback string mediaSourceId, int? audioStreamIndex, int? subtitleStreamIndex, + int? maxAudioChannels, string userId) { var item = _libraryManager.GetItemById(itemId); foreach (var mediaSource in result.MediaSources) { - SetDeviceSpecificData(item, mediaSource, profile, auth, maxBitrate, startTimeTicks, mediaSourceId, audioStreamIndex, subtitleStreamIndex, result.PlaySessionId, userId); + SetDeviceSpecificData(item, mediaSource, profile, auth, maxBitrate, startTimeTicks, mediaSourceId, audioStreamIndex, subtitleStreamIndex, maxAudioChannels, result.PlaySessionId, userId); } SortMediaSources(result, maxBitrate); @@ -251,6 +252,7 @@ namespace MediaBrowser.Api.Playback string mediaSourceId, int? audioStreamIndex, int? subtitleStreamIndex, + int? maxAudioChannels, string playSessionId, string userId) { @@ -262,7 +264,8 @@ namespace MediaBrowser.Api.Playback Context = EncodingContext.Streaming, DeviceId = auth.DeviceId, ItemId = item.Id.ToString("N"), - Profile = profile + Profile = profile, + MaxAudioChannels = maxAudioChannels }; if (string.Equals(mediaSourceId, mediaSource.Id, StringComparison.OrdinalIgnoreCase)) diff --git a/MediaBrowser.Model/Dto/MediaSourceInfo.cs b/MediaBrowser.Model/Dto/MediaSourceInfo.cs index 8149e3ff5..0b047f9e8 100644 --- a/MediaBrowser.Model/Dto/MediaSourceInfo.cs +++ b/MediaBrowser.Model/Dto/MediaSourceInfo.cs @@ -31,6 +31,7 @@ namespace MediaBrowser.Model.Dto public bool RequiresOpening { get; set; } public string OpenToken { get; set; } public bool RequiresClosing { get; set; } + public bool SupportsProbing { get; set; } public string LiveStreamId { get; set; } public int? BufferMs { get; set; } @@ -63,6 +64,7 @@ namespace MediaBrowser.Model.Dto SupportsTranscoding = true; SupportsDirectStream = true; SupportsDirectPlay = true; + SupportsProbing = true; } public int? DefaultAudioStreamIndex { get; set; } diff --git a/MediaBrowser.Model/MediaInfo/LiveStreamRequest.cs b/MediaBrowser.Model/MediaInfo/LiveStreamRequest.cs index 3affbbcc3..b6e2a96aa 100644 --- a/MediaBrowser.Model/MediaInfo/LiveStreamRequest.cs +++ b/MediaBrowser.Model/MediaInfo/LiveStreamRequest.cs @@ -11,6 +11,7 @@ namespace MediaBrowser.Model.MediaInfo public long? StartTimeTicks { get; set; } public int? AudioStreamIndex { get; set; } public int? SubtitleStreamIndex { get; set; } + public int? MaxAudioChannels { get; set; } public string ItemId { get; set; } public DeviceProfile DeviceProfile { get; set; } @@ -24,6 +25,7 @@ namespace MediaBrowser.Model.MediaInfo MaxStreamingBitrate = options.MaxBitrate; ItemId = options.ItemId; DeviceProfile = options.Profile; + MaxAudioChannels = options.MaxAudioChannels; VideoOptions videoOptions = options as VideoOptions; if (videoOptions != null) diff --git a/MediaBrowser.Model/MediaInfo/PlaybackInfoRequest.cs b/MediaBrowser.Model/MediaInfo/PlaybackInfoRequest.cs index 124739073..a2b85d121 100644 --- a/MediaBrowser.Model/MediaInfo/PlaybackInfoRequest.cs +++ b/MediaBrowser.Model/MediaInfo/PlaybackInfoRequest.cs @@ -16,6 +16,8 @@ namespace MediaBrowser.Model.MediaInfo public int? SubtitleStreamIndex { get; set; } + public int? MaxAudioChannels { get; set; } + public string MediaSourceId { get; set; } public string LiveStreamId { get; set; } diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs index a62796036..393708fb7 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs @@ -140,7 +140,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv try { - if (stream.MediaStreams.Any(i => i.Index != -1)) + if (!stream.SupportsProbing || stream.MediaStreams.Any(i => i.Index != -1)) { await AddMediaInfo(stream, isAudio, cancellationToken).ConfigureAwait(false); } diff --git a/Nuget/MediaBrowser.Common.Internal.nuspec b/Nuget/MediaBrowser.Common.Internal.nuspec index 176de7305..aba4913f3 100644 --- a/Nuget/MediaBrowser.Common.Internal.nuspec +++ b/Nuget/MediaBrowser.Common.Internal.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common.Internal - 3.0.664 + 3.0.665 MediaBrowser.Common.Internal Luke ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains common components shared by Emby Theater and Emby Server. Not intended for plugin developer consumption. Copyright © Emby 2013 - + diff --git a/Nuget/MediaBrowser.Common.nuspec b/Nuget/MediaBrowser.Common.nuspec index 420842418..cd7970127 100644 --- a/Nuget/MediaBrowser.Common.nuspec +++ b/Nuget/MediaBrowser.Common.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common - 3.0.664 + 3.0.665 MediaBrowser.Common Emby Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Server.Core.nuspec b/Nuget/MediaBrowser.Server.Core.nuspec index f9f5c2956..b0dd3ae4f 100644 --- a/Nuget/MediaBrowser.Server.Core.nuspec +++ b/Nuget/MediaBrowser.Server.Core.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Server.Core - 3.0.664 + 3.0.665 Media Browser.Server.Core Emby Team ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains core components required to build plugins for Emby Server. Copyright © Emby 2013 - +