add configurable encoding params

This commit is contained in:
Luke Pulverenti 2016-09-04 11:01:31 -04:00
parent daeedb98ea
commit 9c7eef891b
6 changed files with 46 additions and 6 deletions

View File

@ -346,11 +346,27 @@ namespace MediaBrowser.Api.Playback
var isVc1 = state.VideoStream != null && var isVc1 = state.VideoStream != null &&
string.Equals(state.VideoStream.Codec, "vc1", StringComparison.OrdinalIgnoreCase); string.Equals(state.VideoStream.Codec, "vc1", StringComparison.OrdinalIgnoreCase);
var encodingOptions = ApiEntryPoint.Instance.GetEncodingOptions();
if (string.Equals(videoCodec, "libx264", StringComparison.OrdinalIgnoreCase)) if (string.Equals(videoCodec, "libx264", StringComparison.OrdinalIgnoreCase))
{ {
param = "-preset superfast"; if (!string.IsNullOrWhiteSpace(encodingOptions.H264Preset))
{
param = "-preset " + encodingOptions.H264Preset;
}
else
{
param = "-preset superfast";
}
param += " -crf 23"; if (encodingOptions.H264Crf >= 0 && encodingOptions.H264Crf <= 51)
{
param = " -crf " + encodingOptions.H264Crf.ToString(CultureInfo.InvariantCulture);
}
else
{
param += " -crf 23";
}
} }
else if (string.Equals(videoCodec, "libx265", StringComparison.OrdinalIgnoreCase)) else if (string.Equals(videoCodec, "libx265", StringComparison.OrdinalIgnoreCase))

View File

@ -113,7 +113,8 @@ namespace MediaBrowser.Controller.Entities
{ {
var standaloneTypes = new List<string> var standaloneTypes = new List<string>
{ {
CollectionType.Playlists CollectionType.Playlists,
CollectionType.BoxSets
}; };
var collectionFolder = folder as ICollectionFolder; var collectionFolder = folder as ICollectionFolder;

View File

@ -928,7 +928,12 @@ namespace MediaBrowser.MediaEncoding.Encoder
{ {
StartProcess(processWrapper); StartProcess(processWrapper);
ranToCompletion = process.WaitForExit(10000); var timeoutMs = ConfigurationManager.Configuration.ImageExtractionTimeoutMs;
if (timeoutMs <= 0)
{
timeoutMs = 10000;
}
ranToCompletion = process.WaitForExit(timeoutMs);
if (!ranToCompletion) if (!ranToCompletion)
{ {

View File

@ -11,6 +11,8 @@ namespace MediaBrowser.Model.Configuration
public string HardwareAccelerationType { get; set; } public string HardwareAccelerationType { get; set; }
public string EncoderAppPath { get; set; } public string EncoderAppPath { get; set; }
public string VaapiDevice { get; set; } public string VaapiDevice { get; set; }
public int H264Crf { get; set; }
public string H264Preset { get; set; }
public EncodingOptions() public EncodingOptions()
{ {
@ -19,6 +21,8 @@ namespace MediaBrowser.Model.Configuration
ThrottleDelaySeconds = 180; ThrottleDelaySeconds = 180;
EncodingThreadCount = -1; EncodingThreadCount = -1;
VaapiDevice = "/dev/dri/card0"; VaapiDevice = "/dev/dri/card0";
H264Crf = 23;
H264Preset = "superfast";
} }
} }
} }

View File

@ -207,6 +207,7 @@ namespace MediaBrowser.Model.Configuration
public bool EnableChannelView { get; set; } public bool EnableChannelView { get; set; }
public bool EnableExternalContentInSuggestions { get; set; } public bool EnableExternalContentInSuggestions { get; set; }
public int ImageExtractionTimeoutMs { get; set; }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="ServerConfiguration" /> class. /// Initializes a new instance of the <see cref="ServerConfiguration" /> class.
/// </summary> /// </summary>
@ -216,6 +217,7 @@ namespace MediaBrowser.Model.Configuration
Migrations = new string[] { }; Migrations = new string[] { };
CodecsUsed = new string[] { }; CodecsUsed = new string[] { };
SqliteCacheSize = 0; SqliteCacheSize = 0;
ImageExtractionTimeoutMs = 10000;
EnableLocalizedGuids = true; EnableLocalizedGuids = true;
DisplaySpecialsWithinSeasons = true; DisplaySpecialsWithinSeasons = true;

View File

@ -14,17 +14,20 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using CommonIO; using CommonIO;
using MediaBrowser.Controller.LiveTv;
namespace MediaBrowser.Server.Implementations.UserViews namespace MediaBrowser.Server.Implementations.UserViews
{ {
public class DynamicImageProvider : BaseDynamicImageProvider<UserView> public class DynamicImageProvider : BaseDynamicImageProvider<UserView>
{ {
private readonly IUserManager _userManager; private readonly IUserManager _userManager;
private readonly ILibraryManager _libraryManager;
public DynamicImageProvider(IFileSystem fileSystem, IProviderManager providerManager, IApplicationPaths applicationPaths, IImageProcessor imageProcessor, IUserManager userManager) public DynamicImageProvider(IFileSystem fileSystem, IProviderManager providerManager, IApplicationPaths applicationPaths, IImageProcessor imageProcessor, IUserManager userManager, ILibraryManager libraryManager)
: base(fileSystem, providerManager, applicationPaths, imageProcessor) : base(fileSystem, providerManager, applicationPaths, imageProcessor)
{ {
_userManager = userManager; _userManager = userManager;
_libraryManager = libraryManager;
} }
public override IEnumerable<ImageType> GetSupportedImages(IHasImages item) public override IEnumerable<ImageType> GetSupportedImages(IHasImages item)
@ -50,7 +53,15 @@ namespace MediaBrowser.Server.Implementations.UserViews
if (string.Equals(view.ViewType, CollectionType.LiveTv, StringComparison.OrdinalIgnoreCase)) if (string.Equals(view.ViewType, CollectionType.LiveTv, StringComparison.OrdinalIgnoreCase))
{ {
return new List<BaseItem>(); var programs = _libraryManager.GetItemList(new InternalItemsQuery
{
IncludeItemTypes = new[] { typeof(LiveTvProgram).Name },
ImageTypes = new[] { ImageType.Primary },
Limit = 30,
IsMovie = true
}).ToList();
return GetFinalItems(programs).ToList();
} }
if (string.Equals(view.ViewType, SpecialFolder.MovieGenre, StringComparison.OrdinalIgnoreCase) || if (string.Equals(view.ViewType, SpecialFolder.MovieGenre, StringComparison.OrdinalIgnoreCase) ||
@ -147,6 +158,7 @@ namespace MediaBrowser.Server.Implementations.UserViews
CollectionType.MusicVideos, CollectionType.MusicVideos,
CollectionType.HomeVideos, CollectionType.HomeVideos,
CollectionType.BoxSets, CollectionType.BoxSets,
CollectionType.LiveTv,
CollectionType.Playlists, CollectionType.Playlists,
CollectionType.Photos, CollectionType.Photos,
string.Empty string.Empty