ijkplayer库 获取

先去下载源码

git clone https://github.com/Bilibili/ijkplayer.git ijkplayer-ios

cd ijkplayer-ios

git checkout -B latest k0.8.8

./init-ios.sh

cd ios

./compile-ffmpeg.sh clean

./compile-ffmpeg.sh all

下载下来后打开项目报错误

'libavformat/avformat.h' file not found

是因为./compile-ffmpeg.sh all失败

./libavutil/arm/asm.S:50:9: error: unknown directive .arch armv7-a^make: *** [libavcodec/arm/aacpsdsp_neon.o] Error 1


 Xcode 已经弱化了对 32 位的支持

打开compile-ffmpeg.sh中删除armv7, 

FF_ALL_ARCHS_IOS8_SDK="armv7 arm64 i386 x86_64"

修改成:

FF_ALL_ARCHS_IOS8_SDK="arm64 i386 x86_64"

...

再重新执行:

./compile-ffmpeg.sh clean

./compile-ffmpeg.sh all


适配rtsp

config文件夹下的module-lite.sh文件

export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-protocol=rtp"

改为

export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-protocol=rtp"

export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-demuxer=rtsp"


cd /到config

rm module.sh //删除原来的

ln -s module-lite.sh module.sh //用修改过的替换


找到ijkplayer-ios/ijkmedia/ijkplayer/ff_ffplay.c

修改

static int packet_queue_get_or_buffering(FFPlayer *ffp, PacketQueue *q, AVPacket *pkt, int *serial, int *finished)

{

    assert(finished);

    if (!ffp->packet_buffering)

        return packet_queue_get(q, pkt, 1, serial);

    while (1) {

        int new_packet = packet_queue_get(q, pkt, 0, serial);

        if (new_packet < 0)

            return -1;

        else if (new_packet == 0) {

            if (q->is_buffer_indicator && !*finished)

                ffp_toggle_buffering(ffp, 1);

            new_packet = packet_queue_get(q, pkt, 1, serial);

            if (new_packet < 0)

                return -1;

        }

        if (*finished == *serial) {

            av_packet_unref(pkt);

            continue;

        }

        else

            break;

    }

    return 1;

}

static int packet_queue_get_or_buffering(FFPlayer *ffp, PacketQueue *q, AVPacket *pkt, int *serial, int finished){

    while (1) {

        int new_packet = packet_queue_get(q, pkt, 1, serial);

        if (new_packet < 0){

            new_packet = packet_queue_get(q, pkt, 0, serial);

            if(new_packet < 0)

                return -1;

        }else if (new_packet == 0) {

            if (!finished)

                ffp_toggle_buffering(ffp, 1);

            new_packet = packet_queue_get(q, pkt, 1, serial);

            if (new_packet < 0)

                return -1;

        }

        if (finished == *serial) {

            av_free_packet(pkt);

            continue;

        }

        else

            break;

    }

    return 1;

}

然后

./init-ios.sh

cd ios./compile-ffmpeg.sh clean

./compile-ffmpeg.sh all

打开项目,编译真机和模拟器,获得ijk库

 lipo -create 真机地址 模拟器地址 -output 需要打印到的地址

你可能感兴趣的:(ijkplayer库 获取)