@ -53,7 +53,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
private readonly int DefaultImageExtractionTimeoutMs ;
private readonly string StartupOptionFFmpegPath ;
private readonly SemaphoreSlim _thumbnailResourcePool = new SemaphoreSlim ( 1, 1 ) ;
private readonly SemaphoreSlim _thumbnailResourcePool = new SemaphoreSlim ( 2, 2 ) ;
private readonly List < ProcessWrapper > _runningProcesses = new List < ProcessWrapper > ( ) ;
private readonly ILocalizationManager _localization ;
@ -582,19 +582,27 @@ namespace MediaBrowser.MediaEncoding.Encoder
{
bool ranToCompletion ;
StartProcess ( processWrapper ) ;
var timeoutMs = ConfigurationManager . Configuration . ImageExtractionTimeoutMs ;
if ( timeoutMs < = 0 )
await _thumbnailResourcePool . WaitAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
try
{
timeoutMs = DefaultImageExtractionTimeoutMs ;
}
StartProcess ( processWrapper ) ;
var timeoutMs = ConfigurationManager . Configuration . ImageExtractionTimeoutMs ;
if ( timeoutMs < = 0 )
{
timeoutMs = DefaultImageExtractionTimeoutMs ;
}
ranToCompletion = await process . WaitForExitAsync ( timeoutMs ) . ConfigureAwait ( false ) ;
ranToCompletion = await process . WaitForExitAsync ( timeoutMs ) . ConfigureAwait ( false ) ;
if ( ! ranToCompletion )
if ( ! ranToCompletion )
{
StopProcess ( processWrapper , 1000 ) ;
}
}
finally
{
StopProcess ( processWrapper , 1000 ) ;
_thumbnailResourcePool. Release ( ) ;
}
var exitCode = ranToCompletion ? processWrapper . ExitCode ? ? 0 : - 1 ;
@ -625,7 +633,8 @@ namespace MediaBrowser.MediaEncoding.Encoder
return time . ToString ( @"hh\:mm\:ss\.fff" , UsCulture ) ;
}
public async Task ExtractVideoImagesOnInterval ( string [ ] inputFiles ,
public async Task ExtractVideoImagesOnInterval (
string [ ] inputFiles ,
string container ,
MediaStream videoStream ,
MediaProtocol protocol ,
@ -636,8 +645,6 @@ namespace MediaBrowser.MediaEncoding.Encoder
int? maxWidth ,
CancellationToken cancellationToken )
{
var resourcePool = _thumbnailResourcePool ;
var inputArgument = GetInputArgument ( inputFiles , protocol ) ;
var vf = "fps=fps=1/" + interval . TotalSeconds . ToString ( UsCulture ) ;
@ -701,7 +708,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
_logger . LogInformation ( process . StartInfo . FileName + " " + process . StartInfo . Arguments ) ;
await r esourcePool. WaitAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
await _thumbnailR esourcePool. WaitAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
bool ranToCompletion = false ;
@ -742,7 +749,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
}
finally
{
r esourcePool. Release ( ) ;
_thumbnailR esourcePool. Release ( ) ;
}
var exitCode = ranToCompletion ? processWrapper . ExitCode ? ? 0 : - 1 ;