The following Powershell script only executes the first ffmpeg call, no matter which one is first. Both the ffmpeg and the powershell processes never finish. Stopping the server, however, leads to the processes finishing and suddenly the second picture also appears.
Param($InputFile, $OutputFile, $Thumbnail, $Sprites)
$ThumbnailWidth = 120
$ThumbnailHeight = 120
# Thumbnail
ffmpeg -i $InputFile -f image2 -vframes 1 -filter:v "crop=min(iw\,ih):min(iw\,ih), scale=$($ThumbnailWidth):$($ThumbnailHeight)" -crf 18 "$($Thumbnail)\150x150.png"
# Poster
ffmpeg -i $InputFile -f image2 -vframes 1 -filter:v "crop=min(iw\,ih):min(iw\,ih), scale=$($PosterWidth):$($PosterHeight)" -crf 18 "$($Thumbnail)\1000x1000.png"
The script gets called within an ASP.NET application as follows:
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = "powershell.exe";
startInfo.Arguments = String.Format("-executionpolicy RemoteSigned -file \"{0}\" \"{1}\" \"{2}\" \"{3}\" \"{4}\"", scriptPath, fullPath, videoPath, thumbnailPath, sprites);
startInfo.RedirectStandardOutput = true;
startInfo.RedirectStandardError = true;
startInfo.UseShellExecute = false;
startInfo.CreateNoWindow = true;
Process process = new Process();
process.StartInfo = startInfo;
process.EnableRaisingEvents = true;
process.Exited += delegate
{
// Do some cleaning up
};
process.Start();
Does anyone have a clue, why only the first the two ffmpeg calls is working, while each call seems to be correct?
Adding process.StandardError.ReadToEnd();
makes the script finish as expected, but also makes it block, which is not acceptable.