mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-11-15 09:59:06 -07:00
Add perf tradeoff mode to image extractor (#12744)
This commit is contained in:
parent
77420739e6
commit
9ef7ccfc12
@ -21,6 +21,7 @@ namespace Emby.Server.Implementations
|
|||||||
{ BindToUnixSocketKey, bool.FalseString },
|
{ BindToUnixSocketKey, bool.FalseString },
|
||||||
{ SqliteCacheSizeKey, "20000" },
|
{ SqliteCacheSizeKey, "20000" },
|
||||||
{ FfmpegSkipValidationKey, bool.FalseString },
|
{ FfmpegSkipValidationKey, bool.FalseString },
|
||||||
|
{ FfmpegImgExtractPerfTradeoffKey, bool.FalseString },
|
||||||
{ DetectNetworkChangeKey, bool.TrueString }
|
{ DetectNetworkChangeKey, bool.TrueString }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,11 @@ namespace MediaBrowser.Controller.Extensions
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public const string FfmpegAnalyzeDurationKey = "FFmpeg:analyzeduration";
|
public const string FfmpegAnalyzeDurationKey = "FFmpeg:analyzeduration";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The key for the FFmpeg image extraction performance tradeoff option.
|
||||||
|
/// </summary>
|
||||||
|
public const string FfmpegImgExtractPerfTradeoffKey = "FFmpeg:imgExtractPerfTradeoff";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The key for the FFmpeg path option.
|
/// The key for the FFmpeg path option.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -107,6 +112,14 @@ namespace MediaBrowser.Controller.Extensions
|
|||||||
public static bool GetFFmpegSkipValidation(this IConfiguration configuration)
|
public static bool GetFFmpegSkipValidation(this IConfiguration configuration)
|
||||||
=> configuration.GetValue<bool>(FfmpegSkipValidationKey);
|
=> configuration.GetValue<bool>(FfmpegSkipValidationKey);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a value indicating whether the server should trade off for performance during FFmpeg image extraction.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="configuration">The configuration to read the setting from.</param>
|
||||||
|
/// <returns><c>true</c> if the server should trade off for performance during FFmpeg image extraction, otherwise <c>false</c>.</returns>
|
||||||
|
public static bool GetFFmpegImgExtractPerfTradeoff(this IConfiguration configuration)
|
||||||
|
=> configuration.GetValue<bool>(FfmpegImgExtractPerfTradeoffKey);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a value indicating whether playlists should allow duplicate entries from the <see cref="IConfiguration"/>.
|
/// Gets a value indicating whether playlists should allow duplicate entries from the <see cref="IConfiguration"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -650,6 +650,8 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|||||||
{
|
{
|
||||||
ArgumentException.ThrowIfNullOrEmpty(inputPath);
|
ArgumentException.ThrowIfNullOrEmpty(inputPath);
|
||||||
|
|
||||||
|
var useTradeoff = _config.GetFFmpegImgExtractPerfTradeoff();
|
||||||
|
|
||||||
var outputExtension = targetFormat?.GetExtension() ?? ".jpg";
|
var outputExtension = targetFormat?.GetExtension() ?? ".jpg";
|
||||||
|
|
||||||
var tempExtractPath = Path.Combine(_configurationManager.ApplicationPaths.TempDirectory, Guid.NewGuid() + outputExtension);
|
var tempExtractPath = Path.Combine(_configurationManager.ApplicationPaths.TempDirectory, Guid.NewGuid() + outputExtension);
|
||||||
@ -684,7 +686,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|||||||
|
|
||||||
// Use ffmpeg to sample 100 (we can drop this if required using thumbnail=50 for 50 frames) frames and pick the best thumbnail. Have a fall back just in case.
|
// Use ffmpeg to sample 100 (we can drop this if required using thumbnail=50 for 50 frames) frames and pick the best thumbnail. Have a fall back just in case.
|
||||||
// mpegts need larger batch size otherwise the corrupted thumbnail will be created. Larger batch size will lower the processing speed.
|
// mpegts need larger batch size otherwise the corrupted thumbnail will be created. Larger batch size will lower the processing speed.
|
||||||
var enableThumbnail = useIFrame && !string.Equals("wtv", container, StringComparison.OrdinalIgnoreCase);
|
var enableThumbnail = !useTradeoff && useIFrame && !string.Equals("wtv", container, StringComparison.OrdinalIgnoreCase);
|
||||||
if (enableThumbnail)
|
if (enableThumbnail)
|
||||||
{
|
{
|
||||||
var useLargerBatchSize = string.Equals("mpegts", container, StringComparison.OrdinalIgnoreCase);
|
var useLargerBatchSize = string.Equals("mpegts", container, StringComparison.OrdinalIgnoreCase);
|
||||||
@ -718,6 +720,11 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|||||||
args = string.Format(CultureInfo.InvariantCulture, "-ss {0} ", GetTimeParameter(offset.Value)) + args;
|
args = string.Format(CultureInfo.InvariantCulture, "-ss {0} ", GetTimeParameter(offset.Value)) + args;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (useIFrame && useTradeoff)
|
||||||
|
{
|
||||||
|
args = "-skip_frame nokey " + args;
|
||||||
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(container))
|
if (!string.IsNullOrWhiteSpace(container))
|
||||||
{
|
{
|
||||||
var inputFormat = EncodingHelper.GetInputFormat(container);
|
var inputFormat = EncodingHelper.GetInputFormat(container);
|
||||||
|
Loading…
Reference in New Issue
Block a user