本文主要是介绍android基于ffmpeg的简单视频播发器 编译ffmpeg,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
ffmpeg编译的文章网上很多,很简单,我是windows10系统
首先安装mingw:https://sourceforge.net/projects/mingw/files
在安装界面选择basic setup,把右边的都勾选,然后点击installation选择apply change进行下载安装
配置环境变量,在Path内添加
C:\MinGW\bin
C:\MinGW\msys\1.0\bin
完成后,下载yasm:http://yasm.tortall.net/Download.html
将下载的yasm改名为yasm.exe,放到C:\MinGW\msys\1.0\bin下
将ffmpeg目录下的configure文件的代码改成
SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)' SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)' LIB_INSTALL_EXTRA_CMD='$$(RANLIB)"$(LIBDIR)/$(LIBNAME)"' SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'忘了要改哪几个参数,就去网上找来对照一下
然后是创建.sh文件了,由于不知道windows怎么创建.sh文件,就直接把ffmpeg的version.sh复制一份改成arm.sh文件
5种cpu架构,我也不知道我配置的对不对,配置信息还是看不懂
arm64-v8a架构文件
#!/bin/sh
export TMPDIR=C:/f/ffmpegtemp
export NDK=C:/sdk/ndk-bundle
export SYSROOT=$NDK/platforms/android-21/arch-arm64/
export TOOLCHAIN=$NDK/toolchains/aarch64-linux-android-4.9/prebuilt/windows-x86_64
export CPU=arm64-v8a
export PREFIX=C:/f/output/$CPU
ADDI_CFLAGS=""
function build_one
{
./configure \
--prefix=$PREFIX \
--enable-shared \
--disable-static \
--disable-doc \
--disable-ffserver \
--enable-cross-compile \
--cross-prefix=$TOOLCHAIN/bin/aarch64-linux-android- \
--target-os=linux \
--arch=aarch64 \
--sysroot=$SYSROOT \
--extra-cflags="-Os -fpic $ADDI_CFLAGS" \
--extra-ldflags="$ADDI_LDFLAGS" \
$ADDITIONAL_CONFIGURE_FLAG
make clean
make
make install
}
build_one
armeabi架构
#!/bin/sh
export TMPDIR=C:/f/ffmpegtemp
export NDK=C:/sdk/ndk-bundle
export SYSROOT=$NDK/platforms/android-15/arch-arm/
export TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64
export CPU=arm
export PREFIX=C:/f/output/$CPU
ADDI_CFLAGS="-marm"
function build_one
{
./configure \
--prefix=$PREFIX \
--enable-shared \
--disable-static \
--disable-doc \
--disable-ffserver \
--enable-cross-compile \
--cross-prefix=$TOOLCHAIN/bin/arm-linux-androideabi- \
--target-os=linux \
--arch=$CPU \
--sysroot=$SYSROOT \
--extra-cflags="-Os -fpic $ADDI_CFLAGS" \
--extra-ldflags="$ADDI_LDFLAGS" \
$ADDITIONAL_CONFIGURE_FLAG
make clean
make
make install
}
build_one
armeabi-v7a架构
#!/bin/sh
export TMPDIR=C:/f/ffmpegtemp
export NDK=C:/sdk/ndk-bundle
export SYSROOT=$NDK/platforms/android-14/arch-arm/
export TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64
export CPU=armv7-a
export PREFIX=C:/f/output/$CPU
ADDI_CFLAGS="-marm"
function build_one
{
./configure \
--prefix=$PREFIX \
--enable-shared \
--disable-static \
--disable-doc \
--disable-ffserver \
--enable-cross-compile \
--cross-prefix=$TOOLCHAIN/bin/arm-linux-androideabi- \
--target-os=linux \
--arch=$CPU \
--sysroot=$SYSROOT \
--extra-cflags="-Os -fpic $ADDI_CFLAGS" \
--extra-ldflags="$ADDI_LDFLAGS" \
$ADDITIONAL_CONFIGURE_FLAG
make clean
make
make install
}
build_one
x86架构
#!/bin/sh
export TMPDIR=C:/f/ffmpegtemp
export NDK=C:/sdk/ndk-bundle
export SYSROOT=$NDK/platforms/android-14/arch-x86/
export TOOLCHAIN=$NDK/toolchains/x86-4.9/prebuilt/windows-x86_64
export CPU=x86
export PREFIX=C:/f/output/$CPU
ADDI_CFLAGS="-m32"
function build_one
{
./configure \
--prefix=$PREFIX \
--enable-shared \
--disable-static \
--disable-doc \
--disable-ffserver \
--enable-cross-compile \
--cross-prefix=$TOOLCHAIN/bin/i686-linux-android- \
--target-os=linux \
--arch=$CPU \
--sysroot=$SYSROOT \
--extra-cflags="-Os -fpic $ADDI_CFLAGS" \
--extra-ldflags="$ADDI_LDFLAGS" \
$ADDITIONAL_CONFIGURE_FLAG
make clean
make
make install
}
build_one
x86_64架构
#!/bin/sh
export TMPDIR=C:/f/ffmpegtemp
export NDK=C:/sdk/ndk-bundle
export SYSROOT=$NDK/platforms/android-21/arch-x86_64/
export TOOLCHAIN=$NDK/toolchains/x86_64-4.9/prebuilt/windows-x86_64
export CPU=x86_64
export PREFIX=C:/f/output/$CPU
ADDI_CFLAGS="-m64"
function build_one
{
./configure \
--prefix=$PREFIX \
--enable-shared \
--disable-static \
--disable-doc \
--disable-ffserver \
--enable-cross-compile \
--cross-prefix=$TOOLCHAIN/bin/x86_64-linux-android- \
--target-os=linux \
--arch=$CPU \
--sysroot=$SYSROOT \
--extra-cflags="-Os -fpic $ADDI_CFLAGS" \
--extra-ldflags="$ADDI_LDFLAGS" \
$ADDITIONAL_CONFIGURE_FLAG
make clean
make
make install
}
build_one
NDK是我的ndk路径
SYSROOT和TOOLCHAIN都是根据cpu架构需要选择匹配的
TMPDIR临时缓存路径
PREFIX是so文件生成路径
打开mingw
$ cd C:/ffmpeg/ffmpeg-3.3.2 进入到ffmpeg目录
$ ./xx.sh 开始编译
这篇关于android基于ffmpeg的简单视频播发器 编译ffmpeg的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!