/**
* 集成基于FFmpeg的框架+kxmovie的直播播放器
1.去github下载脚本https://github.com/kewlbear/FFmpeg-iOS-build-script
2.只有一个build-ffmpeg.sh脚本文件。在终端中转至脚本的目录,执行命令:./build-ffmpeg.sh
3.编译完成获得一些文件其中ffmpeg-3.0是源码,在FFmpeg-iOS中有两个文件夹,include和lib,前者是头文件后者是.a静态库,共有7个
4.将FFmpeg-iOS这个文件夹添加到工程中,注意添加的路径
5.在Build Setting中找到header search paths 添加头文件路径:$(SRCROOT)/工程名/.../include的上一级文件夹路径/include
6.添加依赖库libiconv.tbd、libbz2.tbd、libz.tbd、VideoToolBox.framework
7.创建一个pch文件导入#import <UIKit/UIKit.h>框架解决KxMovieDecoder.h文件中关于UI的错误
8.会报两个PIX_FMT_RGB24错误,解决办法按照提示替换成AV_PIX_FMT_RGB24
9.最后还会有一个C语言函数错误Implicit declaration of function 'avpicture_deinterlace' is invalid in C99,解决方式把该段注释掉
10.导入kxmovie这个库
*/
集成完之后包含内容:
屏幕快照 2017-05-07 下午3.58.10.png在控制器中用下面的代码测试:
NSString *path = @"http://live.hkstv.hk.lxdns.com/live/hks/playlist.m3u8";//@"http://192.168.2.13/test/1avi.avi";
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];
参考资料:
http://www.jianshu.com/p/c33f4c96074e
http://www.jianshu.com/p/ec432a8f5729
http://www.jianshu.com/p/147c03553e63
http://www.cocoachina.com/ios/20150514/11827.html
http://blog.sina.com.cn/s/blog_47522f7f0102vbwp.html
网友评论