如何编译ffmpeg
❶ 如何用Android NDK编译FFmpeg
一、安装cygwin、配置ndk和下载ffmpeg源码
这步就不说了,网上很多教程,再次声明本教程只针对ndk R4这个版本。需要说明的是,本人在cygwin安装路径下的.bash_profile文件中指定的NDK路径如下所示。因为本人装了好几个NDK,因此后面的R4只是个标示。
NDK_R4=/cygdrive/d/android-ndk-r4
export NDK_R4
二、编译前准备和编译
1、因为R4这个NDK比较旧,交叉编译的时候需要在一个Android环境中,那简单,创建一个Android空项目,把整个项目拷出来,在项目下建立一个文件夹jni,把ffmpeg0.6.6的源码拷进去。左图,HelloJni就是我新建的一个项目,Android.mk这时候你还没有,先不用管。右图ffmpeg-0.6.6文件夹的内容要跟我一样,直接就是代码。我这里的ffmpeg_cywin这个文件夹是随便建的,放哪里无所谓的。
2、在ffmpeg-0.6.6下建立一个文件config.sh,内容如下所示。需要注意的是,unix下的换行符和windows下是不一样,如果直接拷贝到windows下的记事本,后面执行这个config.sh的时候会出问题,这里我用的是notepad++编辑的,在编辑->档案格式转换->转换为UNIX格式。(注意,后面的所有的Android.mk的编辑都有此要求)。
简单说一下这个config.sh,PREBUILT和PLATFORM根据你安装ndk的位置而不同,config.sh其实是一个脚本,执行这个脚本的时候又调用了另外一个脚本configure,configure主要是根据编译选项(下面enable disable那些),生成相应的编译配置,就是说你想要编译ffmpeg什么模块就自己定制编译选项的内容。基本上这个文件只要修改一下PREBUILT和PLATFORM就行,其他都不用改。
#!/bin/bash
export PREBUILT=D://android-ndk-r4/build/prebuilt/windows/arm-eabi-4.4.0
export PLATFORM=D://android-ndk-r4/build/platforms/android-8/arch-arm
./configure --target-os=linux \
--arch=arm \
--enable-version3 \
--enable-gpl \
--enable-nonfree \
--disable-stripping \
--disable-ffmpeg \
--disable-ffplay \
--disable-ffserver \
--disable-ffprobe \
--disable-encoders \
--disable-muxers \
--disable-devices \
--disable-protocols \
--enable-protocol=file \
--enable-avfilter \
--disable-network \
--disable-mpegaudio-hp \
--disable-avdevice \
--enable-cross-compile \
--cc=$PREBUILT/bin/arm-eabi-gcc \
--cross-prefix=$PREBUILT/bin/arm-eabi- \
--nm=$PREBUILT/bin/arm-eabi-nm \
--extra-cflags="-fPIC -DANDROID" \
--disable-asm \
--enable-neon \
--enable-armv5te \
--extra-ldflags="-Wl,-T,$PREBUILT/arm-eabi/lib/ldscripts/armelf.x -Wl,-rpath-link=$PLATFORM/usr/lib -L$PLATFORM/usr/lib -nostdlib $PREBUILT/lib/gcc/arm-eabi/4.4.0/crtbegin.o $PREBUILT/lib/gcc/arm-eabi/4.4.0/crtend.o -lc -lm -ldl"
3、修改configure文件,找到下图的内容,修改成我这样,这个是用来存放执行脚本过程的临时文件的,我这里用的是D://NDK,你可以设置其他地方,但是要先创建好这个文件夹,放哪里无所谓的。
4、然后在cywin中进入ffmpeg0.6.6文件夹,执行chmod -x config.sh,然后执行./config,此过程需要一定的时间。如果这一步出现问题,很有可能是你config.sh中的PREBUILT和PLATFORM的路径设置不对,或者是你拷贝内容到config.sh的时候没有在UNIX格式下。执行完如下图所示。
5、在ffmpeg-0.6.6下会生成一个config.h文件,编辑它,找到#define restrict restrict这一行,把它改成#define restrict
6、在libavutil/libm.h下,把所有static的方法注释掉或者直接删掉。
7、修改libavcodec,libavfilter,libavformat,libavutil,libpostproc和libswscale目录的MakeFile文件,每个文件中,删除语句
include $( SUBDIR ) ../config.mak 和 include $ (SUBDIR) .. / subdir.mak。
libavcodec下的makefile中搜索inverse.o,把它所在的那一行删掉,要不编译的时候会冲突。
8、在ffmpeg-0.6.6文件夹下,创建av.mk文件(UNIX格式),内容如下:
#LOCAL_PATH is one of libavutil, libavcodec, libavformat, or libswscale
#include $(LOCAL_PATH)/../config-$(TARGET_ARCH).mak
include $(LOCAL_PATH)/../config.mak
OBJS :=
OBJS-yes :=
MMX-OBJS-yes :=
include $(LOCAL_PATH)/Makefile
# collect objects
OBJS-$(HAVE_MMX) += $(MMX-OBJS-yes)
OBJS += $(OBJS-yes)
FFNAME := lib$(NAME)
FFLIBS := $(foreach,NAME,$(FFLIBS),lib$(NAME))
FFCFLAGS = -DHAVE_AV_CONFIG_H -Wno-sign-compare -Wno-switch -Wno-pointer-sign
FFCFLAGS += -DTARGET_CONFIG=\"config-$(TARGET_ARCH).h\"
ALL_S_FILES := $(wildcard $(LOCAL_PATH)/$(TARGET_ARCH)/*.S)
ALL_S_FILES := $(addprefix $(TARGET_ARCH)/, $(notdir $(ALL_S_FILES)))
ifneq ($(ALL_S_FILES),)
ALL_S_OBJS := $(patsubst %.S,%.o,$(ALL_S_FILES))
C_OBJS := $(filter-out $(ALL_S_OBJS),$(OBJS))
S_OBJS := $(filter $(ALL_S_OBJS),$(OBJS))
else
C_OBJS := $(OBJS)
S_OBJS :=
endif
C_FILES := $(patsubst %.o,%.c,$(C_OBJS))
S_FILES := $(patsubst %.o,%.S,$(S_OBJS))
FFFILES := $(sort $(S_FILES)) $(sort $(C_FILES))
9、在jni文件夹下,创建Android.mk(UNIX格式),内容如下:
include $(all-subdir-makefiles)
10、在ffmpeg-0.6.6文件夹下,创建Android.mk,内容如下:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_STATIC_LIBRARIES := libavformat libavcodec libavutil libpostproc libswscale
LOCAL_MODULE := ffmpeg
include $(BUILD_SHARED_LIBRARY)
include $(call all-makefiles-under,$(LOCAL_PATH))
11、在ffmpeg-0.6.6\libavformat下,创建Android.mk,内容如下:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
include $(LOCAL_PATH)/../av.mk
LOCAL_SRC_FILES := $(FFFILES)
LOCAL_C_INCLUDES := \
$(LOCAL_PATH) \
$(LOCAL_PATH)/..
LOCAL_CFLAGS += $(FFCFLAGS)
LOCAL_CFLAGS += -include "string.h" -Dipv6mr_interface=ipv6mr_ifindex
LOCAL_LDLIBS := -lz
LOCAL_STATIC_LIBRARIES := $(FFLIBS)
LOCAL_MODULE := $(FFNAME)
include $(BUILD_STATIC_LIBRARY)
12、在ffmpeg-0.6.6\libavcodec下,创建Android.mk,内容如下:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
include $(LOCAL_PATH)/../av.mk
LOCAL_SRC_FILES := $(FFFILES)
LOCAL_C_INCLUDES := \
$(LOCAL_PATH) \
$(LOCAL_PATH)/..
LOCAL_CFLAGS += $(FFCFLAGS)
LOCAL_LDLIBS := -lz
LOCAL_STATIC_LIBRARIES := $(FFLIBS)
LOCAL_MODULE := $(FFNAME)
include $(BUILD_STATIC_LIBRARY)
13、在ffmpeg-0.6.6\libavfilter、libavutil、libpostproc和libswscale下,创建Android.mk,内容如下:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
include $(LOCAL_PATH)/../av.mk
LOCAL_SRC_FILES := $(FFFILES)
LOCAL_C_INCLUDES := \
$(LOCAL_PATH) \
$(LOCAL_PATH)/..
LOCAL_CFLAGS += $(FFCFLAGS)
LOCAL_STATIC_LIBRARIES := $(FFLIBS)
LOCAL_MODULE := $(FFNAME)
include $(BUILD_STATIC_LIBRARY)
14、然后在jni目录下,运行$NDK_R4/ndk-build -B,这里的命令需要根据你自己的情况修改,然后就开始编译了。过程需要10来分钟,成功之后,会在libs下生产libffmpeg.so。如果编译出来的libffmpeg.so只有1.5k,得如下修改一下NDK,再重新编译。
把下面红色部分加到NDK的build/core/build-binary.mk里:
LOCAL_STATIC_LIBRARIES := $(call strip-lib-prefix,$(LOCAL_STATIC_LIBRARIES))
LOCAL_STATIC_WHOLE_LIBRARIES := $(call strip-lib-prefix,$(LOCAL_STATIC_WHOLE_LIBRARIES))
...
static_libraries := $(call map,static-library-path,$(LOCAL_STATIC_LIBRARIES))
static_whole_libraries := $(call map,static-library-path,$(LOCAL_STATIC_WHOLE_LIBRARIES))
...
$(call mole-add-static-depends,$(LOCAL_MODULE),$(LOCAL_STATIC_LIBRARIES))
$(call mole-add-static-depends,$(LOCAL_MODULE),$(LOCAL_STATIC_WHOLE_LIBRARIES))
...
$(LOCAL_BUILT_MODULE): $(static_libraries) $(static_whole_libraries) $(shared_libraries)
...
$(LOCAL_BUILT_MODULE): PRIVATE_STATIC_LIBRARIES := $(static_libraries)
$(LOCAL_BUILT_MODULE): PRIVATE_WHOLE_STATIC_LIBRARIES := $(static_whole_libraries)
接着再将最外层ffmpeg/Android.mk里面的LOCAL_STATIC_LIBRARIES改成LOCAL_STATIC_WHOLE_LIBRARIES
❷ 如何用Android NDK编译FFmpeg
android的NDK开发需要在linux下进行:
因为需要把C/C++编写的代码生成能在arm上运行的.so文件,这就需要用到交叉编译环境,而交叉编译需要在linux系统下才能完成。
安装android-ndk开发包,这个开发包可以在google android 官网下载: 通过这个开发包的工具才能将android jni 的C/C++的代码编译成库
android应用程序开发环境: 包括eclipse、java、 android sdk、 adt等。
NDK编译步骤:
a.选择ndk自带的例子hello-jni,我的位于E:android-ndk-r5sampleshello-jni(根据具体的安装位置而定) 。
b.运行cygwin,输入命令cd /cygdrive/e/android-ndk-r5/samples/hello-jni,进入到E:android-ndk-r5sampleshello-jni目录。
c.输入$NDK/ndk-build,执行成功后,它会自动生成一个libs目录,把编译生成的.so文件放在里面。($NDK是调用我们之前配置好的环境变量,ndk-build是调用ndk的编译程序)
d.此时去hello-jni的libs目录下看有没有生成的.so文件,如果有,ndk就运行正常啦。
❸ 怎么编译ffmpeg release版本
FFmpeg在Windows系统下的编译过程,分四步:如下:1.配置编译环境2.下载FFMPEG的代码3.编译,获取FFMPEG库(头文件,lib,和DLL)4.在VC下配置,测试1.配置编译环境1)安装MSys下载文件:bash-3.1-MSYS-1.0.11-snapshot.tar.bz2m
❹ 如何把ffmpeg编译进motion
ffmpeg编译
首先解压ffmpeg-0.5.1.tar.bz2,,执行configure命令如下:
[plain] view plain
./configure --cc=arm-linux-gnueabihf-gcc --host-cc=arm-linux-gnueabihf --prefix=/home/***/iWork/common/gcc-linaro-arm-linux-gnueabihf-4.8-2013.10_linux --enable-cross-compile --arch=arm --disable-yasm
编译:
[plain] view plain
make
出现错误如下:
[plain] view plain
arm-linux-gnueabihf-gcc -DHAVE_AV_CONFIG_H -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -I. -I"/home/***/iWork/lamobo/motion-3.2.12-arm-project/ffmpeg-0.5.1"
-D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112 -std=c99 -fomit-frame-pointer -g -Wdeclaration-after-statement -Wall -Wno-switch -Wdisabled-optimization
-Wpointer-arith -Wrendant-decls -Wno-pointer-sign -Wcast-qual -Wwrite-strings -Wtype-limits -Wundef -O3 -fno-math-errno -fno-signed-zeros -c -o
libavcodec/dsputil.o libavcodec/dsputil.c
/tmp/ccOmDdh7.s: Assembler messages:
/tmp/ccOmDdh7.s:51789: Error: thumb conditional instruction should be in IT block -- `movgt fp,r9'
/tmp/ccOmDdh7.s:51790: Error: thumb conditional instruction should be in IT block -- `movgt r9,r8'
/tmp/ccOmDdh7.s:51792: Error: thumb conditional instruction should be in IT block -- `movle r9,r7'
/tmp/ccOmDdh7.s:51794: Error: thumb conditional instruction should be in IT block -- `movgt fp,r9'
/tmp/ccOmDdh7.s:51889: Error: thumb conditional instruction should be in IT block -- `movgt r9,r8'
/tmp/ccOmDdh7.s:51890: Error: thumb conditional instruction should be in IT block -- `movgt r8,ip'
/tmp/ccOmDdh7.s:51892: Error: thumb conditional instruction should be in IT block -- `movle r8,r6'
/tmp/ccOmDdh7.s:51894: Error: thumb conditional instruction should be in IT block -- `movgt r9,r8'
make: *** [libavcodec/dsputil.o] Error 1
这需要修改~/ffmpeg-0.5.1/config.mak,在OPTFLAGS(line:16)选项中添加:
[plain] view plain
-Wa,-mimplicit-it=thumb
加入这句的意思是在使用Thumb ISA指令编译时自动产生“IT”指令。 继续编译,又报错:
[plain] view plain
strip: Unable to recognise the format of the input file `ffmpeg'
这是strip没有使用交叉编译的版本所致,由于此时我们需要的库文件已经编成,所以这个错误可以忽略不计,修改config.mak中的strip为arm-linux-gnueabihf-strip,继续让编译完成
motion编译
motion中的ffmpeg.c是对ffmpeg api的封装,向其他模块提供功能。如在主程序文件motion.c中
[cpp] view plain
//......
#ifdef HAVE_FFMPEG
/* FFMpeg initialization is only performed if FFMpeg support was found
* and not disabled ring the configure phase.
*/
ffmpeg_init();
#endif /* HAVE_FFMPEG */
//......
这里ffmpeg_init就是ffmpeg.c中封装的方法:
[cpp] view plain
void ffmpeg_init()
{
motion_log(LOG_INFO, 0, "ffmpeg LIBAVCODEC_BUILD %d LIBAVFORMAT_BUILD %d", LIBAVCODEC_BUILD, LIBAVFORMAT_BUILD);
av_register_all();
#if LIBAVCODEC_BUILD > 4680
av_log_set_callback( (void *)ffmpeg_avcodec_log );
#endif
/* Copy the functions to use for the append file protocol from the standard
* file protocol.
*/
mpeg1_file_protocol.url_read = file_protocol.url_read;
mpeg1_file_protocol.url_write = file_protocol.url_write;
mpeg1_file_protocol.url_seek = file_protocol.url_seek;
mpeg1_file_protocol.url_close = file_protocol.url_close;
/* Register the append file protocol. */
#if LIBAVFORMAT_BUILD >= (52<<16 | 31<<8)
av_register_protocol(&mpeg1_file_protocol);
#else
register_protocol(&mpeg1_file_protocol);
#endif
}
我们需要在motion的Makefile中加入对ffmpeg模块的编译,并且打开HAVE_FFMPEG等开关。首先执行configure如下:
[plain] view plain
./configure CC=arm-linux-gnueabihf-gcc --host=arm-linux-gnueabihf --prefix=/home/stewart/iWork/common/gcc-linaro-arm-linux-gnueabihf-4.8-2013.10_linux
生成Makefile,在OBJ选项中添加ffmpeg.o:
[plain] view plain
OBJ = ffmpeg.o motion.o conf.o draw.o jpegutils.o $(VIDEO_OBJ) netcam.o \
netcam_ftp.o netcam_jpeg.o netcam_wget.o track.o \
alg.o event.o picture.o rotate.o webhttpd.o \
webcam.o
在CFLAGS选项中添加-DHAVE_FFMPEG -DFFMPEG_NEW_INCLUDES -DHAVE_FFMPEG_NEW的定义,加入libjpeg头文件搜索目录
[plain] view plain
libdir = ${prefix}/lib
incdir = ${prefix}/include
[plain] view plain
CFLAGS = -g -O2 -DHAVE_FFMPEG -DFFMPEG_NEW_INCLUDES -DHAVE_FFMPEG_NEW -D_REENTRANT
-DMOTION_V4L2 -DMOTION_V4L2_OLD -DTYPE_32BIT="int" -DHAVE_BSWAP -Wall
-DVERSION=\"3.2.12\" -Dsysconfdir=\"$( sysconfdir)\"
在LIBS中加入对ffmpeg库的支持:
[plain] view plain
LIBS = -L${libdir} -static -lavformat -lavcodec -lavutil -ljpeg -lm -lpthread
预备工作完成,make,编译报错:
[plain] view plain
motion.h:44:28: fatal error: linux/videodev.h: No such file or directory
compilation terminated.
由于linux-2.4以上的内核已经取消了videodev.h文件,需要安装libv4l-dev,然后将motion.h,video.h中的
[plain] view plain
#include <linux/videodev.h>
修改为
[cpp] view plain
#include <libv4l1-videodev.h>
继续,又报错:
[plain] view plain
track.c: In function ‘uvc_center’:
track.c:587:29: error: storage size of ‘control_s’ isn’t known
track.c:589:24: error: ‘V4L2_CID_PRIVATE_BASE’ undeclared (first use in this function)
track.c:589:24: note: each undeclared identifier is reported only once for each function it appears in
track.c:592:24: error: ‘VIDIOC_S_CTRL’ undeclared (first use in this function)
track.c:601:31: error: storage size of ‘queryctrl’ isn’t known
track.c:605:24: error: ‘VIDIOC_QUERYCTRL’ undeclared (first use in this function)
track.c:601:31: warning: unused variable ‘queryctrl’ [-Wunused-variable]
track.c:587:29: warning: unused variable ‘control_s’ [-Wunused-variable]
track.c:636:25: error: storage size of ‘control_s’ isn’t known
track.c:636:25: warning: unused variable ‘control_s’ [-Wunused-variable]
track.c: In function ‘uvc_move’:
track.c:724:29: error: storage size of ‘control_s’ isn’t known
track.c:726:24: error: ‘V4L2_CID_PRIVATE_BASE’ undeclared (first use in this function)
track.c:729:24: error: ‘VIDIOC_S_CTRL’ undeclared (first use in this function)
track.c:724:29: warning: unused variable ‘control_s’ [-Wunused-variable]
track.c:779:25: error: storage size of ‘control_s’ isn’t known
track.c:779:25: warning: unused variable ‘control_s’ [-Wunused-variable]
make: *** [track.o] Error 1
在track.c中添加:
[plain] view plain
#include <linux/videodev2.h>
继续,报错(怎么还有啊?):
[plain] view plain
gcc -L/usr/local/lib -o motion motion.o conf.o draw.o jpegutils.o video.o video2.o video_common.o netcam.o netcam_ftp.o netcam_jpeg.o netcam_wget.o track.o alg.o event.o picture.o rotate.o webhttpd.o webcam.o ffmpeg.o -lm -lpthread -ljpeg -L/usr/local/lib -lavformat -lavcodec -lavutil -lm -lz
/usr/local/lib/libavformat.a(file.o):(.data+0x60): multiple definition of `file_protocol'
ffmpeg.o:(.data+0x0): first defined here
collect2: ld returned 1 exit status
原来结构体file_protocol在libavformat.a和ffmpeg.o中重复定义了,分别打开两个定义:
[cpp] view plain
//libavformat/file.c:85
URLProtocol file_protocol = {
"file",
file_open,
file_read,
file_write,
file_seek,
file_close,
};
[cpp] view plain
//ffmpeg.c
URLProtocol file_protocol = {
"file",
file_open,
file_read,
file_write,
file_seek,
file_close,
#if LIBAVFORMAT_BUILD >= (52<<16 | 31<<8)
NULL,
NULL,
NULL,
#endif
};
将libavformat/file.c中的file_protocol定义注掉,重新编译一份libavformat.a。然后继续编译motion,又报错:
[plain] view plain
/home/xxx/iWork/Thrid_party/ffmpeg-0.5.1/libavformat/matroskadec.c:917: undefined reference to `BZ2_bzDecompressInit'
/home/xxx/iWork/Thrid_party/ffmpeg-0.5.1/libavformat/matroskadec.c:926: undefined reference to `BZ2_bzDecompress'
/home/xxx/iWork/Thrid_party/ffmpeg-0.5.1/libavformat/matroskadec.c:929: undefined reference to `BZ2_bzDecompressEnd'
这个需要libbz2库,下载地址http://www.bzip.org/downloads.html
编译安装libbz2后将-lbz2加入motion的Makefile的LIBS选项:
[plain] view plain
LIBS = -lpthread -ljpeg -L/usr/lib -lavformat -lavcodec -lavutil -lm -lz -lbz2
❺ FFmpeg之Linux下编译与调试
下面的一切都是在 root 模式下进行的,可以不再 root 模式下进行
基础环境就是编译代码的基础库,Ubuntu联网安装软件很简单,一个语句即可搞定,这里列出语句如下:
依赖库分两方面,参考以下网站列出的依赖库信息,本文选择的版本均参考于此网页: FFmpeg依赖库信息
首先创建 FFmpeg 代码目录,所有的源代码放在这个目录下
FFmpeg 编译之后,即可使用。编译生成的可执行程序在 ~/bin 目录下
注:上面的 ./configure 配置编译后并不能进行调试,需要如下配置.
刚才的工程可以运行,但不能debug。解决此问题,首先认定一点,生成的可执行程序中,ffmpeg 不包含调试信息,调试信息在 ffmpeg_g 中,debug 要选择 ffmpeg_g。
另外,./config选项也是确定包含调试信息的核心,需要在config中添加:
采用以下命令重新config:
一些注意事项; 在使用 ffplay 播放生成 h264 格式的视频时,播放速度会加快,解决方式:不要使用 FFmpeg 转码生成纯 h264 格式的视频,要使用一种容器包含 h264 视频,即生成一种音视频流格式,也就是不要生成纯粹的 h264 码流,而是生成诸如 mkv 等格式的文件。
❻ 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文件,至此编译结束。
❼ 如何编译wince平台能使用的ffmpeg库
如何编译wince平台能使用的ffmpeg库
在configure ffmpeg工程时,如果不特别指定,默认fdshow设备是被支持的,但编译后却没有.可以查看configure的日志文件,会发现找不到一些依赖的头文件.
所以最终编译出来的ffmpeg.exe, 用ffmpeg -formats来看,在indev一项中,一般只有vfwcap,而没有dsh
❽ 如何使用ndk编译ffmpeg静态库
如何使用ndk为ffmpeg编译rtmp+polarssl静态库?这个问题花了我整整一天时间。其中遇到很多小问题,这里记录一下,方便自己也方便其他人。
1、编译polarssl,查看其Readme文件即可,不需要configure,只需要make时带上必要的参数即可,不过要记得在每一次执行make命令时都带上CC的参数(指向你的arm gcc),因为我试过在make install时没有带上CC的参数,虽然能编译出polarssl但是未能正确被rtmp引用到。
2、因为前面我用的polarssl是当前最新(1.3.7)版本,而librtmp使用的好像是polarssl1.0.0以下版本的api,所以需要修改rtmp部分源码,让其调用新版polarssl的api,这里的修改可以参照《Migrating from PolarSSL-1.2 to the PolarSSL 1.3 branch》和《[rtmpmp] branch master updated. a312ac7 Fix compat with PolarSSL >= 1.1.0》。
3、出现 undefined reference to `havege_random’错误,这里是因为polarssl默认关闭了havege模块,需要你手动开启,主要就是修改include/polarssl/config.h,去掉POLARSSL_HAVEGE_C前的注释,也就是要定义POLARSSL_HAVEGE_C,如下:
#define POLARSSL_HAVEGE_C
4、在编译出上面两个库之后,可以开始编译ffmpeg(2.1.1版本)了,如果遇到下面的问题 check_pkg_config librtmp librtmp/rtmp.h RTMP_Socket
ERROR: librtmp not found
这里有三种解决方法:
第一种,因为是网络上传播最多的,算是比较简便的方法,就是修改ffmpeg的configure,将以下一行:
enabled librtmp && require_pkg_config librtmp librtmp/rtmp.h RTMP_Socket
改为:
enabled librtmp && require librtmp librtmp/rtmp.h RTMP_Socket -lrtmp -lpolarssl -lz
或者直接注释掉&& *** 部分,然后再自己加上librtmp的库路径也行
第二种,(比较推荐,因为解决了这个会顺带解决大部分找不到库的错误!)因为这里使用了pkg-config工具查找库,而这个工具ndk并没有附带提供,而出现check_pkg_config相关错误的话,只要稍加注意,会发现在使用configure配置ffmpeg的交叉编译时,已经有相应的pkg-config不存在的警告了。我对这个工具不熟悉,所以我只是简单地加上了一个软链接到系统的pkg-config,如下:
ln -s /usr/bin/pkg-config /home/cidy0106/android-ndk-r9d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-pkg-config
这个时候重新configure的话可能会出现找不到polarssl库的错误提示,需要修改一下librtmp安装目录里的librtmp.pc,把以下内容:
Libs: -L${libdir} -lrtmp -lz
改为:
Libs: -L${libdir} -lrtmp -lz -lpolarssl
至此,就可以正确编译出ffmpeg了
转载