我想写一个连接两个视频的安卓应用
我尝试了以下代码
InputStream in=null;
OutputStream os=null;
String appFileDirectory = getFilesDir().getPath();
final String executableFilePath = appFileDirectory + "/ffmpeg";
final String input ="concat:/mnt/sdcard/input1.mpg|/mnt/sdcrad/input2.mpg";
File executable=new File(executableFilePath);
try {
in = getAssets().open("ffmpeg");
os = new FileOutputStream(executable);
int read = 0;
byte[] bytes = new byte[1024];
while ((read = in.read(bytes)) != -1) {
os.write(bytes, 0, read);
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally {
if (in != null) {
try {
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (os != null) {
try {
// outputStream.flush();
os.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
executable.setExecutable(true);
Button b = (Button)findViewById(R.id.button);
b.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
try {
Process p = Runtime.getRuntime().exec(executableFilePath + "-i \""+ input + "\" -c copy /mnt/sdcrd/output.mpg");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
}
此代码没有给出任何错误或没有崩溃,但是当我单击按钮时没有任何反应。我创建了与 android 兼容的 ffmpeg 版本。那么任何人都可以帮助我如何从android java代码运行命令。