|
|
|
@ -708,11 +708,26 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder
|
|
|
|
|
/// <param name="cancellationToken">The cancellation token.</param>
|
|
|
|
|
/// <returns>Task.</returns>
|
|
|
|
|
/// <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;
|
|
|
|
|
|
|
|
|
|
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>
|
|
|
|
@ -722,6 +737,7 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder
|
|
|
|
|
/// <param name="type">The type.</param>
|
|
|
|
|
/// <param name="offset">The offset.</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="cancellationToken">The cancellation token.</param>
|
|
|
|
|
/// <returns>Task.</returns>
|
|
|
|
@ -729,7 +745,7 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder
|
|
|
|
|
/// or
|
|
|
|
|
/// outputPath</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))
|
|
|
|
|
{
|
|
|
|
@ -741,7 +757,7 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
var probeSize = GetProbeSizeArgument(type);
|
|
|
|
|