rockcarry / fanplayer

A portable video player based on ffmpeg for windows and android platform.
GNU Lesser General Public License v3.0
616 stars 163 forks source link

build fanplayer for arm64-v8a #30

Closed MohammedElladaa closed 3 years ago

MohammedElladaa commented 4 years ago

Thanks man for great job.

can you give me a hint about compile fanplayer.so for arm64, I am a beginner in native but I try my hard to learn things ! I build ffmpeg from your script to arm64 after a hundred times>>> I think it's ok - can you correct me->>> BUILD FILE

!/bin/bash

set -e

PREFIX_DIR=$PWD/ffmpeg-android-sdk SYSROOT=$NDK_HOME/platforms/android-21/arch-arm64/ CROSS_COMPILE=$NDK_HOME/toolchains/aarch64-linux-android-4.9/prebuilt/darwin-x86_64/bin/aarch64-linux-android- EXTRA_CFLAGS="-I$PREFIX_DIR/include -DANDROID -DNDEBUG -Os -ffast-math -O3 -march=armv8-a" EXTRA_LDFLAGS="-L$PREFIX_DIR/lib/"

++ build ffmpeg ++

if [ ! -d ffmpeg ]; then git clone -b fanplayer-n3.3.x https://github.com/rockcarry/ffmpeg fi cd ffmpeg ./configure \ --pkg-config=pkg-config \ --arch=arm64 \ --cpu=armv8-a \ --target-os=android \ --disable-runtime-cpudetect \ --enable-cross-compile \ --cross-prefix=$CROSS_COMPILE \ --sysroot=$SYSROOT \ --prefix=$PREFIX_DIR/armv8-a \ --enable-thumb \ --enable-static \ --enable-small \ --disable-shared \ --disable-symver \ --disable-debug \ --disable-programs \ --disable-doc \ --disable-postproc \ --disable-encoders \ --disable-muxers \ --disable-filters \ --disable-swscale-alpha \ --enable-encoder=mjpeg \ --enable-encoder=apng \ --enable-encoder=aac \ --enable-muxer=mjpeg \ --enable-muxer=apng \ --enable-muxer=mp4 \ --enable-muxer=flv \ --enable-muxer=avi \ --enable-filter=yadif \ --enable-filter=rotate \ --enable-asm \ --enable-gpl \ --enable-version3 \ --enable-nonfree \ --enable-jni \ --enable-mediacodec \ --enable-decoder=h264_mediacodec \ --enable-decoder=hevc_mediacodec \ --enable-decoder=mpeg2_mediacodec \ --enable-decoder=mpeg4_mediacodec \ --enable-decoder=vp8_mediacodec \ --enable-decoder=vp9_mediacodec \ --extra-cflags="$EXTRA_CFLAGS" \ --extra-ldflags="$EXTRA_LDFLAGS" make -j8 && make install cd -

++ build ffmpeg ++

echo done


And then try to build fanplayer just i change application.mk file ---> APP_ABI := arm64-v8a and build but error appear /ffmpeg/lib/libavformat.a: error adding symbols: File in wrong format collect2: error: ld returned 1 exit status

***Full buidl log building fanplayer jni library using ndk...

[arm64-v8a] Compile : fanplayer_jni <= ffplayer.c /Users/BlackBird/f/pa/jni/../../src/ffplayer.c: In function 'init_stream': /Users/BlackBird/f/pa/jni/../../src/ffplayer.c:227:9: warning: 'codec' is deprecated (declared at /Users/BlackBird/f/pa/jni/../ffmpeg/include/libavformat/avformat.h:893) [-Wdeprecated-declarations] if (player->avformat_context->streams[i]->codec->codec_type == type) { ^ /Users/BlackBird/f/pa/jni/../../src/ffplayer.c:236:9: warning: 'codec' is deprecated (declared at /Users/BlackBird/f/pa/jni/../ffmpeg/include/libavformat/avformat.h:893) [-Wdeprecated-declarations] player->acodec_context = player->avformat_context->streams[idx]->codec; ^ /Users/BlackBird/f/pa/jni/../../src/ffplayer.c:250:9: warning: 'codec' is deprecated (declared at /Users/BlackBird/f/pa/jni/../ffmpeg/include/libavformat/avformat.h:893) [-Wdeprecated-declarations] player->vcodec_context = player->avformat_context->streams[idx]->codec; ^ /Users/BlackBird/f/pa/jni/../../src/ffplayer.c: In function 'get_stream_total': /Users/BlackBird/f/pa/jni/../../src/ffplayer.c:308:9: warning: 'codec' is deprecated (declared at /Users/BlackBird/f/pa/jni/../ffmpeg/include/libavformat/avformat.h:893) [-Wdeprecated-declarations] if (player->avformat_context->streams[i]->codec->codec_type == type) { ^ /Users/BlackBird/f/pa/jni/../../src/ffplayer.c: In function 'audio_decode_thread_proc': /Users/BlackBird/f/pa/jni/../../src/ffplayer.c:641:13: warning: 'avcodec_decode_audio4' is deprecated (declared at /Users/BlackBird/f/pa/jni/../ffmpeg/include/libavcodec/avcodec.h:4852) [-Wdeprecated-declarations] consumed = avcodec_decode_audio4(player->acodec_context, &player->aframe, &gotaudio, packet); ^ /Users/BlackBird/f/pa/jni/../../src/ffplayer.c: In function 'video_decode_thread_proc': /Users/BlackBird/f/pa/jni/../../src/ffplayer.c:714:13: warning: 'avcodec_decode_video2' is deprecated (declared at /Users/BlackBird/f/pa/jni/../ffmpeg/include/libavcodec/avcodec.h:4901) [-Wdeprecated-declarations] consumed = avcodec_decode_video2(player->vcodec_context, &player->vframe, &gotvideo, packet); ^ [arm64-v8a] Compile : fanplayer_jni <= ffrender.c [arm64-v8a] Compile : fanplayer_jni <= pktqueue.c [arm64-v8a] Compile : fanplayer_jni <= snapshot.c /Users/BlackBird/f/pa/jni/../../src/snapshot.c: In function 'take_snapshot': /Users/BlackBird/f/pa/jni/../../src/snapshot.c:78:5: warning: 'codec' is deprecated (declared at /Users/BlackBird/f/pa/jni/../ffmpeg/include/libavformat/avformat.h:893) [-Wdeprecated-declarations] codec_ctxt = stream->codec; ^ /Users/BlackBird/f/pa/jni/../../src/snapshot.c:99:9: warning: 'avcodec_encode_video2' is deprecated (declared at /Users/BlackBird/f/pa/jni/../ffmpeg/include/libavcodec/avcodec.h:5416) [-Wdeprecated-declarations] if (avcodec_encode_video2(codec_ctxt, &packet, &picture, &got) < 0) { ^ [arm64-v8a] Compile : fanplayer_jni <= recorder.c /Users/BlackBird/f/pa/jni/../../src/recorder.c: In function 'recorder_init': /Users/BlackBird/f/pa/jni/../../src/recorder.c:40:9: warning: 'codec' is deprecated (declared at /Users/BlackBird/f/pa/jni/../ffmpeg/include/libavformat/avformat.h:893) [-Wdeprecated-declarations] AVStream *os = avformat_new_stream(recorder->ofc, is->codec->codec); ^ /Users/BlackBird/f/pa/jni/../../src/recorder.c:46:9: warning: 'avcodec_copy_context' is deprecated (declared at /Users/BlackBird/f/pa/jni/../ffmpeg/include/libavcodec/avcodec.h:4326) [-Wdeprecated-declarations] ret = avcodec_copy_context(os->codec, is->codec); ^ /Users/BlackBird/f/pa/jni/../../src/recorder.c:46:9: warning: 'codec' is deprecated (declared at /Users/BlackBird/f/pa/jni/../ffmpeg/include/libavformat/avformat.h:893) [-Wdeprecated-declarations] /Users/BlackBird/f/pa/jni/../../src/recorder.c:46:9: warning: 'codec' is deprecated (declared at /Users/BlackBird/f/pa/jni/../ffmpeg/include/libavformat/avformat.h:893) [-Wdeprecated-declarations] /Users/BlackBird/f/pa/jni/../../src/recorder.c:52:9: warning: 'codec' is deprecated (declared at /Users/BlackBird/f/pa/jni/../ffmpeg/include/libavformat/avformat.h:893) [-Wdeprecated-declarations] os->codec->codec_tag = 0; ^ /Users/BlackBird/f/pa/jni/../../src/recorder.c:54:13: warning: 'codec' is deprecated (declared at /Users/BlackBird/f/pa/jni/../ffmpeg/include/libavformat/avformat.h:893) [-Wdeprecated-declarations] os->codec->flags |= AV_CODEC_FLAG_GLOBAL_HEADER; ^ [arm64-v8a] Compile : fanplayer_jni <= adev-cmn.c [arm64-v8a] Compile : fanplayer_jni <= vdev-cmn.c [arm64-v8a] Compile++ : fanplayer_jni <= adev-android.cpp [arm64-v8a] Compile++ : fanplayer_jni <= vdev-android.cpp [arm64-v8a] Compile++ : fanplayer_jni <= fanplayer_jni.cpp [arm64-v8a] SharedLibrary : libfanplayer_jni.so /Users/BlackBird/f/pa/jni/../ffmpeg/lib/libavformat.a: error adding symbols: File in wrong format collect2: error: ld returned 1 exit status make: *** [/Users/BlackBird/f/pa/obj/local/arm64-v8a/libfanplayer_jni.so] Error 1

pvnsaravana2 commented 3 years ago

Hi MohammedElladaa , i am also facing the same issues ..Is there any solution for this @MohammedElladaa ..

@rockcarry ,Help to fix this issues

rockcarry commented 3 years ago

from the log, the ffmpeg library compile may not using the correct arch arm64-v8a. you can use file command to check the file format. if the format it wrong, focus on how to build ffmpeg for arm64.

pvnsaravana2 commented 3 years ago

Hi , Thanks for the reply ... @rockcarry , Is there any chance to provide .a static library for ffmpeg in all android ABI (armeabi-v7a,arm64-v8a,x86,x86_64) @MohammedElladaa

rockcarry commented 3 years ago

in lastest version v1.9.0, I write a script to buld android jni, it support for arm, arm64, x86 and x86_64. I've tested arm and arm64, works fine. x86 and x86-64 build ok, but I don't have enviroment to do test.