Mobile-ffmpeg: Execution Progress

Created on 8 Aug 2020  路  10Comments  路  Source: tanersener/mobile-ffmpeg

Description
I want to sync the ffmpeg command execution progress with a progress bar on alert dialog can any body tell me how can I do in this library by the way I do this work using

implementation 'nl.bravobit:android-ffmpeg:1.1.7'

and code for that is given below but now I can't find any listener in this new library

                        ffmpeg.execute(command, new ExecuteBinaryResponseHandler() {

                            @Override
                            public void onStart() {
                                Log.d("VideoConvertActivity","Started");
                                dialog.show();
                            }

                            @Override
                            public void onProgress(String message) {
                                Log.d("VideoConvertActivity",message);

                                String[] arr;
                                if (message.contains("time=")){
                                    arr = message.split("time=");
                                    String one = arr[1];
                                    String[] two = one.split(":");
                                    String[] three = two[2].split(" ");
                                    String sec = three[0];

                                    int hours = Integer.parseInt(two[0]);
                                    hours = hours * 3600;
                                    int minutes = Integer.parseInt(two[1]);
                                    minutes = minutes * 60;
                                    float seconds = Float.valueOf(sec);
                                    float timeInSeconds = hours + minutes + seconds;
                                    counter = (int) ((timeInSeconds/duration)*100);
                                }

                                if (counter <= 100){
                                    convertingProgressBar.setProgress(counter);
                                    String progress = (convertingProgressBar.getProgress() + " %");
                                    convertingProgressTextview.setText(progress);
                                    ObjectAnimator.ofInt(convertingProgressBar,"progress",counter)
                                            .setDuration((duration))
                                            .start();
                                }

                            }

                            @Override
                            public void onFailure(String message) {
                                Log.d("VideoConvertActivity",message);
                                Toast.makeText(ConvertActivity.this,message,Toast.LENGTH_SHORT).show();
                            }

                            @Override
                            public void onSuccess(String message) {
                                Log.d("VideoConvertActivity",message);
                                Intent intent = new Intent(ConvertActivity.this,MediaActivity.class);
                                intent.putExtra("status",2);
                                startActivity(intent);
                                finish();
                                loader.showInterstitial();
                            }

                            @Override
                            public void onFinish() {
                                Log.d("VideoConvertActivity","Finished");
                                dialog.dismiss();
                            }
                        });

All 10 comments

I have the same issue @AamirNaseer1 did you find any solution?

I have the same issue @AamirNaseer1 did you find any solution?

Yes I found the solution

I have the same issue @AamirNaseer1 did you find any solution?

I will post the solution very soon

please post as soon as possible

`

                Config.enableLogCallback(new LogCallback() {
                    public void apply(LogMessage message) {

                        msg = message.getText();

                        new Handler(Looper.getMainLooper()).post(new Runnable() {
                            @Override
                            public void run() {

                                String[] arr;
                                if (msg.contains("time=")){
                                    arr = msg.split("time=");
                                    String one = arr[1];
                                    String[] two = one.split(":");
                                    String[] three = two[2].split(" ");
                                    String sec = three[0];

                                    int hours = Integer.parseInt(two[0]);
                                    hours = hours * 3600;
                                    int minutes = Integer.parseInt(two[1]);
                                    minutes = minutes * 60;
                                    float seconds = Float.valueOf(sec);
                                    float timeInSeconds = hours + minutes + seconds;
                                    counter = (int) ((timeInSeconds/(duration))*100);

                                    Log.d("progress", "time in seconds : " + timeInSeconds);
                                    Log.d("progress", "duration : " + duration);
                                    Log.d("progress", "progress : " + counter);

                                }

                                if (counter <= 100){

                                    convertingProgressBar.setProgress(counter);
                                    String progress = (convertingProgressBar.getProgress() + " %");
                                    convertingProgressTextview.setText(progress);
                                    ObjectAnimator.ofInt(convertingProgressBar,"progress",counter)
                                            .setDuration(duration)
                                            .start();


                                }

                            }
                        });

                    }
                });

`

@TheMilanTej this is the solution.

@AamirNaseer1 what is duration?
how did you find that out!

@AamirNaseer1 what is duration?
how did you find that out!

duration is the time get from videoview.getDuration()

but how to get duration work when i have multiple videos to merge, i want that progress to show in dialog

but how to get duration work when I have multiple videos to merge, I want that progress to show in the dialog

for (int i = 0; i < dataList.size(); i++) {
MediaMetadataRetriever retriever = new MediaMetadataRetriever();
retriever.setDataSource(MergeActivity.this, Uri.fromFile(dataList.get(i)));
String time = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION);
long timeInMillisec = Long.parseLong(time);
totalDuration += timeInMillisec;
retriever.release();
}

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JayParikh20 picture JayParikh20  路  4Comments

abokhalel2 picture abokhalel2  路  4Comments

brainstormapps picture brainstormapps  路  7Comments

rabelhmd picture rabelhmd  路  7Comments

shaheercs picture shaheercs  路  6Comments