1.编译ijk:
https://www.jianshu.com/p/d817d9caaca6
2.解决IJK在子线程执行UI的问题:
https://blog.csdn.net/mlcldh/article/details/101155942
3.解决硬解码失败:
找到vtbformat_init 方法,下面更改最好在IJKVideoToolBoxAsync.m和IJKVideoToolBoxSync.m 文件中都同步改下
3.1 注释掉 validate_avcC_spc 如下,在vtbformat_init中出现了两次
// if (!validate_avcC_spc(extradata, extrasize, &fmt_desc->max_ref_frames, &sps_level, &sps_profile)) {
//goto failed;
// }
3.2 ff_isom_write_avcc 在h265时替换为 ff_isom_write_hvcc
// ff_isom_write_avcc(pb, extradata, extrasize);
if (codec == AV_CODEC_ID_HEVC) {
ff_isom_write_hvcc(pb, extradata, extrasize, 1); //hvcc isom is different from avcc'
} else {
ff_isom_write_avcc(pb, extradata, extrasize);
}
3.3 导入hevc.h文件
加入ff_isom_write_hvcc 方法会报错,原因是需要导入hevc.h文件,而hevc.h文件在libavformat 中没暴露出来。下面介绍如何解决:
3.3.1 打开 ijkplayer-ios/extra/ffmpeg/libavformat/Makefile文件" HEADERS = " 加入"hevc.h \ " “OBJS =” 中加入"hevc.o \ "
HEADERS = avformat.h \
.......
hevc.h \
OBJS = allformats.o \
.......
hevc.o \
3.3.2 打开 /ijkplayer-ios/ios/ffmpeg-arm64/libavformat/Makefile 同3.3.1 步骤 HEADERS = " 加入hevc.h \ “OBJS =” 中加入hevc.o \
3.3.3 重新编译ijk
cd iOS
./compile-ffmpeg.sh clean
./compile-ffmpeg.sh all