bravobit / FFmpeg-Android

FFMpeg/FFprobe compiled for Android
https://bravobit.nl/
MIT License
734 stars 172 forks source link

How to Get Processing Progress Callback? #119

Open protectedMan opened 5 years ago

protectedMan commented 5 years ago

I want to show the percentage of processing progress.

bahmanworld commented 5 years ago

You can use following code

@Override
public void onProgress(String message) {
    try {
        long current = Functions.timeToMillisecond(StringUtils.substringBetween(message, "time=", ""));
        percent = (int)((current * 100) / duration);
        progress.setProgress(percent);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

🔽 Note: Get video duration as milliseconds long Convert current progress time [from message] to milliseconds long You can use both variable to make percent value

Also you can find out StringUtils here jar: Apache Common Lang3 3.9