ios 怎么配置编译ffmpeg

作者&投稿:希君 (若有异议请与网页底部的电邮联系)
ios 怎么配置编译ffmpeg~

IOS上编译ffmpeg需要先下载两个程序:iFrameExractor和ffmpeg
编译步骤:
1、在终端下: cd /iFrameExtractor/ffmpeg 建议开始就执行 sudo -s (获取权限命令)
2、在终端下输入 ./configure --prefix=/iFrameExtractor/ffmpeg --libdir=iFrameExtractor/ffmpeg/lib --enable-gpl --enable-static --disable-shared --enable-swscale --enable-zlib --enable-bzlib --disable-ffmpeg --disable-ffplay --disable-ffserver --enable-pthreads
3、执行make 这里会有一堆的编译情况。
注:最好先升级Command Line Tools,避免编译错误

4、执行make install。 (执行完后 到iFrameExtractor/ffmpeg/lib文件上去看看)
出现 libavcodec libavdevice libavformat libavutil libswscale5个.a文件
5、用xcode 打开iFrameExractor工程,确认Header Search Paths里有:"$(SRCROOT)/ffmpeg"路径。 $(SRCROOT)表示工程路径。同时可以看到iFrameExractor工程下ffmpeg文件下的.a文件都不是红色的了。

6、真机上编译(模拟器上i386,真机上是arm的,真机还分arm6 和arm7 )
以下是针对arm7的

/configure --disable-doc --disable-ffmpeg --disable-ffplay --disable-ffserver --enable-cross-compile --arch=arm --target-os=darwin --cc=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc --as='gas-preprocessor/gas-preprocessor.pl /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc' -- sysroot=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk --cpu=cortex-a8 --extra-cflags='-arch armv7' --extra-ldflags='-arch armv7 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk' --enable-pic
7、执行 make 和make install 就有上面的几个.a文件,至此编译结束。

FFmpeg在Windows系统下的编译过程,分四步:如下:1. 配置编译环境2. 下载FFMPEG的代码3. 编译,获取FFMPEG库(头文件,lib,和DLL)4. 在VC下配置,测试1. 配置编译环境1)安装MSys下载文件:  bash-3.1-MSYS-1.0.11-snapshot.tar.bz2  msysCORE-1.0.11-20080826.tar.gz解压msysCORE-1.0.11-20080826.tar.gz,比如解压到X:\msys(以下内容都使用该路径描述,X为你安装的盘符)。  解压bash-3.1-MSYS-1.0.11-snapshot.tar.bz2,产生一个名为bash-3.1的目录,在该目录下有一个子目录名为bin,其他的目录不需要关心。复制bin目录中的所有文件到D:\msys\bin,提示是否要覆盖sh.exe的时候,选择是。  到“D:\msys\postinstall”目录下执行pi.bat,在出现的提示中输入n回车后(这个不搞错了),按任意键退出即可。2)安装MinGW

一、系统环境

MAC OS X Mountain Lion 10.8.3、 XCode 5.1

二、编译FFMpeg

1、下载ffmpeg2.2.5版本代码,并解压。

2、下载并解压gas-preprocessor.pl (附件中有,zip格式,因网易博客不能上传zip后缀的文件,故加了个.rar)

在终端中使用cp命令将它复制到 /usr/sbin/目录,并赋予可执行权限。

sudo cp -f gas-preprocessor/gas-preprocessor.pl /usr/sbin/chmod +x /usr/sbin/gas-preprocessor.pl

3、在ffmpeg目录下创建一个config.sh脚本

#!/bin/bash
SDKVERSION="7.1"

ARCHS="armv7 armv7s i386"

DEVELOPER=`xcode-select -print-path`

cd "`dirname \"$0\"`"
REPOROOT=$(pwd)

# where we will store intermediary builds
INTERDIR="${REPOROOT}/built"
mkdir -p $INTERDIR

########################################
# Exit the script if an error happens

for ARCH in ${ARCHS}
do
if [ "${ARCH}" == "i386" ];
then
PLATFORM="iPhoneSimulator"
EXTRA_CONFIG="--arch=i386 --disable-asm --enable-cross-compile --target-os=darwin --cpu=i386"
EXTRA_CFLAGS="-arch i386"
EXTRA_LDFLAGS="-I${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer/SDKs/${PLATFORM}${SDKVERSION}.sdk/usr/lib"
else
PLATFORM="iPhoneOS"
EXTRA_CONFIG="--arch=arm --target-os=darwin --enable-cross-compile --cpu=cortex-a9 --disable-armv5te"
EXTRA_CFLAGS="-w -arch ${ARCH}"
fi

mkdir -p "${INTERDIR}/${ARCH}"

./configure --prefix="${INTERDIR}/${ARCH}" \
   --disable-neon \
   --disable-armv6 \
   --disable-armv6t2 \
   --disable-ffmpeg \
   --disable-ffplay \
   --disable-ffprobe \
   --disable-ffserver \
   --disable-iconv \
   --disable-bzlib \
   --enable-avresample \
   --sysroot="${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer/SDKs/${PLATFORM}${SDKVERSION}.sdk" \
   --cc="${DEVELOPER}/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" \
   --as='/usr/local/bin/gas-preprocessor.pl' \
   --extra-cflags="${EXTRA_CFLAGS} -miphoneos-version-min=${SDKVERSION}" \
   --extra-ldflags="-arch ${ARCH} ${EXTRA_LDFLAGS} -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/${PLATFORM}.platform/Developer/SDKs/${PLATFORM}${SDKVERSION}.sdk -miphoneos-version-min=${SDKVERSION}" ${EXTRA_CONFIG} \
   --enable-pic \
   --extra-cxxflags="$CPPFLAGS -isysroot ${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer/SDKs/${PLATFORM}${SDKVERSION}.sdk"

make && make install && make clean

done

mkdir -p "${INTERDIR}/universal/lib"

cd "${INTERDIR}/armv7/lib"
for file in *.a
do

cd ${INTERDIR}
xcrun -sdk iphoneos lipo -output universal/lib/$file  -create -arch armv7 armv7/lib/$file -arch armv7s armv7s/lib/$file -arch i386 i386/lib/$file
echo "Universal $file created."

done
cp -r ${INTERDIR}/armv7/include ${INTERDIR}/universal/

echo "Done."

SDKVERSION 是XCode的版本,通过`xcode-select -print-path`来获取XCode的安装路径,ARCHS是编译的三种模式,接下来在终端中cd到ffmpeg目录,./config.sh执行就可以编译了。等到编译完成后,在ffmpeg目录下会多出一个built目录,里面分别是armv7 armv7s i386及三个合并的universal版本了。



IOS上编译ffmpeg需要先下载两个程序:iFrameExractor和ffmpeg
编译步骤:
1、在终端下: cd /iFrameExtractor/ffmpeg 建议开始就执行 sudo -s (获取权限命令)
2、在终端下输入 ./configure --prefix=/iFrameExtractor/ffmpeg --libdir=iFrameExtractor/ffmpeg/lib --enable-gpl --enable-static --disable-shared --enable-swscale --enable-zlib --enable-bzlib --disable-ffmpeg --disable-ffplay --disable-ffserver --enable-pthreads
3、执行make 这里会有一堆的编译情况。
注:最好先升级Command Line Tools,避免编译错误

4、执行make install。 (执行完后 到iFrameExtractor/ffmpeg/lib文件上去看看)
出现 libavcodec libavdevice libavformat libavutil libswscale5个.a文件
5、用xcode 打开iFrameExractor工程,确认Header Search Paths里有:"$(SRCROOT)/ffmpeg"路径。 $(SRCROOT)表示工程路径。同时可以看到iFrameExractor工程下ffmpeg文件下的.a文件都不是红色的了。

6、真机上编译(模拟器上i386,真机上是arm的,真机还分arm6 和arm7 )
以下是针对arm7的

/configure --disable-doc --disable-ffmpeg --disable-ffplay --disable-ffserver --enable-cross-compile --arch=arm --target-os=darwin --cc=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc --as='gas-preprocessor/gas-preprocessor.pl /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc' -- sysroot=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk --cpu=cortex-a8 --extra-cflags='-arch armv7' --extra-ldflags='-arch armv7 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk' --enable-pic
7、执行 make 和make install 就有上面的几个.a文件,至此编译结束。

MAC OS X Mountain Lion 10.8.3、 XCode 5.1
二、编译FFMpeg
1、下载ffmpeg2.2.5版本代码,并解压。
2、下载并解压gas-preprocessor.pl (附件中有,zip格式,因网易博客不能上传zip后缀的文件,故加了个.rar)
在终端中使用cp命令将它复制到 /usr/sbin/目录,并赋予可执行权限。
sudo cp -f gas-preprocessor/gas-preprocessor.pl /usr/sbin/chmod +x /usr/sbin/gas-preprocessor.pl

3、在ffmpeg目录下创建一个config.sh脚本
#!/bin/bash
SDKVERSION="7.1"

ARCHS="armv7 armv7s i386"

DEVELOPER=`xcode-select -print-path`

cd "`dirname \"$0\"`"
REPOROOT=$(pwd)

# where we will store intermediary builds
INTERDIR="${REPOROOT}/built"
mkdir -p $INTERDIR

########################################
# Exit the script if an error happens

for ARCH in ${ARCHS}
do
if [ "${ARCH}" == "i386" ];
then
PLATFORM="iPhoneSimulator"
EXTRA_CONFIG="--arch=i386 --disable-asm --enable-cross-compile --target-os=darwin --cpu=i386"
EXTRA_CFLAGS="-arch i386"
EXTRA_LDFLAGS="-I${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer/SDKs/${PLATFORM}${SDKVERSION}.sdk/usr/lib"
else
PLATFORM="iPhoneOS"
EXTRA_CONFIG="--arch=arm --target-os=darwin --enable-cross-compile --cpu=cortex-a9 --disable-armv5te"
EXTRA_CFLAGS="-w -arch ${ARCH}"
fi

mkdir -p "${INTERDIR}/${ARCH}"

./configure --prefix="${INTERDIR}/${ARCH}" \
--disable-neon \
--disable-armv6 \
--disable-armv6t2 \
--disable-ffmpeg \
--disable-ffplay \
--disable-ffprobe \
--disable-ffserver \
--disable-iconv \
--disable-bzlib \
--enable-avresample \
--sysroot="${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer/SDKs/${PLATFORM}${SDKVERSION}.sdk" \
--cc="${DEVELOPER}/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" \
--as='/usr/local/bin/gas-preprocessor.pl' \
--extra-cflags="${EXTRA_CFLAGS} -miphoneos-version-min=${SDKVERSION}" \
--extra-ldflags="-arch ${ARCH} ${EXTRA_LDFLAGS} -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/${PLATFORM}.platform/Developer/SDKs/${PLATFORM}${SDKVERSION}.sdk -miphoneos-version-min=${SDKVERSION}" ${EXTRA_CONFIG} \
--enable-pic \
--extra-cxxflags="$CPPFLAGS -isysroot ${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer/SDKs/${PLATFORM}${SDKVERSION}.sdk"

make && make install && make clean

done

mkdir -p "${INTERDIR}/universal/lib"

cd "${INTERDIR}/armv7/lib"
for file in *.a
do

cd ${INTERDIR}
xcrun -sdk iphoneos lipo -output universal/lib/$file -create -arch armv7 armv7/lib/$file -arch armv7s armv7s/lib/$file -arch i386 i386/lib/$file
echo "Universal $file created."

done
cp -r ${INTERDIR}/armv7/include ${INTERDIR}/universal/


邗江区18791433806: 如何编译ffmpeg for iphone -
鲜薇萘哌: 编译iPhone下的FFmpeg mkdir ./build # configure for armv7 build ./configure \ --cc=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc \ --as='gas-preprocessor.pl /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc' \ --...

邗江区18791433806: ios下 怎么在代码中调用ffmpeg的命令 -
鲜薇萘哌: 理解 要使用FFMPEG,首先需要理解FFMPEG的代码结构.根据志哥的提示,ffmpeg的代码是包括两部分的,一部分是library,一部分是tool.api都是在library里面,如果直接调api来操作视频的话,就需要写c或者c++了.另一部分是tool,使用的是命令行,则不需要自己去编码来实现视频操作的流程.实际上tool只不过把命令行转换为api的操作而已. 2. 预热-在mac os下使用ffmpeg 在mac os下使用ffmpeg比较简单,可以直接使用命令行来操作.首先安装ffmpeg,这里

邗江区18791433806: ios下 怎么在代码中调用ffmpeg的命令 -
鲜薇萘哌: 调用命令:system("path/to/ffmpeg -param");调用的前提是要保证 ffmpeg 在有执行权限的目录下才可以生效.ffmpeg是一个多平台多媒体处理工具,拥有强大的处理视频和音频的功能.

邗江区18791433806: ios编译ffmpeg时如何添加x264的库 -
鲜薇萘哌: 找到问题了编译的时候首先要连接libx264 ,le-libx264 --enable-gpl --extra-cflags=-I/usr/local/include --extra-ldflags=-L/usr/local/lib 然后要打开这个编码器--enable-encoder=libx264,我就是这一步搞错了一直找不到,我在编译的时候禁掉了所有的编码器,终于可以继续走下去了 到DEVDIV.COM网站查看回答详情>>

邗江区18791433806: 编译ios的静态库必须用clang吗 -
鲜薇萘哌: IOS上编译ffmpeg需要先下载两个程序:iFrameExractor和ffmpeg编译步骤:

邗江区18791433806: 编辑码工具ffmpeg怎么使用 -
鲜薇萘哌: FFmpeg在Windows系统下的编译过程,分四步:如下:1. 配置编译环境2. 下载FFMPEG的代码3. 编译,获取FFMPEG库(头文件,lib,和DLL)4. 在VC下配置,测试1. 配置编译环境1)安装MSys下载文件: bash-3.1-MSYS-1.0.11-snapshot....

邗江区18791433806: 有在iphone下用ffmpeg的吗??
鲜薇萘哌: 照你的描述应该是编译成功了(有libavcodec.a那你编译的应该是静态库)而至于ffmpeg的调用的话你可以参考ffmpeg中的那几个example如output_example.c.

邗江区18791433806: 怎样使用ffmpeg 进行音频解码 -
鲜薇萘哌: 安装完成ffmpeg后,就可以使用ffmpeg进行音频文件格式转换.比如 ./ffmpeg -i /media/1.mp3 /media/1.wav, 通过该命令行可以将/media文件夹下1.mp3文件转换成WAV格式的.但是反过来 ./ffmpeg -i /media/1.WAV /media/1.MP3 却不能转换成...

邗江区18791433806: mac系统如何快速安装FFMPEG -
鲜薇萘哌: 先安装brew库 网页链接 Brew库官网 打开Terminal终端,输入并回车:/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" 安装完成后输入并回车:brew install ffmpeg 安装完成后测试:ffmpeg

邗江区18791433806: ios 怎么做一个rtmp播放器 -
鲜薇萘哌: ffmpeg本身实现了rtmp协议的解析,具体可以查看源代码,只是性能不如librtmp强,并且不支持rtmpt,rtmps等

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 星空见康网