在学习本教程时:https://github.com/cine-io/android-ffmpeg-with-rtmp并且在Ubuntu 14.04 64位中成功编译后,在尝试执行ffmpeg时出现IOException:
String abspath = getApplicationInfo().nativeLibraryDir;
// Change the permissions
try {
Runtime.getRuntime().exec("chmod -R 777 "+ abspath).waitFor();
} catch (InterruptedException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
String cameraPath = "/storage/emulated/0/DCIM/Camera/";
String cmd = "ffmpeg -i "+ cameraPath + "VID_20150728_150045662.mp4 -y "+ cameraPath + "output.mp4";
ProcessBuilder processBuilder = new ProcessBuilder(cmd);
final Map<String, String> environment = processBuilder.environment();
environment.put("LD_LIBRARY_PATH", getDir("lib", 0).getAbsolutePath());
try {
Process process = processBuilder.start();
} catch (IOException e) {
e.printStackTrace();
}
IOException是:
运行exec()时出错。命令:[ffmpeg -i /storage/emulated/0/DCIM/Camera/VID_20150728_150045662.mp4 -y /storage/emulated/0/DCIM/Camera/output.mp4]工作目录:null 环境:[ANDROID_ROOT = / system, EMULATED_STORAGE_SOURCE = / mnt / shell / emulated,LOOP_MOUNTPOINT = / mnt / obb, EMULATED_STORAGE_TARGET = / storage / emulated,ANDROID_BOOTLOGO = 1, LD_LIBRARY_PATH = /数据/数据/ douglasanunciacao.ndksample / app_lib, EXTERNAL_STORAGE = / storage / emulated / legacy,ANDROID_SOCKET_zygote = 11, ANDROID_DATA = /数据, PATH = / sbin目录:/供应商/ bin中:/系统/ sbin目录:/系统/ bin中:/系统/ XBIN, ANDROID_ASSETS = / system / app,ASEC_MOUNTPOINT = / mnt / asec, BOOTCLASSPATH = /系统/框架/ core.jar添加:/system/framework/conscrypt.jar:/system/framework/okhttp.jar:/system/framework/core-junit.jar:/system/framework/bouncycastle.jar:/系统/框架/ ext.jar:/system/framework/framework.jar:/system/framework/framework2.jar:/system/framework/telephony-common.jar:/system/framework/voip-common.jar:/系统/framework/mms-common.jar:/system/framework/android.policy.jar:/system/framework/services.jar:/system/framework/apache-xml.jar:/system/framework/webviewchromium.jar:/系统/框架/电话-msim.jar:/system/framework/oem-services.jar:/system/framework/qcmediaplayer.jar, ANDROID_PROPERTY_WORKSPACE = 9,0,ANDROID_STORAGE = / storage]
有谁知道这个问题的解决方案?
答案 0 :(得分:1)
您可能需要在命令中获取ffmpeg
的完全限定路径。
如果它位于/data/data/douglasanunciacao.ndksample/app_lib
文件夹中,则String cmd = "/data/data/douglasanunciacao.ndksample/app_lib/ffmpeg -i "+ cameraPath + "VID_20150728_150045662.mp4 -y "+ cameraPath + "output.mp4";