一、编译针对iOS平台的ffmpeg库(kxmovie)
git clone git://github.com/kolyvan/kxmovie.git
cd kxmovie
git submodule update --init
rake
ViewController *vc;
vc = [KxMovieViewController movieViewControllerWithContentPath:path parameters:nil];
[self presentViewController:vc animated:YES completion:nil];
[rtsp @ 0x906cc00] UDP timeout, retrying with TCP
[rtsp @ 0x906cc00] Nonmatching transport in server reply
[rtsp @ 0x906cc00] Could not find codec parameters for stream 0 (Video: h264): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Couldn't find stream information
跟踪代码,错误是在avformat_find_stream_info获取流信息失败的时候的时候触发。
if(avformat_find_stream_info(pFormatCtx,NULL) < 0) {
av_log(NULL, AV_LOG_ERROR, "Couldn't find stream information\n");
goto initError;
}
……
// Open video file
pFormatCtx = avformat_alloc_context();
//有三种传输方式:tcp udp_multicast udp,强制采用tcp传输
AVDictionary* options = NULL;
av_dict_set(&options, "rtsp_transport", "tcp", 0);
if(avformat_open_input(&pFormatCtx, [moviePathcStringUsingEncoding:NSASCIIStringEncoding], NULL,&options) != 0) {
av_log(NULL, AV_LOG_ERROR, "Couldn't open file\n");
goto initError;
}
// Retrieve stream information
if(avformat_find_stream_info(pFormatCtx,NULL) < 0) {
av_log(NULL, AV_LOG_ERROR, "Couldn't find stream information\n");
goto initError;
} rake aborted!
******** Build failed ********
/Users/guomin/Desktop/kxmovie/Rakefile:8:in `system_or_exit'
/Users/guomin/Desktop/kxmovie/Rakefile:159:in `buildArch'
/Users/guomin/Desktop/kxmovie/Rakefile:207:in `block in <top (required)>'
Tasks: TOP => default => build_ffmpeg => build_ffmpeg_armv7
(See full trace by running task with --trace) 这个问题。怎么百度都没有办法。
后面就叫朋友发送了个lib 和ffmpeg 两个文件夹给我。
将这lib文件导入到项目中。。
ffmpeg 是只需要放到工程目录结构下的、不需要拖到工程了
build settings
Hader Search Paths 中 加 "$(SRCROOT)/FFmpeg"
library Search Paths 中加 $(PROJECT_DIR)/lib
1、 xcode出现 use of undeclared identifier 是因为没有包含头文件。导入头文件就可以
2、遇到此问题 ld: '' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. for architecture arm64
只需要 进入build settings把bitcode关掉就可以
3、Undefined symbols for architecture arm64:
"_BZ2_bzDecompressInit", referenced from:
_matroska_decode_buffer in libavformat.a(matroskadec.o)
"_iconv", referenced from:
_avcodec_decode_subtitle2 in libavcodec.a(utils.o)
"_BZ2_bzDecompress", referenced from:
_matroska_decode_buffer in libavformat.a(matroskadec.o)
"_BZ2_bzDecompressEnd", referenced from:
_matroska_decode_buffer in libavformat.a(matroskadec.o)
"_iconv_open", referenced from:
_avcodec_open2 in libavcodec.a(utils.o)
_avcodec_decode_subtitle2 in libavcodec.a(utils.o)
"_iconv_close", referenced from:
_avcodec_open2 in libavcodec.a(utils.o)
_avcodec_decode_subtitle2 in libavcodec.a(utils.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
解决方法:
"_iconv_close", referenced from: 这个是因为没有导入 libiconv 框架
"_BZ2_bzDecompress", referenced from: 这个是因为没有导入 libbz2.1.0 框架
下面是可能导致上面这类问题出现的原因及修改:
1.相关工程文件未导入
你可以直接在这里+进来,也可以在左边工程目录中把文件全部重新导人一遍(多人操作工程时,一般这种解决办法)
2..framework文件未导入
把xx文件库+进来,本问题"_OBJC_CLASS_$_ASIdentifierManager", 就是因为AdSupport.Framework类库未加
3.文件路径缺失
检查是否某些文件路径未加入进来或者写错了
工程编译报出:Undefined symbols for architecture i386:和"_OBJC_CLASS_$_xx", referenced from:错误,问题大致是由于上面这几种情况,把各个方面检查下基本就ok了。