2

i want to run ffmepg command directly on android. a simple command

ffmpeg -i vid.mp4 out.mp4

now the issue is that i have searched the internet and found the best android ffmpeg can be found here

http://bambuser.com/opensource

I have downloaded it and read the readme file and compiled it. the folder is ffmpeg. I have kept it in <--projectfolder-->/ffmpeg/

there is a ffmpeg executeable file in ffmpeg folder called ffmpeg folder

i have copied it in files folder and run this command

  try {    

    Toast.makeText(this, "Working", Toast.LENGTH_SHORT).show();

    Process p = Runtime.getRuntime().exec("/data/data/com.koder.testffmpeg/files/ffmpeg -i /sdcard/vid.mp4 /sdcard/out.mp4");


    } catch (IOException e) {

    txt.setText(e.toString());

    Toast.makeText(this, e.toString(), Toast.LENGTH_LONG).show();

    e.printStackTrace();

    }

according to this link How do I reduce the video size captured by the default camera using FFMPEG in Android?

but still it does not work always exception i dont know what is going wrong can someone plz help me with this

java.io.IOException: Error running exec(). Command:[/data/data/com.koder.testffmpeg/files/ffmpeg -i /sdcard/vid.mp4 /sdcard/out.mp4] Working Directory: null Environment:null
5
  • What exception you are getting? Please post the log details. Commented Dec 27, 2011 at 9:02
  • 1
    java.io.IOException: Error running exec(). Command:[/data/data/com.koder.testffmpeg/files/ffmpeg -i /sdcard/vid.mp4 /sdcard/out.mp4] Working Directory: null Environment:null Commented Dec 27, 2011 at 9:59
  • The problem is that your ffmpeg command is probably not really marked as executable in the android folder. Use "adb shell" to connect and then "ls -l /data/data/com.koder.testffmpeg/files/ffmpeg" to see if it is really exectuable Commented Jan 2, 2013 at 18:56
  • were you able to find a solution for this?...I followed the same method and it is giving an IO exception. Can u please help me? Commented Jan 11, 2013 at 4:57
  • Same problem, could't find any solutions!! Commented May 17, 2017 at 7:50

4 Answers 4

2

You should use getBaseContext().getApplicationInfo().nativeLibraryDir instead of "/data/data/com.example.ffmpegnew/files/"

Sign up to request clarification or add additional context in comments.

Comments

1

Give executable permission to ffmpeg like so:

chmod 700 ffmpeg

Comments

0

Try using this:

Process proc = null;
ProcessBuilder pb = new ProcessBuilder();
proc = pb.command("String...yourCommand")
                    .redirectErrorStream(true).start();
BufferedReader bReader = new BufferedReader(new InputStreamReader(
                    proc.getInputStream()));

This code work for me for get system wakelock details in android.may be this will useful to you.

1 Comment

it did not work, gave lots of errors. how can i ffmpeg file in my project folder. and one more thing will this file be able to run on linux or not, becoz i have tried it and it did not work
0

You could combine above answers like this:

 Process p = Runtime.getRuntime().exec("chmod 700 "+getBaseContext().getApplicationInfo().nativeLibraryDir + "/ffmpeg ...");

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.