Reputation: 660
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
Upvotes: 2
Views: 4117
Reputation: 1021
You could combine above answers like this:
Process p = Runtime.getRuntime().exec("chmod 700 "+getBaseContext().getApplicationInfo().nativeLibraryDir + "/ffmpeg ...");
Upvotes: 0
Reputation: 6572
You should use getBaseContext().getApplicationInfo().nativeLibraryDir
instead of "/data/data/com.example.ffmpegnew/files/"
Upvotes: 2
Reputation: 354
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.
Upvotes: 0