FFmpeg編譯出錯和解決方法
阿新 • • 發佈:2019-01-08
FFmpeg原始碼:
https://github.com/FFmpeg/FFmpeg
例子:
https://github.com/leixiaohua1020/simplest_ffmpeg_mobile
AS開啟上面的例子會有錯誤
錯誤1:
Error:(12, 0) Error: NDK integration is deprecated in the current plugin. Consider trying the new experimental plugin. For details, see http://tools.android.com/tech-docs/new-build-system/gradle-experimental. Set "android.useDeprecatedNdk=true" in gradle.properties to continue using the current NDK integration.
在專案根目錄新建檔案gradle.properties
,並增加一行程式碼:
android.useDeprecatedNdk=true
同步專案即可。
錯誤2:
Error:Execution failed for task ':app:compileDebugNdk'. > NDK not configured. Download the NDK from http://developer.android.com/tools/sdk/ndk/.Then add ndk.dir=path/to/ndk in local.properties. (On Windows, make sure you escape backslashes, e.g. C:\\ndk rather than C:\ndk)
未配置NDK
路徑。在local.properties
增加ndk路徑,增加後如下:
#sdk路徑
sdk.dir=D:\\Android\\sdk
#ndk路徑
ndk.dir=D:\\Android\\android-ndk-r10e
錯誤3:
Error:(31, 33) libavutil/samplefmt.h: No such file or directory
類似的錯誤很多,都是因為檔案相對目錄不對,按如下方式修改即可。
#include "libavutil/samplefmt.h"
//修改為
#include "../libavutil/samplefmt.h"
錯誤4:
Error:(58) undefined reference to `avio_enum_protocols'
類似錯誤也很多,需要在app/build.gradle
檔案android{}
內增加如下程式碼:
sourceSets {
main {
jni.srcDirs = []
jniLibs.srcDir 'src/main/jniLibs'
}
}
錯誤5:
Error:Execution failed for task ':app:compileDebugNdk'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'D:\Android\android-ndk-r10e\ndk-build.cmd'' finished with non-zero exit value 2
使用錯誤4的解決方法