Video Merging with Xabe.FFmpeg. How to track the progress?
-
Hi I wrote the below simple code to merge two video files, it's working. But I wanna track the merging task percentage (or something that shows the progress), so I could show it using a progress bar. How to track the progress? Thanks.
textBox_taskMsg.Text = "Task is being performed.. This may take some time.";
string[] files = { textBox_Source1.Text, textBox_Source2.Text }; // Vids to be merged
string output = textBox_Source1.Text + "_merged.mp4"; // Output vid name
var conversion = await FFmpeg.Conversions.FromSnippet.Concatenate(output, files); // Merge
await conversion.Start();// SHOW MERGING PROGRESS
textBox_taskMsg.Text = "Merge Complete.";
-
Hi I wrote the below simple code to merge two video files, it's working. But I wanna track the merging task percentage (or something that shows the progress), so I could show it using a progress bar. How to track the progress? Thanks.
textBox_taskMsg.Text = "Task is being performed.. This may take some time.";
string[] files = { textBox_Source1.Text, textBox_Source2.Text }; // Vids to be merged
string output = textBox_Source1.Text + "_merged.mp4"; // Output vid name
var conversion = await FFmpeg.Conversions.FromSnippet.Concatenate(output, files); // Merge
await conversion.Start();// SHOW MERGING PROGRESS
textBox_taskMsg.Text = "Merge Complete.";
The only way to find that out is to go back to where you got the package from, and either ask there or read the documentation. But ... if you are using ffmpeg in a separate process, it's very unlikely that progress reporting is going to be possible: ffmpeg isn't a "windows aware" app, it's a console app and those don't generally report anything except to a console screen. And while you can pipe the console app progress to a stream you can read that requires getting the process itself, and providing extra command line instructions when the process is started. Since you are using a wrapper API, it would be entirely up to what that wrapper provides, and I'm not familiar with that one.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!
-
Hi I wrote the below simple code to merge two video files, it's working. But I wanna track the merging task percentage (or something that shows the progress), so I could show it using a progress bar. How to track the progress? Thanks.
textBox_taskMsg.Text = "Task is being performed.. This may take some time.";
string[] files = { textBox_Source1.Text, textBox_Source2.Text }; // Vids to be merged
string output = textBox_Source1.Text + "_merged.mp4"; // Output vid name
var conversion = await FFmpeg.Conversions.FromSnippet.Concatenate(output, files); // Merge
await conversion.Start();// SHOW MERGING PROGRESS
textBox_taskMsg.Text = "Merge Complete.";
You can use the 'OnProgress' event - ffmpeg Documentation[^] To add a progress tracker using a percentage, add the following to your code -
textBox_taskMsg.Text = "Task is being performed.. This may take some time.";
string[] files = { textBox_Source1.Text, textBox_Source2.Text };
string output = textBox_Source1.Text + "_merged.mp4";var conversion = await FFmpeg.Conversions.FromSnippet.Concatenate(output, files)
.OnProgress += (sender, args) =>
{
//Calculate and display the progress as a percentage to your uswer...
double progressPercentage = args.Percent;
textBox_taskMsg.Text = $"Merging... {progressPercentage:F2}% complete";
};await conversion.Start();
textBox_taskMsg.Text = "Merge Complete.";