引言:
这几天公司项目做完了,想深入研究一下Android的多媒体。既然想研究媒体流,那么转码就一定得研究,由于之前已经做过一些硬编码,那么这次就来研究FFMPEG 这个大家伙吧,但是JNI 自己也不是很熟悉,所以遇到了一些问题,下面记录一下。
环境配置及编译:
博主是在ubuntu12.04下编译的,参考的文章为: 我是传送门 , 经过了几分钟的等待,编译出来的。
问题开始:
1.undefined reference to `av_register_all'
源代码为:
#include <stdio.h> #include <libavcodec/avcodec.h> #include <libavformat/avformat.h> int main(int argc,char*argv[]) { av_register_all(); return 0; }
编译之后,会提示:undefined reference to `av_register_all',
解决方法:添加对C 语言的支持
修正后代码为:
#include <stdio.h>
extern "C"
{
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
}
int main(int argc,char*argv[])
{
av_register_all();
return 0;
}
参考连接: 点击打开链接
2.no matching function for call to '_JNIEnv::NewStringUTF(
问题原因: 由于C 和 C++语法不一样的原因,在JNI中写法不一样
C版本的写法:
NewStringUTF(env, "Hello from native code!");
C++版本: