switch to hwaccel auto

pull/1154/head
Luke Pulverenti 8 years ago
parent 997b357750
commit 8755886761

@ -1765,7 +1765,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
if (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);
}
}

@ -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.EmbyTV
private 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.EmbyTV
var 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;

@ -66,7 +66,7 @@ namespace MediaBrowser.Api
return 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.Api
throw new SecurityException("Unauthorized access.");
}
}
else
else if (restrictUserPreferences)
{
if (!authenticatedUser.Policy.EnableUserPreferenceAccess)
{

@ -427,7 +427,7 @@ namespace MediaBrowser.Api.Images
public 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.Images
public void Delete(DeleteUserImage request)
{
var userId = request.Id;
AssertCanUpdateUser(_authContext, _userManager, userId);
AssertCanUpdateUser(_authContext, _userManager, userId, true);
var item = _userManager.GetUserById(userId);

@ -497,7 +497,7 @@ namespace MediaBrowser.Api
}
else
{
episodes = series.GetSeasonEpisodes(season, user);
episodes = season.GetEpisodes(user);
}
}
else

@ -444,7 +444,7 @@ namespace MediaBrowser.Api
public 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.Api
public 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.cs
var id = GetPathValue(1);
AssertCanUpdateUser(_authContext, _userManager, id);
AssertCanUpdateUser(_authContext, _userManager, id, false);
var dtoUser = request;
@ -568,7 +568,7 @@ namespace MediaBrowser.Api
public void Post(UpdateUserConfiguration request)
{
AssertCanUpdateUser(_authContext, _userManager, request.Id);
AssertCanUpdateUser(_authContext, _userManager, request.Id, false);
var task = _userManager.UpdateConfiguration(request.Id, request);

@ -1725,6 +1725,11 @@ namespace MediaBrowser.Controller.MediaEncoding
if (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())

@ -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.Encoder
using (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.Encoder
throw;
}
finally
{
_ffProbeResourcePool.Release();
}
}
}

@ -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

Loading…
Cancel
Save