@ -331,8 +331,8 @@ namespace MediaBrowser.MediaEncoding.Encoder
// -f image2 -f webp
// 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.
var args = useIFrame ? string . Format ( "-i {0} -threads 0 -v quiet -vframes 1 -vf \"{2},thumbnail=30\" -f image2 \"{1}\"", inputPath , "-" , vf ) :
string . Format ( "-i {0} -threads 0 -v quiet -vframes 1 -vf \"{2}\" -f image2 \"{1}\"", inputPath , "-" , vf ) ;
var args = useIFrame ? string . Format ( "-i {0} -threads 1 -v quiet -vframes 1 -vf \"{2},thumbnail=30\" -f image2 \"{1}\"", inputPath , "-" , vf ) :
string . Format ( "-i {0} -threads 1 -v quiet -vframes 1 -vf \"{2}\" -f image2 \"{1}\"", inputPath , "-" , vf ) ;
var probeSize = GetProbeSizeArgument ( new [ ] { inputPath } , protocol ) ;
@ -479,7 +479,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
Directory . CreateDirectory ( targetDirectory ) ;
var outputPath = Path . Combine ( targetDirectory , filenamePrefix + "%05d.jpg" ) ;
var args = string . Format ( "-i {0} -threads 0 -v quiet -vf \"{2}\" -f image2 \"{1}\"", inputArgument , outputPath , vf ) ;
var args = string . Format ( "-i {0} -threads 1 -v quiet -vf \"{2}\" -f image2 \"{1}\"", inputArgument , outputPath , vf ) ;
var probeSize = GetProbeSizeArgument ( new [ ] { inputArgument } , protocol ) ;
@ -506,6 +506,10 @@ namespace MediaBrowser.MediaEncoding.Encoder
await resourcePool . WaitAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
bool ranToCompletion ;
try
{
process . Start ( ) ;
// Need to give ffmpeg enough time to make all the thumbnails, which could be a while,
@ -515,14 +519,18 @@ namespace MediaBrowser.MediaEncoding.Encoder
bool isResponsive = true ;
int lastCount = 0 ;
while ( isResponsive & & ! process . WaitForExit ( 12 0000) )
while ( isResponsive & & ! process . WaitForExit ( 3 0000) )
{
int jpegCount = Directory . GetFiles ( targetDirectory , "*.jpg" ) . Count ( ) ;
cancellationToken . ThrowIfCancellationRequested ( ) ;
int jpegCount = Directory . GetFiles ( targetDirectory )
. Count ( i = > string . Equals ( Path . GetExtension ( i ) , ".jpg" , StringComparison . OrdinalIgnoreCase ) ) ;
isResponsive = ( jpegCount > lastCount ) ;
lastCount = jpegCount ;
}
bool ranToCompletion = process . HasExited ;
ranToCompletion = process . HasExited ;
if ( ! ranToCompletion )
{
@ -539,8 +547,11 @@ namespace MediaBrowser.MediaEncoding.Encoder
_logger . ErrorException ( "Error killing process" , ex ) ;
}
}
}
finally
{
resourcePool . Release ( ) ;
}
var exitCode = ranToCompletion ? process . ExitCode : - 1 ;