Update FFmpegWrapper.cs (#200)

This commit is contained in:
rlauuzo 2024-06-14 17:11:04 +02:00 committed by GitHub
parent 508ab9897f
commit a9cdaf66b0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -415,14 +415,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();
@ -432,23 +427,21 @@ 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);
}
ffmpeg.WaitForExit(timeout);
@ -463,6 +456,7 @@ public static class FFmpegWrapper
return output;
}
}
}
/// <summary>
/// Fingerprint a queued episode.