我正在构建一个简单的视频应用,并希望在录制的视频上嵌入水印。我正在使用ffmpeg进行此过程并已成功编译它。问题是当我尝试使用ndk-build.cmd命令将它与Android Studio中的项目链接时,它会给我以下错误:
C:\Users\MyPC\AppData\Local\Temp\ccIRLDZn.s: Assembler messages:
C:\Users\MyPC\AppData\Local\Temp\ccIRLDZn.s:8547: Error: unknown mnemonic `itt' -- `itt gt'
C:\Users\MyPC\AppData\Local\Temp\ccIRLDZn.s:8548: Error: unknown mnemonic `movgt' -- `movgt x25,x0'
C:\Users\MyPC\AppData\Local\Temp\ccIRLDZn.s:8549: Error: unknown mnemonic `movgt' -- `movgt x0,x1'
C:\Users\MyPC\AppData\Local\Temp\ccIRLDZn.s:8551: Error: unknown mnemonic `it' -- `it le'
C:\Users\MyPC\AppData\Local\Temp\ccIRLDZn.s:8552: Error: unknown mnemonic `movle' -- `movle x0,x2'
C:\Users\MyPC\AppData\Local\Temp\ccIRLDZn.s:8554: Error: unknown mnemonic `it' -- `it gt'
C:\Users\MyPC\AppData\Local\Temp\ccIRLDZn.s:8555: Error: unknown mnemonic `movgt' -- `movgt x25,x0'
make: *** [obj/local/arm64-v8a/objs/myProject_Videokit/ffmpeg.o] Error 1
我的开发环境是
首先,我安装了Cygwin64bit并添加了' make',' dos2unix',' c ++ gcc'包。我在C:/ android-ndk-r11c / sources中解压缩了ffmpeg文件夹。这是我使用的构建脚本。
config.sh
#!/bin/bash
NDK=C:/android-ndk-r11c
SYSROOT=$NDK/platforms/android-9/arch-arm/
TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64
#I used cygpath to avoid path errors in Cygwin.
CUR="$(cygpath -m "$(pwd)")"
TEMPDIR="$(cygpath -m "/tmp")"
TMP="$(cygpath -m "/tmp")"
TMPDIR="$(cygpath -m "/tmp")"
CPU=arm
PREFIX=$CUR/android/$CPU
ADDI_CFLAGS="-marm"
./configure
--prefix=$PREFIX
--enable-shared
--disable-static
--disable-doc
--disable-ffmpeg
--disable-ffplay
--disable-ffprobe
--disable-ffserver
--disable-doc
--disable-symver
--enable-protocol=concat
--enable-protocol=file
--enable-muxer=mp4
--enable-demuxer=mpegts
--enable-memalign-hack
--cross-prefix=$TOOLCHAIN/bin/arm-linux-androideabi-
--target-os=linux
--arch=arm
--enable-cross-compile
--sysroot=$SYSROOT
--extra-cflags="-Os -fpic $ADDI_CFLAGS"
--extra-ldflags="$ADDI_LDFLAGS"
$ADDITIONAL_CONFIGURE_FLAG
make clean
make
make install
我在Cygwin中运行此.sh(作为管理员),但它没有工作。所以我在Cygwin上输入了每一行,并且编译成功。我尝试了--target-os=android
和--target-os=linux
,但两者都没有解决上述问题。
然后我按照本教程(enoent.fr/blog/2014/06/20/compile-ffmpeg-for-android/)。基于此,我在我的项目中创建了一个本机方法并构建了头文件和c文件。(为此,我关注了这个视频.youtube.com / watch?v = kFtxo7rr2HQ)
之后,我克隆了这个repo(github.com/HikoQiu/JNI_INVOKE_FFMPEG)并复制 - 将jni文件夹粘贴到我的项目中。在制作Android.mk和Application.mk之后,我在Android Studio终端中运行了C:/android-ndk-r11c/ndk-build.cmd,它给了我上面的错误。
这些是我使用的Makefile。
myProject / app / src / main / jni / Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := com_example_project_Videokit
LOCAL_LDLIBS := -llog -ljnigraphics -lz
LOCAL_CFLAGS := -Wdeprecated-declarations
ANDROID_LIB := -landroid
LOCAL_C_INCLUDES := C:\android-ndk-r11c\sources\ffmpeg-3.0.2
LOCAL_SRC_FILES := com_example_project_Videokit.c ffmpeg.c ffmpeg_filter.c ffmpeg_opt.c cmdutils.c
LOCAL_SHARED_LIBRARIES := libavformat libavcodec libswscale libavutil
include $(BUILD_SHARED_LIBRARY)
$(call import-module,ffmpeg-3.0.2/android/arm)
myProject的/应用/ SRC /主/ JNI / Application.mk
APP_ABI := all
C:/android-ndk-r11c/sources/ffmpeg-3.0.2/android/arm/Android.mk
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE:= libavcodec
LOCAL_SRC_FILES:= lib/libavcodec-57.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE:= libavformat
LOCAL_SRC_FILES:= lib/libavformat-57.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE:= libswscale
LOCAL_SRC_FILES:= lib/libswscale-4.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE:= libavutil
LOCAL_SRC_FILES:= lib/libavutil-55.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE:= libavfilter
LOCAL_SRC_FILES:= lib/libavfilter-6.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE:= libwsresample
LOCAL_SRC_FILES:= lib/libswresample-2.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_SHARED_LIBRARY)
到目前为止,这是我的项目结构。 com_example_myProjct.c是我在build.gradle文件中用作moduleName的文件,在Android.mk中用作LOCAL_MODULE。
app
- build
- libs
- src
- androidTest
- main
- java
-com.example.myProject
-MainActivity
-Videokit //this is the class where I called the native method.
- jni
-Android.mk
-Application.mk
-cmdutils.c
-cmdutils.h
-com_example_myProject.c
-com_example_myProject.h
-ffmpeg.c
-ffmpeg.h
-ffmpeg_filter.c
-ffmpeg_opt.c
-ffmpeg_opt.h
-logjam.h
- obj
- res
AndroidManifest.xml
- test
应用/ gradle.build
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.myProjct"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0.0"
ndk {
moduleName "com_example_myProjet_Videokit"
}
sourceSets.main {
jni.srcDirs = []
jniLibs.srcDir 'src/main/libs'
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-rules.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
}
有什么想法吗?
答案 0 :(得分:0)
编译错误报告的最后一行是:
make: *** [obj/local/arm64-v8a/objs/myProject_Videokit/ffmpeg.o] Error 1
这是关键。您正在尝试为所有可用的ABI构建应用程序。我可以看到您的build.gradle
文件,但没有abiFilter
。我会以下一种方式(我不确定语法,但是):
android {
...
ndk {
moduleName "com_example_myProjet_Videokit"
abiFilters = "x86", "armeabi"
}
...
}
如果我是你,我会使用gradle-experimental plugin
,为所有需要的ABI预建ffmpeg库,然后使用this方法加载库。
所以主要问题 - 所有ABI都有一个库。这是不正确的。