Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NotifyOnProgress counting too fast #531

Open
JonathanBout opened this issue Jul 12, 2024 · 0 comments
Open

NotifyOnProgress counting too fast #531

JonathanBout opened this issue Jul 12, 2024 · 0 comments

Comments

@JonathanBout
Copy link

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));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant