iOS平台在ffmpeg中使用librtmp

转载请注明出处:http://www.cnblogs.com/fpzeng/p/3202344.html

系统版本:OS X 10.8

一、在iOS平台上交叉编译librtmp

librtmp link时需要openssl,在iOS上编译openssl请参考以下脚本:https://github.com/x2on/OpenSSL-for-iPhone/blob/master/build-libssl.sh,假设openssl/*.h头文件放于

/a/b/c/openssl/include路径下,libcrypto.a和libssl.a库文件i386版本存放于/a/b/c/openssl/ios/libs/ios_i386路径下,libcrypto.a和libssl.a库文件armv7版本存放于/a/b/c/openssl/ios/libs/ios_armv7路径下。

首先获取librtmp代码:

git clone git://git.ffmpeg.org/rtmpdump

在rtmpdump中就有librtmp代码了,可以看到librtmp/Makefile文件已经存在了,我们需要做的就是export相关变量就行了。其中需要处理CROSS_COMPILE、XCFLAGS、XLDFLAGS三个变量。

1.1 编译i386版本

cd rtmpdump/librtmp
export CROSS_COMPILE=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/
export XCFLAGS="-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.1.sdk -I/a/b/c/openssl/ios/include -arch i386"
export XLDFLAGS="-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.1.sdk -L/a/b/c/openssl/ios/libs/ios_i386 -arch i386 "
make SYS=darwin

 1.2 编译armv7版本

export CROSS_COMPILE=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/
export XCFLAGS='-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk -I/a/b/c/openssl/ios/include -arch armv7' 
export XLDFLAGS
='-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk -L/a/b/c/openssl/ios/libs/openssl/ios_armv7 -arch armv7'
make SYS=darwin

1.3  调试

如果需要调试,请将librtmp/Makefile中设置优化选项产生debug信息。

OPT=-O0
CFLAGS=-Wall -g $(XCFLAGS) $(INC) $(DEF) $(OPT) $(SO_DEF)
LDFLAGS=$(XLDFLAGS) -g

其中,-O0能减少编译时间并产生调试信息。并且在编译和链接选项中添加-g选项产生debug symbol。

二、在ffmpeg中使用librtmp

假设librtmp/*.h头文件在/a/b/c/librtmp/include路径下,librtmp.a在/a/b/c/librtmp/libs/路径下。

执行配置时,添加选项开启librtmp并且指定头文件和链接库路径:

./configure --enable-librtmp
--extra-cflags=-I/a/b/c/librtmp/include 
--extra-ldflags=-L/a/b/c/librtmp/libs/

此时,提示错误:

ERROR: librtmp not found

查看日志文件config.log:

check_pkg_config librtmp librtmp/rtmp.h RTMP_Socket
ERROR: librtmp not found

ffmpeg尝试在检查librtmp时运行pkg-config,请将

enabled librtmp && require_pkg_config librtmp librtmp/rtmp.h RTMP_Socket

修改为

enabled librtmp

 

posted @ 2013-07-20 14:07  fpzeng  阅读(4254)  评论(1编辑  收藏  举报