ffmpeg在linux编译
ffmpeg是用来记录,转换数字音频和视频,并能将其转化为流的开源框架,以下编译so和搭建指令环境
编译so
一.配置环境
下载ndk和ffmpeg
vi /etc/profile
export NDK_HOME=/workspace/ffmpeg/android-ndk-r15c
验证环境 ndk-build -v
添加ffmpeg目录下build_android.sh
添加运行权限 chmod 777 build_android.sh
运行./build_android
生成so库文件 ffmpeg下android/arm/lib
二.注意事项
build_android.sh配置平台系统需要是android-12,且不能太高 因为ndk版本有对应
配置生成so版本文件名 ffmpeg目录下configure配置文件(新版本已修复3.2.14)
vi cofigure
#SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
#LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
#SLIB_INSTALL_NAME='$(SLIBNAME_WITH_VERSION)'
#SLIB_INSTALL_LINKS='$(SLIBNAME_WITH_MAJOR) $(SLIBNAME)'
SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
LIB_INSTALL_EXTRA_CMD='$$(RANLIB)"$(LIBDIR)/$(LIBNAME)"'
SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
SLIB_INSTALL_LINKS='$(SLIBNAME)'
三.编译过程问题(先本地编译)
1.需要安装yasm和pkg-config,可以通过apt-get install yasm;apt-get install pkg-config
2.提示request for member 's_addr' in something not a tructure(4.1.3)
需要升级NDK版本,下载android-ndk-r17
3.头文件找不到
CFALGS_INCLUDE="-I${NDK_PATH}/sysroot/usr/include/$4 -isysroot ${NDK_PATH}/sysroot"
4.变量名称问题
修改变量名称B0改为BB0
5.C compiler test failed.
检测gcc路径版本是否存在
6.ERROR: x265 not found using pkg-config
x265库找不到 把/usr/bin/pkg-config到对应ndk目录toolchains/arm-linux-androideabi-4.9/prebuiltnux-x86_64/bin 方案1:arm-linux-androideabi-pkg-config 方案2:配置PKG_CONFIG_PATH参数 方案3:添加参数pkg_config_path
三.x264编译
1.下载wget -c https://code.videolan.org/videolan/x264/-/archive/master/x264-master.tar.bz2
2.修改configure文件将SONAME=libx264.so.$API改为SONAME=lib264.$API.so
3. ./configure --prefix=/usr/local/h264 --disable-asm && make;make install
链接地址:http://www.videolan.org/developers/x264.html
四.fdk-acc编译
1.下载wget -c wget -c https://nchc.dl.sourceforge.net/project/opencore-amr/fdk-aac/fdk-aac-0.1.6.tar.gz
2.找到m4打开libtool.m4, so.1替换so $versuffix删掉 $major删掉
3../configure --prefix=/usr/local/fdk && make;make install
链接地址:https://sourceforge.net/projects/opencore-amr/files/fdk-aac/
五.错误
1.error: ‘x264_bit_depth’ undeclared
版本兼容问题
六.链接
https://github.com/mabeijianxi/FFmpeg4Android
https://blog.csdn.net/jacke121/article/details/95533888
https://blog.csdn.net/caoshangpa/article/details/51392445
下载h264
http://download.videolan.org/x264/snapshots/
编译h264
https://blog.csdn.net/season_hangzhou/article/details/24399371
编译x265
https://mozi100.com/blog/detail?blog_id=47
脚本参考
https://github.com/mabeijianxi/FFmpeg4Android
编码流程
https://www.jianshu.com/p/bd95b9e8fed2
https://blog.csdn.net/zwz1984/article/details/82824524
搭建指令环境
一.下载
下载地址:http://www.ffmpeg.org/download.html
wget -c http://www.ffmpeg.org/releases/ffmpeg-3.2.14.tar.gz
二.解压编译
1.依赖安装
apt-get install nasm;apt-get install yasm;apt-get install libx264-dev;apt-get install libx265-dev libnuma-dev;apt-get install libvpx-dev;apt-get install libfdk-acc-dev;apt-get install libmp3lame-dev;apt-get install libopus-dev;
2.tar -jxvf ffmpeg-4.2.1.tar.bz2
3.目录下运行
./configure --enable-shared --prefix=/usr/local/ffmpeg
make
make install
4.添加库链接
vi /etc/ld.so.conf/ffmpeg.conf
/usr/local/ffmpeg/lib
ldconfig
5.配置环境变量
vi /etc/profile
export FFMPEG=/usr/local/ffmpeg
export PATH=$PATH:$FFMPEG/bin