How to create a progress bar that shows the real completion percentage of a task

I would like to add a progress bar showing the real percentage of completion of a task (compressing a video using ffmpeg) in my app. At the moment, I just found examples with delays that seem real, but they aren’t.
Right now, I’m using Progress Dialog:

    progressDialog = ProgressDialog(requireActivity())
    progressDialog.setTitle("Please wait..")

but I don’t know how to show the percentage and it says it’s deprecated.
In order to compress the video, I use “com.arthenica.ffmpegkit.FFmpegKit”, but I didn’t find a way to get the progress from there.
What’s the best option here?

That is doable only if whatever library you’re using actively cooperates with your code rather than blocking and telling you “bham i’m done”…

If you’re doing it yourself you have some sort of loop which has specific ending condition and the loop itself knows where it is at…

Another thing you could do if you have access to add code to the library or you do it yourself is to publish some sort of observable of the progress.

So it would look something like this.

fun copmressVideo(…) : IObservable where Int is the progress from [0,1]

either way the code that does the job needs to cooperate, you would subscribe to that observable and on each value update the title…