NotifyOnProgress counting too fast
Opened this issue · 0 comments
JonathanBout commented
I'm building an WAV -> FLAC converter and was trying to give some feedback to the user for when a file takes a long time to process.
For that I found the NotifyOnProgress
method. But the duration or percentage seems to be way to high. Dividing it by 10 came closer but was still too high. It's also very unstable (sometimes a small step, sometimes a big jump).
As a solution I created my own way to keep track of the time which works fine and is way more stable and accurate.
This code is what I run to convert the file (with both ways of keeping track of the duration):
var file = new FileInfo("/your/file/name.wav");
var flacPath = file.Replace(".wav", ".flac");
var startTime = DateTime.UtcNow;
FFMpegArguments
.FromFileInput(file.FullName)
.OutputToFile(flacPath)
.NotifyOnProgress(d =>
{
var duration = DateTime.UtcNow - startTime;
if (duration > TimeSpan.FromSeconds(3))
{
Console.WriteLine("my time: {0:0N}s", duration.TotalSeconds);
Console.WriteLine("ffmpeg time: {0:0N}s\n", d.TotalSeconds);
}
})
.ProcessSynchronously(throwOnError: false));