【发布时间】:2015-01-31 23:08:32
【问题描述】:
我正在尝试构建一个使用 FFmpeg 本机代码进行视频解码和编码的 Android 应用程序。我有一台运行 32 位 Ubuntu 14.04、ADT 版本 23 的 64 位机器。我下载了 FFmpeg-2.4.4(32 位)并按照此处提到的步骤为 Android 构建它 - http://www.roman10.net/how-to-build-ffmpeg-with-ndk-r9/
我使用了最新的 Android NDK,即 NDK r10c。为了测试,我使用了此链接中给出的 FFmpeg 的 API 示例代码 - http://ffmpeg.org/doxygen/trunk/decoding__encoding_8c-source.html
我能够成功构建所有共享对象,并且 Android 项目成功编译,没有任何错误。
以下代码是加载所有共享对象的Android代码
public class CallNative {
public static String libName = "decode_encode" ;
public CallNative(){
System.loadLibrary("avutil-54");
System.loadLibrary("swresample-1");
System.loadLibrary("avcodec-56");
System.loadLibrary("avformat-56");
System.loadLibrary("swscale-3");
System.loadLibrary("avfilter-5");
System.loadLibrary(libName);
}
public native int decode(String Filename, int length);
}
而且,这就是从 Android 调用 decode 函数的方式。
Uri videoURI = Uri.parse(fileUri.toString());
String videoFilePath = getFilePathFromURI(getApplicationContext(), videoURI);
Log.d("SPLASH","Entering native decode call");
CallNative n = new CallNative();
n.decode(videoFilePath, videoFilePath.length());
Log.d("SPLASH","successfully returned from decode call");
当我调试时,应用程序在进入本机函数调用时崩溃。我收到以下链接器错误。
W/linker(32244): libavcodec-56.so has text relocations. This is wasting memory and prevents security hardening. Please fix.
我也对 FFmpeg 2.4.3 和 2.0.6 包进行了同样的尝试。我遇到了同样的错误。
如何解决?
【问题讨论】:
标签: java android android-ndk ffmpeg linker-errors