ffmpeg 在ios中使用
ffmpeg的强大毋庸置疑,流媒体服务,录播,android,IOS,linux无处不见。
- 操作系统:Mac OS 10.8
- Xcode版本:Xcode 4.4
- 确保xcode的Command Line Tools已安装, Command Line Tools位于Xcode->Perference->Downloads目录下
- 确保git工作正常, 安装xcode后,在Terminal里git应该就可以正常工作了, 如果工作不正常,可以到下面的链接下载gitfor mac:
http://code.google.com/p/git-osx-installer/
1 下载代码
1.下载ffmpeg源代码
git clone git://source.ffmpeg.org/ffmpeg.git ffmpeg
参考:http://ffmpeg.org/download.html
2.下载ffmpeg-iphone-build
git clone https://github.com/gabriel/ffmpeg-iphone-build.git
参考:https://github.com/gabriel/ffmpeg-iphone-build
2 编译
- 拷贝ffmpeg-iphone-build/gas-preprocessor.pl到 /usr/sbin目录下
- 编译ffmpeg for iOS i386版本
(1)将新下载的ffmpeg拷贝到ffmpeg-iphone-build目录下,改名为ffmpeg-i386
(2)用TextEdit打开build-i386文件注释#svnco -r22403 svn://svn.ffmpeg.org/ffmpeg/trunk $FFMPEG_DIR这一行
(3)在CONFIGURE_OPTIONS里添加--disable-asm --enable-cross-compile
(4)将 ./configure修改成:
./configure--cc=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc--as="$SCRIPT_DIR/gas-preprocessor.pl/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc"--extra-ldflags=-L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk/usr/lib/system--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk--extra-cflags="-mdynamic-no-pic" --prefix="dist"$CONFIGURE_OPTIONS --target-os=darwin --arch=i386 --cpu=i386--extra-cflags='-arch i386' --extra-ldflags='-arch i386'
(4) 在Terminal里运行 ./build-i386
3 编译ffmpeg for iOS armv7版本
(1) 将新下载的ffmpeg拷贝到ffmpeg-iphone-build目录下,改名为ffmpeg-armv7
(2) 用TextEdit打开build-armv7文件注释#svnco -r22403 svn://svn.ffmpeg.org/ffmpeg/trunk
$FFMPEG_DIR这一行
(3) 在CONFIGURE_OPTIONS里添加--disable-asm--enable-cross-compile
(4) 将 ./configure修改成:
./configure--cc=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc--as="$SCRIPT_DIR/gas-preprocessor.pl/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc"--extra-ldflags=-L//Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/usr/lib/system--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk--extra-cflags="-mdynamic-no-pic" --prefix="dist"$CONFIGURE_OPTIONS --target-os=darwin --arch=armv7 --cpu=armv7--extra-cflags='-arch armv7' --extra-ldflags='-arch armv7'
(5)在Terminal里运行 ./build-armv7
4 编译ffmpeg for iOS armv6版本
(1) 将新下载的ffmpeg拷贝到ffmpeg-iphone-build目录下,改名为ffmpeg-armv6
(2) 用TextEdit打开build-armv6文件注释#svnco -r22403 svn://svn.ffmpeg.org/ffmpeg/trunk $FFMPEG_DIR这一行
(3) 在CONFIGURE_OPTIONS里添加--disable-asm--enable-cross-compile将
(4) ./configure修改成:
(5)
./configure--cc=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc--as="$SCRIPT_DIR/gas-preprocessor.pl /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc"--extra-ldflags=-L//Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/usr/lib/system--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk--extra-cflags="-mdynamic-no-pic" --prefix="dist"$CONFIGURE_OPTIONS --target-os=darwin --arch=armv6 --cpu=armv6--extra-cflags='-arch armv6' --extra-ldflags='-arch armv6'
(6) 在Terminal里运行 ./build-armv6
5 合并armv6 armv7 i386 创建fat类型的静态库
(1)创建build-universal文件。文件内容为
!/bin/tcsh -f
mkdir universal
mkdir lib
mkdir armv6
mkdir armv7
mkdir i386
mv ffmpeg-armv6/libavcodec/libavcodec.a armv6/
mv ffmpeg-armv6/libavdevice/libavdevice.a armv6/
mv ffmpeg-armv6/libavformat/libavformat.a armv6/
mv ffmpeg-armv6/libavutil/libavutil.a armv6/
mv ffmpeg-armv6/libswscale/libswscale.a armv6/
mv ffmpeg-armv7/libavcodec/libavcodec.a armv7/
mv ffmpeg-armv7/libavdevice/libavdevice.a armv7/
mv ffmpeg-armv7/libavformat/libavformat.a armv7/
mv ffmpeg-armv7/libavutil/libavutil.a armv7/
mv ffmpeg-armv7/libswscale/libswscale.a armv7/
mv ffmpeg-i386/libavcodec/libavcodec.a i386/
mv ffmpeg-i386/libavdevice/libavdevice.a i386/
mv ffmpeg-i386/libavformat/libavformat.a i386/
mv ffmpeg-i386/libavutil/libavutil.a i386/
mv ffmpeg-i386/libswscale/libswscale.a i386/
rm universal/.a
lipo -create -arch armv6 armv6/libavcodec.a-arch armv7 armv7/libavcodec.a -arch i386 i386/libavcodec.a -outputuniversal/libavcodec.a
lipo -create -arch armv6 armv6/libavdevice.a-arch armv7 armv7/libavdevice.a -arch i386 i386/libavdevice.a -outputuniversal/libavdevice.a
lipo -create -arch armv6 armv6/libavformat.a-arch armv7 armv7/libavformat.a -arch i386 i386/libavformat.a -outputuniversal/libavformat.a
lipo -create -arch armv6 armv6/libavutil.a-arch armv7 armv7/libavutil.a -arch i386 i386/libavutil.a -outputuniversal/libavutil.a
lipo -create -arch armv6 armv6/libswscale.a-arch armv7 armv7/libswscale.a -arch i386 i386/libswscale.a -outputuniversal/libswscale.a
rm lib/.a
cp universal/*.a lib/
(2)运行build-universal文件./build-universal
6 编译完成,编译成功的静态库在目录lib下
- 分享
- 举报
-
浏览量:798次2023-12-20 17:38:18
-
浏览量:2749次2020-08-14 18:40:18
-
浏览量:4769次2022-05-27 15:56:26
-
浏览量:6420次2020-10-09 14:28:11
-
浏览量:2400次2019-11-09 18:26:29
-
浏览量:11167次2021-07-13 16:37:15
-
浏览量:1536次2023-12-29 17:51:55
-
浏览量:1567次2024-02-04 17:13:47
-
浏览量:2670次2019-11-13 17:04:17
-
浏览量:4181次2018-05-25 21:45:17
-
浏览量:925次2024-01-17 11:25:11
-
浏览量:2314次2018-12-20 11:54:45
-
浏览量:2272次2020-04-24 11:04:36
-
浏览量:4644次2021-04-23 14:10:09
-
浏览量:1663次2018-09-21 14:10:02
-
浏览量:638次2023-12-18 18:31:22
-
浏览量:2997次2019-11-09 19:10:44
-
浏览量:3293次2018-06-08 17:07:30
-
浏览量:2164次2020-03-19 18:04:02
-
广告/SPAM
-
恶意灌水
-
违规内容
-
文不对题
-
重复发帖
david
感谢您的打赏,如若您也想被打赏,可前往 发表专栏 哦~
举报类型
- 内容涉黄/赌/毒
- 内容侵权/抄袭
- 政治相关
- 涉嫌广告
- 侮辱谩骂
- 其他
详细说明