The Free Software Media System - Server Backend & API
switch to hwaccel auto
Luke Pulverenti875588676123
diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.csindex 666c1fdcd4..5082f1b044 100644--- a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs+++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs@@ -1765,7 +1765,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTVif (regInfo.IsValid){- return new EncodedRecorder(_logger, _fileSystem, _mediaEncoder, _config.ApplicationPaths, _jsonSerializer, config, _httpClient, _processFactory);+ return new EncodedRecorder(_logger, _fileSystem, _mediaEncoder, _config.ApplicationPaths, _jsonSerializer, config, _httpClient, _processFactory, _config);}}diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.csindex 6cc5b69208..8ee3d71b5e 100644--- a/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs+++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs@@ -11,14 +11,16 @@ using MediaBrowser.Model.IO;using MediaBrowser.Common.IO;using MediaBrowser.Common.Net;using MediaBrowser.Controller;-using MediaBrowser.Controller.IO;+using MediaBrowser.Controller.Configuration;using MediaBrowser.Controller.MediaEncoding;+using MediaBrowser.Model.Configuration;using MediaBrowser.Model.Diagnostics;using MediaBrowser.Model.Dto;using MediaBrowser.Model.Entities;using MediaBrowser.Model.LiveTv;using MediaBrowser.Model.Logging;using MediaBrowser.Model.Serialization;+using MediaBrowser.Common.Configuration;namespace Emby.Server.Implementations.LiveTv.EmbyTV{@@ -37,8 +39,9 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTVprivate readonly IProcessFactory _processFactory;private readonly IJsonSerializer _json;private readonly TaskCompletionSource<bool> _taskCompletionSource = new TaskCompletionSource<bool>();+ private readonly IServerConfigurationManager _config;- public EncodedRecorder(ILogger logger, IFileSystem fileSystem, IMediaEncoder mediaEncoder, IServerApplicationPaths appPaths, IJsonSerializer json, LiveTvOptions liveTvOptions, IHttpClient httpClient, IProcessFactory processFactory)+ public EncodedRecorder(ILogger logger, IFileSystem fileSystem, IMediaEncoder mediaEncoder, IServerApplicationPaths appPaths, IJsonSerializer json, LiveTvOptions liveTvOptions, IHttpClient httpClient, IProcessFactory processFactory, IServerConfigurationManager config){_logger = logger;_fileSystem = fileSystem;@@ -48,6 +51,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV_liveTvOptions = liveTvOptions;_httpClient = httpClient;_processFactory = processFactory;+ _config = config;}private string OutputFormat@@ -89,6 +93,11 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV_logger.Info("Recording completed to file {0}", targetFile);}+ private EncodingOptions GetEncodingOptions()+ {+ return _config.GetConfiguration<EncodingOptions>("encoding");+ }+private Task RecordFromFile(MediaSourceInfo mediaSource, string inputFile, string targetFile, TimeSpan duration, Action onStarted, CancellationToken cancellationToken){_targetPath = targetFile;@@ -163,6 +172,12 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTVvar durationParam = " -t " + _mediaEncoder.GetTimeParameter(duration.Ticks);var inputModifiers = "-fflags +genpts -async 1 -vsync -1";++ if (!string.IsNullOrWhiteSpace(GetEncodingOptions().HardwareAccelerationType))+ {+ inputModifiers += " -hwaccel auto";+ }+var commandLineArgs = "-i \"{0}\"{5} {2} -map_metadata -1 -threads 0 {3}{4}{6} -y \"{1}\"";long startTimeTicks = 0;diff --git a/MediaBrowser.Api/BaseApiService.cs b/MediaBrowser.Api/BaseApiService.csindex 1f21a1dd15..a802e56af0 100644--- a/MediaBrowser.Api/BaseApiService.cs+++ b/MediaBrowser.Api/BaseApiService.cs@@ -66,7 +66,7 @@ namespace MediaBrowser.Apireturn ResultFactory.GetOptimizedResult(Request, result);}- protected void AssertCanUpdateUser(IAuthorizationContext authContext, IUserManager userManager, string userId)+ protected void AssertCanUpdateUser(IAuthorizationContext authContext, IUserManager userManager, string userId, bool restrictUserPreferences){var auth = authContext.GetAuthorizationInfo(Request);@@ -80,7 +80,7 @@ namespace MediaBrowser.Apithrow new SecurityException("Unauthorized access.");}}- else+ else if (restrictUserPreferences){if (!authenticatedUser.Policy.EnableUserPreferenceAccess){diff --git a/MediaBrowser.Api/Images/ImageService.cs b/MediaBrowser.Api/Images/ImageService.csindex 392654aa25..9f144c8e45 100644--- a/MediaBrowser.Api/Images/ImageService.cs+++ b/MediaBrowser.Api/Images/ImageService.cs@@ -427,7 +427,7 @@ namespace MediaBrowser.Api.Imagespublic void Post(PostUserImage request){var userId = GetPathValue(1);- AssertCanUpdateUser(_authContext, _userManager, userId);+ AssertCanUpdateUser(_authContext, _userManager, userId, true);request.Type = (ImageType)Enum.Parse(typeof(ImageType), GetPathValue(3), true);@@ -462,7 +462,7 @@ namespace MediaBrowser.Api.Imagespublic void Delete(DeleteUserImage request){var userId = request.Id;- AssertCanUpdateUser(_authContext, _userManager, userId);+ AssertCanUpdateUser(_authContext, _userManager, userId, true);var item = _userManager.GetUserById(userId);diff --git a/MediaBrowser.Api/TvShowsService.cs b/MediaBrowser.Api/TvShowsService.csindex 126f1c7539..bc2b08384e 100644--- a/MediaBrowser.Api/TvShowsService.cs+++ b/MediaBrowser.Api/TvShowsService.cs@@ -497,7 +497,7 @@ namespace MediaBrowser.Api}else{- episodes = series.GetSeasonEpisodes(season, user);+ episodes = season.GetEpisodes(user);}}elsediff --git a/MediaBrowser.Api/UserService.cs b/MediaBrowser.Api/UserService.csindex fde03e1f2c..49b7f6c15e 100644--- a/MediaBrowser.Api/UserService.cs+++ b/MediaBrowser.Api/UserService.cs@@ -444,7 +444,7 @@ namespace MediaBrowser.Apipublic async Task PostAsync(UpdateUserPassword request){- AssertCanUpdateUser(_authContext, _userManager, request.Id);+ AssertCanUpdateUser(_authContext, _userManager, request.Id, true);var user = _userManager.GetUserById(request.Id);@@ -482,7 +482,7 @@ namespace MediaBrowser.Apipublic async Task PostAsync(UpdateUserEasyPassword request){- AssertCanUpdateUser(_authContext, _userManager, request.Id);+ AssertCanUpdateUser(_authContext, _userManager, request.Id, true);var user = _userManager.GetUserById(request.Id);@@ -518,7 +518,7 @@ namespace MediaBrowser.Api// https://code.google.com/p/servicestack/source/browse/trunk/Common/ServiceStack.Text/ServiceStack.Text/Controller/PathInfo.csvar id = GetPathValue(1);- AssertCanUpdateUser(_authContext, _userManager, id);+ AssertCanUpdateUser(_authContext, _userManager, id, false);var dtoUser = request;@@ -568,7 +568,7 @@ namespace MediaBrowser.Apipublic void Post(UpdateUserConfiguration request){- AssertCanUpdateUser(_authContext, _userManager, request.Id);+ AssertCanUpdateUser(_authContext, _userManager, request.Id, false);var task = _userManager.UpdateConfiguration(request.Id, request);diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.csindex 22d09f34a1..d6e4a61e42 100644--- a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs+++ b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs@@ -1725,6 +1725,11 @@ namespace MediaBrowser.Controller.MediaEncodingif (state.VideoStream != null && !string.IsNullOrWhiteSpace(state.VideoStream.Codec)){+ if (!string.IsNullOrWhiteSpace(encodingOptions.HardwareAccelerationType))+ {+ return "-hwaccel auto";+ }+if (string.Equals(encodingOptions.HardwareAccelerationType, "qsv", StringComparison.OrdinalIgnoreCase)){switch (state.MediaSource.VideoStream.Codec.ToLower())diff --git a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.csindex 816f14f821..130afa3e3c 100644--- a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs+++ b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs@@ -49,11 +49,6 @@ namespace MediaBrowser.MediaEncoding.Encoder/// </summary>private readonly SemaphoreSlim _thumbnailResourcePool = new SemaphoreSlim(1, 1);- /// <summary>- /// The FF probe resource pool- /// </summary>- private readonly SemaphoreSlim _ffProbeResourcePool = new SemaphoreSlim(2, 2);-public string FFMpegPath { get; private set; }public string FFProbePath { get; private set; }@@ -591,20 +586,7 @@ namespace MediaBrowser.MediaEncoding.Encoderusing (var processWrapper = new ProcessWrapper(process, this, _logger)){- await _ffProbeResourcePool.WaitAsync(cancellationToken).ConfigureAwait(false);-- try- {- StartProcess(processWrapper);- }- catch (Exception ex)- {- _ffProbeResourcePool.Release();-- _logger.ErrorException("Error starting ffprobe", ex);-- throw;- }+ StartProcess(processWrapper);try{@@ -655,10 +637,6 @@ namespace MediaBrowser.MediaEncoding.Encoderthrow;}- finally- {- _ffProbeResourcePool.Release();- }}}diff --git a/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs b/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.csindex 231a2ae85e..3f2ecae317 100644--- a/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs+++ b/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs@@ -524,8 +524,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles{if (!_fileSystem.FileExists(outputPath)){- await ExtractTextSubtitleInternal(_mediaEncoder.GetInputArgument(inputFiles, protocol), subtitleStreamIndex,- outputCodec, outputPath, cancellationToken).ConfigureAwait(false);+ await ExtractTextSubtitleInternal(_mediaEncoder.GetInputArgument(inputFiles, protocol), subtitleStreamIndex, outputCodec, outputPath, cancellationToken).ConfigureAwait(false);}}finally