Home » Android » java – Ffmpeg Command in Android not working. Creating a Video of several Images-Exceptionshub

java – Ffmpeg Command in Android not working. Creating a Video of several Images-Exceptionshub

Posted by: admin February 26, 2020 Leave a comment

Questions:

I Try to load png’s from my Folder and put it together in a single Video.
I’m using Mobile-FFmpeg as Library and Android Studio

But I keep getting the ErrorCode after executing the Command:

I/mobile-ffmpeg: Command execution failed with rc=1 and the output below.

My Images are saved like this earlier

enter image description here

The Command i Use:
int rc = FFmpeg.execute(” ffmpeg -r 1/5 -i “+ src+”/img%03d.png -c:v libx264 -vf \”fps=25,format=yuv420p\” “+ src + “/ou1t.mp4”);

Here is the whole Code:

               String dirPath = Environment.getExternalStorageDirectory().getAbsolutePath()+"/FlyerMaker/ffmpeg";
            File dir = new File(dirPath);
            String src = Environment.getExternalStorageDirectory().getAbsolutePath()+"/FlyerMaker/ffmpeg";

            int rc = FFmpeg.execute(" ffmpeg -r 1/5 -i "+ src+"/img%03d.png -c:v libx264 -vf \"fps=25,format=yuv420p\" "+ src + "/ou1t.mp4");

            if (rc == RETURN_CODE_SUCCESS) {
                Log.i(Config.TAG, "Command execution completed successfully.");
            } else if (rc == RETURN_CODE_CANCEL) {
                Log.i(Config.TAG, "Command execution cancelled by user.");
            } else {
                Log.i(Config.TAG, String.format("Command execution failed with rc=%d and the output below.", rc));
                Config.printLastCommandOutput(Log.INFO);
            }

//clearing the Folder since I don’t need the pics anymore right after the code above

            for(int i = 0; i < 20 ; i++){
                String filePrefix = "img"; //imagename prefix
                String fileExtn = ".png";//image extention
                String a = filePrefix + String.format("%03d", i)+fileExtn;
                File file = new File(dir, a);
                file.delete();
                System.out.println("del"+i);
            }
How to&Answers: