From ccaf2f43a679dca056ef9512b9b260735d357948 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 20 Oct 2016 02:36:34 -0400 Subject: [PATCH] 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 eb80ae89e6..dc26218a52 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 b66a3ed96d..f811a8d48a 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 7c72363b0d..902afb2003 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); } }