Update FFmpegWrapper.cs

This commit is contained in:
rlauuzo 2024-06-14 16:42:15 +02:00 committed by TwistedUmbrellaX
parent b101d8f8a4
commit d351a6225e

View File

@ -417,14 +417,9 @@ public static class FFmpegWrapper
RedirectStandardError = stderr
};
var ffmpeg = new Process
using (var ffmpeg = new Process { StartInfo = info })
{
StartInfo = info
};
Logger?.LogDebug(
"Starting ffmpeg with the following arguments: {Arguments}",
ffmpeg.StartInfo.Arguments);
Logger?.LogDebug("Starting ffmpeg with the following arguments: {Arguments}", ffmpeg.StartInfo.Arguments);
ffmpeg.Start();
@ -434,29 +429,24 @@ public static class FFmpegWrapper
}
catch (Exception e)
{
Logger?.LogDebug(
"ffmpeg priority could not be modified. {Message}",
e.Message);
Logger?.LogDebug("ffmpeg priority could not be modified. {Message}", e.Message);
}
using (MemoryStream ms = new MemoryStream())
using (var ms = new MemoryStream())
{
var buf = new byte[4096];
var bytesRead = 0;
int bytesRead;
do
using (var streamReader = stderr ? ffmpeg.StandardError : ffmpeg.StandardOutput)
{
while ((bytesRead = streamReader.BaseStream.Read(buf, 0, buf.Length)) > 0)
{
var streamReader = stderr ? ffmpeg.StandardError : ffmpeg.StandardOutput;
bytesRead = streamReader.BaseStream.Read(buf, 0, buf.Length);
ms.Write(buf, 0, bytesRead);
}
while (bytesRead > 0);
if (ffmpeg.WaitForExit(timeout))
{
ffmpeg.Dispose();
}
ffmpeg.WaitForExit(timeout);
var output = ms.ToArray();
// If caching is enabled, cache the output of this command.
@ -468,6 +458,7 @@ public static class FFmpegWrapper
return output;
}
}
}
/// <summary>
/// Fingerprint a queued episode.