added dual pass image extraction
This commit is contained in:
parent
27d2d2b89a
commit
06a7d64525
|
@ -357,9 +357,6 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
||||||
_logger.ErrorException("AcceptWebSocketAsync error", ex);
|
_logger.ErrorException("AcceptWebSocketAsync error", ex);
|
||||||
|
|
||||||
ctx.Response.StatusCode = 500;
|
ctx.Response.StatusCode = 500;
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
ctx.Response.Close();
|
ctx.Response.Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -708,11 +708,26 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
/// <returns>Task.</returns>
|
/// <returns>Task.</returns>
|
||||||
/// <exception cref="System.ArgumentException">Must use inputPath list overload</exception>
|
/// <exception cref="System.ArgumentException">Must use inputPath list overload</exception>
|
||||||
public Task ExtractImage(string[] inputFiles, InputType type, TimeSpan? offset, string outputPath, CancellationToken cancellationToken)
|
public async Task ExtractImage(string[] inputFiles, InputType type, TimeSpan? offset, string outputPath, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var resourcePool = type == InputType.AudioFile ? _audioImageResourcePool : _videoImageResourcePool;
|
var resourcePool = type == InputType.AudioFile ? _audioImageResourcePool : _videoImageResourcePool;
|
||||||
|
|
||||||
return ExtractImageInternal(GetInputArgument(inputFiles, type), type, offset, outputPath, resourcePool, cancellationToken);
|
var inputArgument = GetInputArgument(inputFiles, type);
|
||||||
|
|
||||||
|
if (type != InputType.AudioFile)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await ExtractImageInternal(inputArgument, type, offset, outputPath, true, resourcePool, cancellationToken).ConfigureAwait(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
_logger.Error("I-frame image extraction failed, will attempt standard way. Input: {0}", inputArgument);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await ExtractImageInternal(inputArgument, type, offset, outputPath, false, resourcePool, cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -722,6 +737,7 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder
|
||||||
/// <param name="type">The type.</param>
|
/// <param name="type">The type.</param>
|
||||||
/// <param name="offset">The offset.</param>
|
/// <param name="offset">The offset.</param>
|
||||||
/// <param name="outputPath">The output path.</param>
|
/// <param name="outputPath">The output path.</param>
|
||||||
|
/// <param name="useIFrame">if set to <c>true</c> [use I frame].</param>
|
||||||
/// <param name="resourcePool">The resource pool.</param>
|
/// <param name="resourcePool">The resource pool.</param>
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
/// <returns>Task.</returns>
|
/// <returns>Task.</returns>
|
||||||
|
@ -729,7 +745,7 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder
|
||||||
/// or
|
/// or
|
||||||
/// outputPath</exception>
|
/// outputPath</exception>
|
||||||
/// <exception cref="System.ApplicationException"></exception>
|
/// <exception cref="System.ApplicationException"></exception>
|
||||||
private async Task ExtractImageInternal(string inputPath, InputType type, TimeSpan? offset, string outputPath, SemaphoreSlim resourcePool, CancellationToken cancellationToken)
|
private async Task ExtractImageInternal(string inputPath, InputType type, TimeSpan? offset, string outputPath, bool useIFrame, SemaphoreSlim resourcePool, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(inputPath))
|
if (string.IsNullOrEmpty(inputPath))
|
||||||
{
|
{
|
||||||
|
@ -741,7 +757,7 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder
|
||||||
throw new ArgumentNullException("outputPath");
|
throw new ArgumentNullException("outputPath");
|
||||||
}
|
}
|
||||||
|
|
||||||
var args = type != InputType.Dvd ? string.Format("-i {0} -threads 0 -v quiet -vframes 1 -filter:v select=\\'eq(pict_type\\,I)\\' -f image2 \"{1}\"", inputPath, outputPath) :
|
var args = useIFrame ? string.Format("-i {0} -threads 0 -v quiet -vframes 1 -filter:v select=\\'eq(pict_type\\,I)\\' -f image2 \"{1}\"", inputPath, outputPath) :
|
||||||
string.Format("-i {0} -threads 0 -v quiet -vframes 1 -f image2 \"{1}\"", inputPath, outputPath);
|
string.Format("-i {0} -threads 0 -v quiet -vframes 1 -f image2 \"{1}\"", inputPath, outputPath);
|
||||||
|
|
||||||
var probeSize = GetProbeSizeArgument(type);
|
var probeSize = GetProbeSizeArgument(type);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user