0

I wanted to split animated gif files using FFmpeg-Android-Java, so I referenced this question Android, split gif to frames with ffmpeg and wrote this code.

String path = "/storage/emulated/0/Download/mothersday-toaster.gif";
        String cmd[] = {"-i",path,"-vsync","0","/storage/emulated/0/Download/output$03d.png"};

        try {
            // to execute "ffmpeg -version" command you just need to pass "-version"
            ffmpeg.execute(cmd, new ExecuteBinaryResponseHandler() {

                @Override
                public void onStart() {}

                @Override
                public void onProgress(String message) {}

                @Override
                public void onFailure(String message) {Log.d("Q", "failed to convert");}

                @Override
                public void onSuccess(String message) {}

                @Override
                public void onFinish() {}
            });
        } catch (FFmpegCommandAlreadyRunningException e) {
            // Handle if FFmpeg is already running
        }

Although, It always gives me the "failed to convert" log. FFMPEG is already loaded. Is there something wrong with my code?

raddeee
  • 3
  • 4

1 Answers1

0

Ok, so the solution was quite easy.

I found the onProgress output saying that it needed permission so I noticed that I forgot to give my app the WRITE_EXTERNAL_STORAGE permission which was kind of a shame. And also, I changed the output$03d part to output%03d. Thanks Gyan for that advise.

raddeee
  • 3
  • 4