How to add progress bar to FFMPEG android

前端 未结 4 1135
时光取名叫无心
时光取名叫无心 2021-01-01 07:34

I want add a progress bar during FFMPEG execution android.

When i start FFMPEG command then progress bar start with percentage progress.

4条回答
  •  梦毁少年i
    2021-01-01 08:25

    I use it every where:

    Pattern timePattern = Pattern.compile("(?<=time=)[\\d:.]*");
    Scanner sc = new Scanner(message);
    
    String match = sc.findWithinHorizon(timePattern, 0);
    if (match != null) {
      String[] matchSplit = match.split(":");
      if (totalDur != 0) {
        float progress = (Integer.parseInt(matchSplit[0]) * 3600 +
              Integer.parseInt(matchSplit[1]) * 60 +
              Float.parseFloat(matchSplit[2])) / totalDur;
        int showProgress = (int) (progress * 100000);
        progressDialog.setProgress(showProgress);
      }
    }

    Use it at onProgress method.

提交回复
热议问题