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
Community
  • 1
  • 1
Iori
  • 660
  • 1
  • 10
  • 19
  • What exception you are getting? Please post the log details. – Vinod Maurya Dec 27 '11 at 09: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 – Iori Dec 27 '11 at 09: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 –  Jan 02 '13 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? – TharakaNirmana Jan 11 '13 at 04:57
  • Same problem, could't find any solutions!! – Akash Dubey May 17 '17 at 07:50

4 Answers4

2

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

Mert
  • 6,432
  • 6
  • 32
  • 68
1

Give executable permission to ffmpeg like so:

chmod 700 ffmpeg
andr
  • 15,970
  • 10
  • 45
  • 59
Duna
  • 1,564
  • 1
  • 16
  • 36
0

You could combine above answers like this:

 Process p = Runtime.getRuntime().exec("chmod 700 "+getBaseContext().getApplicationInfo().nativeLibraryDir + "/ffmpeg ...");
Eftekhari
  • 1,001
  • 1
  • 19
  • 37
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.

ThiefMaster
  • 310,957
  • 84
  • 592
  • 636
Ramindu Weeraman
  • 344
  • 2
  • 10
  • 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 – Iori Dec 27 '11 at 10:51