Issue
I am trying to compile FFMPEG to work with my Android app. I've looked at: https://github.com/halfninja/android-ffmpeg-x264 which is almost what I want but I need a later version of FFMPEG (so I'm trying to use the latest, 2.2).
I'm using most of the scripts located there, but the problem is after I run compile_make_everything.sh, I try to run ndk-build but I get errors (basically it can't find the main function in ffmpeg.c).
This is my Android.mk:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
#LOCAL_ALLOW_UNDEFINED_SYMBOLS := true
LOCAL_MODULE := videokit
LOCAL_SRC_FILES := videokit/com_myapp_example_FFMpegService.c
LOCAL_LDLIBS := -llog -ljnigraphics -lz -landroid
LOCAL_STATIC_LIBRARIES :=ffmpeg
include $(BUILD_SHARED_LIBRARY)
$(call import-module,ffmpeg-2.0.1/android/arm)
If I modify my LOCAL_SRC_FILES to include ffmpeg.c, it fails when I tries to find some of the helper libraries it requires: LOCAL_SRC_FILES := videokit/com_myapp_example_FFMpegService.c ffmpeg/ffmpeg.c ffmpeg/cmdutils.c
The error:
In file included from /home/me/ffmpeg/new-android-ffmpeg/Project/jni/ffmpeg/ffmpeg.c:44:0: /home/me/ffmpeg/new-android-ffmpeg/Project/jni/ffmpeg/libavformat/avformat.h:255:32: fatal error: libavcodec/avcodec.h: No such file or directory compilation terminated.
How can I include the latest ffmpeg library while still being able to call the main function?
Solution
Adding LOCAL_C_INCLUDES += $(LOCAL_PATH)/ffmpeg will probably help a fair bit.
However, you're gonna have more trouble. Basically the ffmpeg.c in the videokit directory is a copy of the original one in the ffmpeg sources, but it's been modified a little to not terminate and to clean up for repeated use, as well as to use the android logging functions. When you build the videokit library, instead of linking in the ffmpeg/ffmpeg.c, you're linking the modified one, videokit/ffmpeg.c.
The problem you're facing is that you've updated all the sources in the ffmpeg directory (and all the libav* libraries under it), but you're still trying to link that old videokit/ffmpeg.c from 0.x against those new 2.x sources. As you can imagine, it's changed a bit.
I would suggest you diff videokit/ffmpeg.c against ffmpeg/ffmpeg.c while you have the old ffmpeg version checked out, and see what was altered. Then you need to copy the new ffmpeg.c out to the videokit directory and perform equivalent changes. The logging stuff is simple, cleaning up for repeated use instead of terminating... that one will be a bit more work. Things have moved around a fair bit.
Oh and you'll also need to copy cmdutils.c, ffmpeg_opt.c, and ffmpeg_filter.c from the new sources into videokit, and to include those in your makefile. They may need alterations too.
Answered By - themightyjon
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.