最近有同学来询问FFmpeg
框架的使用方法
以下过程中如有问题,请简信我.
使用环境
- Mac OS Yosemite 10.10.5
开发工具
-
Xcode 7.0
-
Terminal
需要的文件链接
编译适用于iOS平台的FFmpeg静态库
-
打开终端
Terminal
进入下载后的gas-preprocessor
文件夹-
将文件夹内的
gas-preprocessor.pl
文件拷贝到/usr/sbin/
目录下 -
修改
/usr/sbin/gas-preprocessor.pl
的文件权限为可执行权限chmod 777 /usr/sbin/gas-preprocessor.pl
-
-
执行
FFmpeg-iOS-build-script-master
文件夹内的build-ffmpeg.sh
- 编译所有的版本
arm64
、armv7
、x86_64
的静态库
./build-ffmpeg.sh
- 编译支持
arm64
架构的静态库
./build-ffmpeg.sh arm64
- 编译适用于
armv7
和x86_64(64-bit simulator)
的静态库
./build-ffmpeg.sh armv7 x86_64
- 编译合并的版本
./build-ffmpeg.sh lipo
- 编译所有的版本
编译静态库遇到的问题
-
yasm
没有安装的情况-
解决方案
1
-
进入下载后的
yasm
文件夹,通过编译安装命令yasm
./configure && make -j 4 && sudo make install
-
-
解决方案
2
-
使用Homebrew包管理器,进行安装
brew install yasm
-
-
测试是否安装成功
yasm --verision
-
-
c test failed
的情况-
xcode
环境安装过多,使用xcode-select
选择默认的工具路径/Applications/Xcode-beta.app
sudo xcode-select -s /Applications/Xcode-beta.app
-
使用编译完成的FFmpeg
静态库
-
编译成功后,即可将FFmpeg-iOS文件夹(包含include和lib)引入到Xcode内
-
加入依赖库libz.lib
-
加入依赖库libbz2.lib
-
加入依赖库libiconv.lib
-
如有编译错误,链接文件不存在
修改Build Setting Header Search Paths = $(SRCROOT)/LOFFmpegSample/FFmpeg-iOS/include
使用框架kxmovie
播放视频
NSString *path = @"";
NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
// increase buffering for .wmv, it solves problem with delaying audio frames
if ([path.pathExtension isEqualToString:@"wmv"])
parameters[KxMovieParameterMinBufferedDuration] = @(5.0);
// disable deinterlacing for iPhone, because it's complex operation can cause stuttering
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
parameters[KxMovieParameterDisableDeinterlacing] = @(YES);
KxMovieViewController *vc = [KxMovieViewController movieViewControllerWithContentPath:path
parameters:parameters];
[self presentViewController:vc animated:YES completion:nil];
实例工程:
LOFFmpeg
网友评论
C compiler test failed. 求解答
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- 0:01:14 --:--:-- 0curl: (7) Failed to connect to www.ffmpeg.org port 80: Operation timed out
building arm64...
./build-ffmpeg.sh: line 130: /Users/****/Desktop/测试/FFmpeg-iOS-build-script-master/ffmpeg-3.3/configure: No such file or directory
是yasm --version
不是 yasm --verision
然后是漫长的等待
xcrun -sdk iphoneos clang is unable to create an executable file.
C compiler test failed.
首先感谢楼主的分享。但是我在实际遇到一个问题,希望楼主指点一下,我需要在iOS下支持win下的rmvb,avi,asf等格式,因此我编译出来的包有385M,而我看到一款app,也能播放同样的win下的格式,
而它的大小才11M,iOS原生库是不支持的。请问楼主,他是用啥技术实现的?
Undefined symbols for architecture x86_64:
"_AVMediaTypeAudio", referenced from:
_avf_read_header in libavdevice.a(avfoundation.o)
"_AVMediaTypeVideo", referenced from:
_avf_read_header in libavdevice.a(avfoundation.o)
"_CMAudioFormatDescriptionGetStreamBasicDescription", referenced from:
_avf_read_header in libavdevice.a(avfoundation.o)
"_CMBlockBufferCopyDataBytes", referenced from:
_avf_read_packet in libavdevice.a(avfoundation.o)
"_CMBlockBufferGetDataLength", referenced from:
_avf_read_header in libavdevice.a(avfoundation.o)
_avf_read_packet in libavdevice.a(avfoundation.o)
"_CMSampleBufferGetDataBuffer", referenced from:
_avf_read_header in libavdevice.a(avfoundation.o)
_avf_read_packet in libavdevice.a(avfoundation.o)
"_CMSampleBufferGetFormatDescription", referenced from:
_avf_read_header in libavdevice.a(avfoundation.o)
"_CMSampleBufferGetImageBuffer", referenced from:
_avf_read_header in libavdevice.a(avfoundation.o)
_avf_read_packet in libavdevice.a(avfoundation.o)
"_CMSampleBufferGetOutputSampleTimingInfoArray", referenced from:
_avf_read_packet in libavdevice.a(avfoundation.o)
"_CMVideoFormatDescriptionGetDimensions", referenced from:
_avf_read_header in libavdevice.a(avfoundation.o)
"_OBJC_CLASS_$_AVCaptureAudioDataOutput", referenced from:
objc-class-ref in libavdevice.a(avfoundation.o)
"_OBJC_CLASS_$_AVCaptureDevice", referenced from:
objc-class-ref in libavdevice.a(avfoundation.o)
"_OBJC_CLASS_$_AVCaptureDeviceInput", referenced from:
objc-class-ref in libavdevice.a(avfoundation.o)
"_OBJC_CLASS_$_AVCaptureSession", referenced from:
objc-class-ref in libavdevice.a(avfoundation.o)
"_OBJC_CLASS_$_AVCaptureVideoDataOutput", referenced from:
音频参数: aac 44100HZ 24kb/s
如何设置