Mac 安装iOS集成FFmpeg详细步骤

                                      Mac 安装iOS集成FFmpeg详细步骤

一、Mac安装FFmpeg

1.下载FFmpeg安装文件下载地址(https://github.com/kewlbear/FFmpeg-iOS-build-script)

2.解压里面包含三个文件 uild-ffmpeg.sh为我们需要的

3.打开终端 切换至该文件所在目录 执行 ./uild-ffmpeg.sh

中间会提示需要其他相关东西

yasm 不必特意安装根据提示操作 回车、电脑密码一路往下即可

gas-preprocessor,一些资料说是需要这个东西,我没有理会可以正常安装下载地址

出现如下错误信息,执行最后一句话 后面跟随为Xcode安装路径 (Xcode9会有这个问题)

xcrun -sdk iphoneos clang is unable to create an executable file.
C compiler test failed.

If you think configure made a mistake, make sure you are using the latest
version from Git. If the latest version fails, report the problem to the
[email protected] mailing list or IRC #ffmpeg on irc.freenode.net.
Include the log file "config.log" produced by configure as this will help
solve the problem.

这时只需执行以下命令即可,问题链接:https://github.com/kewlbear/FFmpeg-iOS-build-script/issues/119

sudo xcode-select --switch /Applications/Xcode.app

4.继续执行./uild-ffmpeg.sh 比较耗时,完成后该文件夹下会生成多个文件如下(我们用的是ios)

Mac 安装iOS集成FFmpeg详细步骤

 

二、iOS的集成(大部分都结合kxmovie使用,具体实现demo在下篇文章中有地址)

1.将FFmpeg-iOS文件夹拖到项目中

2.添加相关依赖包(编译看报错信息,应该是如下几个包)

Mac 安装iOS集成FFmpeg详细步骤

3.配置路径

配置头文件搜索路径:在工程文件->Bulid Setting->Search Paths->Header Search Paths添加$(SRCROOT)/$(PRODUCT_NAME)/FFmpeg-iOS/include,(请根据自己实际路径更改)

4.编译常见出错信息

1)'config.h' file not found 缺少一个头文件,在刚才的文件夹scratch目录下随便找个往下找到该文件拖入项目即可;

2)'libavcodec/avcodec.h' file not found 类似的缺少文件,去ffmpeg-3.0文件夹下对应目录找,这里可能会遇到缺少多个文件,不要慌一个一个对应的找到拖入项目中即可

3)libavutil/avconfig.h' file not found  这个一般是第三步路径配置没有配对的问题,不排除确实缺少,缺少就依照2进行添加

4)Use of undeclared identifier 'PIX_FMT_RGB24'; did you mean 'AV_PIX_FMT_RGB24'  将 'PIX_FMT_RGB24'改变成'AV_PIX_FMT_RGB24'就行了

5)Expected a type Use of undeclared identifier 'UIImage'   缺少头文件#import <UIKit/UIKit.h>,添加上去即可

6)如果是FFmpeg3.0版本,会出现Implicit declaration of function 'avpicture_deinterlace' is invalid in C99  直接注释报红的地方即可