FFmpeg using with NDK

4,827 views
Skip to first unread message

baris atbas

unread,
Dec 30, 2010, 10:49:28 AM12/30/10
to android-ndk, baris...@gmail.com
Hi everyone,

I have a little knowledege about android ndk. In my application, I
will use FFmpeg library.

I am able to configure FFmpeg library and create the libffmpeg.so by
the following link :

http://androidcore.com/android-programming-tutorials/641-how-to-compile-ffmpeg-on-android.html?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed:+android_core+(Android+Tutorials)&utm_content=FaceBook

In my jni folder, I have ffmpeg library , Android.mk , FFmpegTest.c .

I made some changes in Android.mk after some research about ndk. but I
couldnt compile the test code with ndk. I think Android.mk file is
wrong. here is my android.mk

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)

LOCAL_MODULE := ffmpg
LOCAL_SRC_FILES := ffmpegTest.c
LOCAL_LDLIBS := -libffmpeg
include $(BUILD_SHARED_LIBRARY)

I will be so glad, if you give some example codes about android.mk and
ffmpeg. I created the .a and .so files but I couldn't use them. I only
need main Android.mk and test code using ffmpeg library.

alan

unread,
Dec 31, 2010, 4:21:12 AM12/31/10
to android-ndk
"I couldnt compile the test code with ndk" isn't very useful, what is
the exact problem you are having? what error messages are displayed

On Dec 30, 3:49 pm, baris atbas <barisat...@gmail.com> wrote:
> Hi everyone,
>
> I have a little knowledege about android ndk.  In my application, I
> will use FFmpeg library.
>
> I am able to configure FFmpeg library and create the libffmpeg.so  by
> the following link  :
>
> http://androidcore.com/android-programming-tutorials/641-how-to-compi...

baris atbas

unread,
Dec 31, 2010, 4:58:11 AM12/31/10
to android-ndk
baris@ubuntu:~/workspace/FFmpegTest$ /home/baris/ndk/ndk-build
Install : libffmpeg.so => /home/baris/workspace/FFmpegTest/libs/
armeabi
make: *** No rule to make target `/home/baris/workspace/FFmpegTest/jni/
ffmpeg/libswscale/FFmpegTest.c', needed by `/home/baris/workspace/
FFmpegTest/obj/local/armeabi/objs/ffmpg/FFmpegTest.o'. Stop.
baris@ubuntu:~/workspace/FFmpegTest$

it is the error. I think ndk is searching my native code in wrong
place.

LOCAL_PATH := $(call my-dir)
include $(all-subdir-makefiles)
include $(CLEAR_VARS)
LOCAL_MODULE := ffmpg
LOCAL_SRC_FILES := FFmpegTest.c
LOCAL_LDLIBS := -libffmpeg
include $(BUILD_SHARED_LIBRARY)

it is the Android.mk

here is my native code. I found this code in a webpage and configured
according to my project.

#include <ffmpeg/avcodec.h>
#include <ffmpeg/avformat.h>

#include <stdio.h>

void SaveFrame(AVFrame *pFrame, int width, int height, int iFrame) {
FILE *pFile;
char szFilename[32];
int y;

// Open file
sprintf(szFilename, "frame%d.ppm", iFrame);
pFile=fopen(szFilename, "wb");
if(pFile==NULL)
return;

// Write header
fprintf(pFile, "P6\n%d %d\n255\n", width, height);

// Write pixel data
for(y=0; y<height; y++)
fwrite(pFrame->data[0]+y*pFrame->linesize[0], 1, width*3, pFile);

// Close file
fclose(pFile);
}

jint Java_com_test_Test_decodeVideo(JNIEnv* env, jobject
javaThis,jstring filename) {
AVFormatContext *pFormatCtx;
int i, videoStream;
AVCodecContext *pCodecCtx;
AVCodec *pCodec;
AVFrame *pFrame;
AVFrame *pFrameRGB;
AVPacket packet;
int frameFinished;
int numBytes;
uint8_t *buffer;

// Register all formats and codecs
av_register_all();

// Open video file
if(av_open_input_file(&pFormatCtx, filename, NULL, 0, NULL)!=0)
return -1; // Couldn't open file

// Retrieve stream information
if(av_find_stream_info(pFormatCtx)<0)
return -1; // Couldn't find stream information

// Dump information about file onto standard error
dump_format(pFormatCtx, 0, filename, 0);

// Find the first video stream
videoStream=-1;
for(i=0; i<pFormatCtx->nb_streams; i++)
if(pFormatCtx->streams[i]->codec->codec_type==CODEC_TYPE_VIDEO) {
videoStream=i;
break;
}
if(videoStream==-1)
return -1; // Didn't find a video stream

// Get a pointer to the codec context for the video stream
pCodecCtx=pFormatCtx->streams[videoStream]->codec;

// Find the decoder for the video stream
pCodec=avcodec_find_decoder(pCodecCtx->codec_id);
if(pCodec==NULL) {
fprintf(stderr, "Unsupported codec!\n");
return -1; // Codec not found
}
// Open codec
if(avcodec_open(pCodecCtx, pCodec)<0)
return -1; // Could not open codec

// Allocate video frame
pFrame=avcodec_alloc_frame();

// Allocate an AVFrame structure
pFrameRGB=avcodec_alloc_frame();
if(pFrameRGB==NULL)
return -1;

// Determine required buffer size and allocate buffer
numBytes=avpicture_get_size(PIX_FMT_RGB24, pCodecCtx->width,
pCodecCtx->height);
buffer=(uint8_t *)av_malloc(numBytes*sizeof(uint8_t));

// Assign appropriate parts of buffer to image planes in pFrameRGB
// Note that pFrameRGB is an AVFrame, but AVFrame is a superset
// of AVPicture
avpicture_fill((AVPicture *)pFrameRGB, buffer, PIX_FMT_RGB24,
pCodecCtx->width, pCodecCtx->height);

// Read frames and save first five frames to disk
i=0;
while(av_read_frame(pFormatCtx, &packet)>=0) {
// Is this a packet from the video stream?
if(packet.stream_index==videoStream) {
// Decode video frame
avcodec_decode_video(pCodecCtx, pFrame, &frameFinished,
packet.data, packet.size);

// Did we get a video frame?
if(frameFinished) {
// Convert the image from its native format to RGB
img_convert((AVPicture *)pFrameRGB, PIX_FMT_RGB24,
(AVPicture*)pFrame, pCodecCtx->pix_fmt, pCodecCtx-
>width,
pCodecCtx->height);

// Save the frame to phone memory

SaveFrame(pFrameRGB, pCodecCtx->width, pCodecCtx->height, ++i);
}
}

// Free the packet that was allocated by av_read_frame
av_free_packet(&packet);
}

// Free the RGB image
av_free(buffer);
av_free(pFrameRGB);

// Free the YUV frame
av_free(pFrame);

// Close the codec
avcodec_close(pCodecCtx);

// Close the video file
av_close_input_file(pFormatCtx);

return 0;

David Turner

unread,
Dec 31, 2010, 5:17:35 AM12/31/10
to andro...@googlegroups.com
Try putting the include all-subdir-makefiles at the end of your Android.mk, otherwise LOCAL_PATH will be redefined to a different value and your later module declaration will not find the sources in the correct location.

See the description of the my-dir function in docs/ANDROID-MK.html for more details

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.


baris atbas

unread,
Dec 31, 2010, 5:30:39 AM12/31/10
to android-ndk
baris@ubuntu:~/workspace/FFmpegTest$ /home/baris/ndk/ndk-build
make: *** No rule to make target `/FFmpegTest.c', needed by `/home/
baris/workspace/FFmpegTest/obj/local/armeabi/objs/ffmpg/
FFmpegTest.o'. Stop.

I got this error when I put the include all-subdir-makefiles at the
end of my Android.mk ...
> > android-ndk...@googlegroups.com<android-ndk%2Bunsubscribe@googlegr oups.com>
> > .

David Turner

unread,
Dec 31, 2010, 5:48:34 AM12/31/10
to andro...@googlegroups.com
It looks like your LOCAL_PATH is not defined. Did you keep the "LOCAL_PATH := $(call my-dir)" line at the top of your Android.mk ?

To unsubscribe from this group, send email to android-ndk...@googlegroups.com.

baris atbas

unread,
Dec 31, 2010, 5:55:05 AM12/31/10
to android-ndk
yes, I only changed the location of include all subdir files command.

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := ffmpg
LOCAL_SRC_FILES := FFmpegTest.c
LOCAL_LDLIBS := -libffmpeg
include $(BUILD_SHARED_LIBRARY)
include $(all-subdir-makefiles)

David Turner

unread,
Dec 31, 2010, 6:26:27 AM12/31/10
to andro...@googlegroups.com
mmm, can you try a "ndk-build clean" first then try to build again. It might be related to a bad dependency file that was generated on a previous pass.

To unsubscribe from this group, send email to android-ndk...@googlegroups.com.

baris atbas

unread,
Dec 31, 2010, 6:41:30 AM12/31/10
to android-ndk
I got this errors. Files that compiler couldnt find exist in the
ffmpeg folder.


baris@ubuntu:~/workspace/FFmpegTest$ /home/baris/ndk/ndk-build
Compile thumb : ffmpg <= /home/baris/workspace/FFmpegTest/jni/
FFmpegTest.c
In file included from /home/baris/workspace/FFmpegTest/jni/
FFmpegTest.c:1:
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavcodec/avcodec.h:
30:33: error: libavcore/samplefmt.h: No such file or directory
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavcodec/avcodec.h:
31:30: error: libavutil/avutil.h: No such file or directory
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavcodec/avcodec.h:
32:27: error: libavutil/cpu.h: No such file or directory
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavcodec/avcodec.h:
437:36: error: libavcore/audioconvert.h: No such file or directory
In file included from /home/baris/workspace/FFmpegTest/jni/
FFmpegTest.c:1:
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavcodec/avcodec.h:779:
error: expected specifier-qualifier-list before 'int16_t'
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavcodec/avcodec.h:1048:
error: expected specifier-qualifier-list before 'int64_t'
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavcodec/avcodec.h:1102:
error: expected specifier-qualifier-list before 'uint8_t'
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavcodec/avcodec.h:1117:
error: expected ':', ',', ';', '}' or '__attribute__' before '*' token
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavcodec/avcodec.h:2801:
error: field 'type' has incomplete type
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavcodec/avcodec.h:2805:
error: expected declaration specifiers or '...' before 'uint8_t'
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavcodec/avcodec.h:2819:
error: expected ':', ',', ';', '}' or '__attribute__' before '*' token
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavcodec/avcodec.h:2849:
error: field 'type' has incomplete type
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavcodec/avcodec.h:2863:
error: field 'pix_fmt' has incomplete type
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavcodec/avcodec.h:2887:
error: expected ';', ',' or ')' before '*' token
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavcodec/avcodec.h:2900:
error: expected ';' before 'int'
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavcodec/avcodec.h:2928:
error: expected specifier-qualifier-list before 'uint8_t'
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavcodec/avcodec.h:2955:
error: expected '=', ',', ';', 'asm' or '__attribute__' before
'attribute_deprecated'
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavcodec/avcodec.h:3001:
error: expected specifier-qualifier-list before 'uint16_t'
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavcodec/avcodec.h:3014:
error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavcodec/avcodec.h:3078:
error: expected '=', ',', ';', 'asm' or '__attribute__' before
'ReSampleContext'
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavcodec/avcodec.h:3102:
warning: 'enum AVSampleFormat' declared inside parameter list
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavcodec/avcodec.h:3102:
warning: its scope is only this definition or declaration, which is
probably not what you want
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavcodec/avcodec.h:3181:
error: expected declaration specifiers or '...' before 'uint8_t'
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavcodec/avcodec.h:3217:
error: expected '=', ',', ';', 'asm' or '__attribute__' before 'enum'
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavcodec/avcodec.h:3234:
error: expected '=', ',', ';', 'asm' or '__attribute__' before
'av_get_codec_tag_string'
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavcodec/avcodec.h:3285:
error: expected ')' before 'pix_fmt_mask'
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavcodec/avcodec.h:3293:
error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavcodec/avcodec.h:3347:
error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavcodec/avcodec.h:3490:
error: expected '=', ',', ';', 'asm' or '__attribute__' before 'int'
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavcodec/avcodec.h:3544:
error: expected '=', ',', ';', 'asm' or '__attribute__' before 'int'
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavcodec/avcodec.h:3588:
error: expected declaration specifiers or '...' before 'int16_t'
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavcodec/avcodec.h:3606:
error: expected '=', ',', ';', 'asm' or '__attribute__' before 'int'
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavcodec/avcodec.h:3659:
error: expected '=', ',', ';', 'asm' or '__attribute__' before 'int'
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavcodec/avcodec.h:3691:
error: expected declaration specifiers or '...' before 'uint8_t'
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavcodec/avcodec.h:3693:
error: expected declaration specifiers or '...' before 'uint8_t'
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavcodec/avcodec.h:3714:
error: expected declaration specifiers or '...' before 'uint8_t'
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavcodec/avcodec.h:3729:
error: expected declaration specifiers or '...' before 'uint8_t'
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavcodec/avcodec.h:3731:
error: expected declaration specifiers or '...' before 'uint8_t'
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavcodec/avcodec.h:3778:
error: expected '=', ',', ';', 'asm' or '__attribute__' before 'int'
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavcodec/avcodec.h:3785:
error: expected specifier-qualifier-list before 'int64_t'
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavcodec/avcodec.h:3916:
error: expected ';', ',' or ')' before '*' token
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavcodec/avcodec.h:3918:
error: expected ';' before 'void'
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavcodec/avcodec.h:3930:
error: expected '=', ',', ';', 'asm' or '__attribute__' before 'int'
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavcodec/avcodec.h:3967:
error: expected declaration specifiers or '...' before 'uint8_t'
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavcodec/avcodec.h:3968:
error: expected ';', ',' or ')' before '*' token
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavcodec/avcodec.h:3974:
error: expected declaration specifiers or '...' before 'uint8_t'
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavcodec/avcodec.h:3975:
error: expected ';', ',' or ')' before '*' token
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavcodec/avcodec.h:3992:
error: expected declaration specifiers or '...' before 'uint8_t'
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavcodec/avcodec.h:3993:
error: expected ';', ',' or ')' before '*' token
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavcodec/avcodec.h:3994:
error: expected ';' before 'void'
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavcodec/avcodec.h:4002:
error: expected declaration specifiers or '...' before 'uint8_t'
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavcodec/avcodec.h:4003:
error: expected ';', ',' or ')' before '*' token
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavcodec/avcodec.h:4036:
error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavcodec/avcodec.h:4074:
error: expected '=', ',', ';', 'asm' or '__attribute__' before 'int'
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavcodec/avcodec.h:4081:
error: expected '=', ',', ';', 'asm' or '__attribute__' before 'int'
In file included from /home/baris/workspace/FFmpegTest/jni/
FFmpegTest.c:2:
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavformat/avformat.h:
106:32: error: libavcodec/avcodec.h: No such file or directory
In file included from /home/baris/workspace/FFmpegTest/jni/ffmpeg/
libavformat/avformat.h:108,
from /home/baris/workspace/FFmpegTest/jni/
FFmpegTest.c:2:
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavformat/avio.h:33:30:
error: libavutil/common.h: No such file or directory
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavformat/avio.h:34:27:
error: libavutil/log.h: No such file or directory
In file included from /home/baris/workspace/FFmpegTest/jni/ffmpeg/
libavformat/avformat.h:108,
from /home/baris/workspace/FFmpegTest/jni/
FFmpegTest.c:2:
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavformat/avio.h:273:
error: expected ':', ',', ';', '}' or '__attribute__' before '*' token
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavformat/avio.h:293:
error: expected '=', ',', ';', 'asm' or '__attribute__' before 'int'
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavformat/avio.h:298:
error: expected '=', ',', ';', 'asm' or '__attribute__' before 'int'
In file included from /home/baris/workspace/FFmpegTest/jni/
FFmpegTest.c:2:
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavformat/avformat.h:
206: error: expected '=', ',', ';', 'asm' or '__attribute__' before
'int'
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavformat/avformat.h:
225: error: expected '=', ',', ';', 'asm' or '__attribute__' before
'void'
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavformat/avformat.h:
293: error: expected specifier-qualifier-list before 'AVRational'
In file included from /home/baris/workspace/FFmpegTest/jni/
FFmpegTest.c:2:
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavformat/avformat.h:
436: error: expected specifier-qualifier-list before
'attribute_deprecated'
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavformat/avformat.h:
543: error: expected specifier-qualifier-list before 'AVRational'
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavformat/avformat.h:
694: error: expected specifier-qualifier-list before
'attribute_deprecated'
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavformat/avformat.h:
709: error: expected specifier-qualifier-list before 'AVRational'
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavformat/avformat.h:
729: error: expected ':', ',', ';', '}' or '__attribute__' before '*'
token
In file included from /home/baris/workspace/FFmpegTest/jni/
FFmpegTest.c:2:
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavformat/avformat.h:
924: error: expected '=', ',', ';', 'asm' or '__attribute__' before
'extern'
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavformat/avformat.h:
925: error: expected '=', ',', ';', 'asm' or '__attribute__' before
'extern'
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavformat/avformat.h:
951: error: expected '=', ',', ';', 'asm' or '__attribute__' before
'AVOutputFormat'
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavformat/avformat.h:
958: error: expected '=', ',', ';', 'asm' or '__attribute__' before
'AVOutputFormat'
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavformat/avformat.h:
1118: error: expected '=', ',', ';', 'asm' or '__attribute__' before
'AVFormatContext'
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavformat/avformat.h:
1306: error: expected declaration specifiers or '...' before
'AVRational'
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavformat/avformat.h:
1501: error: expected '=', ',', ';', 'asm' or '__attribute__' before
'int'
/home/baris/workspace/FFmpegTest/jni/ffmpeg/libavformat/avformat.h:
1508: error: expected '=', ',', ';', 'asm' or '__attribute__' before
'int'
/home/baris/workspace/FFmpegTest/jni/FFmpegTest.c: In function
'SaveFrame':
/home/baris/workspace/FFmpegTest/jni/FFmpegTest.c:23: error: 'AVFrame'
has no member named 'data'
/home/baris/workspace/FFmpegTest/jni/FFmpegTest.c:23: error: 'AVFrame'
has no member named 'linesize'
/home/baris/workspace/FFmpegTest/jni/FFmpegTest.c: In function
'Java_com_test_Test_decodeVideo':
/home/baris/workspace/FFmpegTest/jni/FFmpegTest.c:57: error:
'AVFormatContext' has no member named 'nb_streams'
/home/baris/workspace/FFmpegTest/jni/FFmpegTest.c:58: error:
'AVFormatContext' has no member named 'streams'
/home/baris/workspace/FFmpegTest/jni/FFmpegTest.c:58: error:
'AVMEDIA_TYPE_VIDEO' undeclared (first use in this function)
/home/baris/workspace/FFmpegTest/jni/FFmpegTest.c:58: error: (Each
undeclared identifier is reported only once
/home/baris/workspace/FFmpegTest/jni/FFmpegTest.c:58: error: for each
function it appears in.)
/home/baris/workspace/FFmpegTest/jni/FFmpegTest.c:66: error:
'AVFormatContext' has no member named 'streams'
/home/baris/workspace/FFmpegTest/jni/FFmpegTest.c:69: error:
'AVCodecContext' has no member named 'codec_id'
/home/baris/workspace/FFmpegTest/jni/FFmpegTest.c:87: error:
'PIX_FMT_RGB24' undeclared (first use in this function)
/home/baris/workspace/FFmpegTest/jni/FFmpegTest.c:87: error:
'AVCodecContext' has no member named 'width'
/home/baris/workspace/FFmpegTest/jni/FFmpegTest.c:88: error:
'AVCodecContext' has no member named 'height'
/home/baris/workspace/FFmpegTest/jni/FFmpegTest.c:88: error: type of
formal parameter 1 is incomplete
/home/baris/workspace/FFmpegTest/jni/FFmpegTest.c:95: error:
'AVCodecContext' has no member named 'width'
/home/baris/workspace/FFmpegTest/jni/FFmpegTest.c:95: error:
'AVCodecContext' has no member named 'height'
/home/baris/workspace/FFmpegTest/jni/FFmpegTest.c:95: error: type of
formal parameter 2 is incomplete
/home/baris/workspace/FFmpegTest/jni/FFmpegTest.c:95: error: too many
arguments to function 'avpicture_fill'
/home/baris/workspace/FFmpegTest/jni/FFmpegTest.c:101: error:
'AVPacket' has no member named 'stream_index'
/home/baris/workspace/FFmpegTest/jni/FFmpegTest.c:104: error:
'AVPacket' has no member named 'data'
/home/baris/workspace/FFmpegTest/jni/FFmpegTest.c:104: error:
'AVPacket' has no member named 'size'
/home/baris/workspace/FFmpegTest/jni/FFmpegTest.c:110: error:
'AVCodecContext' has no member named 'pix_fmt'
/home/baris/workspace/FFmpegTest/jni/FFmpegTest.c:110: error:
'AVCodecContext' has no member named 'width'
/home/baris/workspace/FFmpegTest/jni/FFmpegTest.c:111: error:
'AVCodecContext' has no member named 'height'
/home/baris/workspace/FFmpegTest/jni/FFmpegTest.c:115: error:
'AVCodecContext' has no member named 'width'
/home/baris/workspace/FFmpegTest/jni/FFmpegTest.c:115: error:
'AVCodecContext' has no member named 'height'
make: *** [/home/baris/workspace/FFmpegTest/obj/local/armeabi/objs/
ffmpg/FFmpegTest.o] Error 1
> ...
>
> tamamını oku »

David Turner

unread,
Dec 31, 2010, 6:43:46 AM12/31/10
to andro...@googlegroups.com
By default, source files will be searched under $(LOCAL_PATH), so if you have files elsewhere, you should set LOCAL_C_INCLUDES to point to the corresponding directory.

If these are part of an imported module, consider using LOCAL_EXPORT_C_INCLUDES when declaring the module itself so that other modules that use it have the corresponding paths added to their own LOCAL_C_INCLUDES automatically.

To unsubscribe from this group, send email to android-ndk...@googlegroups.com.

baris atbas

unread,
Dec 31, 2010, 6:56:41 AM12/31/10
to android-ndk
I changed the Android.mk like that :

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := ffmpg
LOCAL_SRC_FILES := FFmpegTest.c
LOCAL_LDLIBS := -libffmpeg
LOCAL_C_INCLUDES := $(LOCAL_PATH)/ffmpeg/
include $(BUILD_SHARED_LIBRARY)
include $(all-subdir-makefiles)

but still there are errors.
baris@ubuntu:~/workspace/FFmpegTest$ /home/baris/ndk/ndk-build
Compile thumb : ffmpg <= /home/baris/workspace/FFmpegTest/jni/
FFmpegTest.c
/home/baris/workspace/FFmpegTest/jni/FFmpegTest.c: In function
'Java_com_test_Test_decodeVideo':
/home/baris/workspace/FFmpegTest/jni/FFmpegTest.c:103: warning:
'avcodec_decode_video' is deprecated (declared at /home/baris/
workspace/FFmpegTest/jni/ffmpeg/libavcodec/avcodec.h:3606)
SharedLibrary : libffmpg.so
/home/baris/ndk/build/prebuilt/linux-x86/arm-eabi-4.4.0/bin/../lib/gcc/
arm-eabi/4.4.0/../../../../arm-eabi/bin/ld: cannot find -libffmpeg
collect2: ld returned 1 exit status
make: *** [/home/baris/workspace/FFmpegTest/obj/local/armeabi/
libffmpg.so] Error 1
> ...
>
> tamamını oku »

Udayakumar Rayala

unread,
Dec 31, 2010, 7:41:08 AM12/31/10
to andro...@googlegroups.com
You would have to specify LOCAL_SHARED_LIBRARIES parameter instead of LOCAL_LDLIBS.

LOCAL_SHARED_LIBRARIES := ffmpeg


Below is an example of Android.mk, i have done in one my projects:

======================================================================
MY_LOCAL_PATH := $(call my-dir)
include $(MY_LOCAL_PATH)/ffmpeg/FFMpeg.mk

LOCAL_PATH :=$(MY_LOCAL_PATH)
include $(CLEAR_VARS)
LOCAL_MODULE    := takepics
LOCAL_SRC_FILES := takepics.c
LOCAL_C_INCLUDES := $(MY_LOCAL_PATH) $(MY_LOCAL_PATH)/ffmpeg
LOCAL_SHARED_LIBRARIES := ffmpeg 
LOCAL_LDLIBS += -lz -llog
include $(BUILD_SHARED_LIBRARY)
======================================================================

- Uday.

> ...
>
> tamamını oku »

baris atbas

unread,
Dec 31, 2010, 10:54:25 AM12/31/10
to android-ndk
I added the local shared lib statement but there are still errors :

baris@ubuntu:~/workspace/FFmpegTest$ /home/baris/ndk/ndk-build
Compile thumb : ffmpg <= /home/baris/workspace/FFmpegTest/jni/
FFmpegTest.c
/home/baris/workspace/FFmpegTest/jni/FFmpegTest.c: In function
'Java_com_test_Test_decodeVideo':
/home/baris/workspace/FFmpegTest/jni/FFmpegTest.c:104: warning:
'avcodec_decode_video' is deprecated (declared at /home/baris/
workspace/FFmpegTest/jni/ffmpeg/libavcodec/avcodec.h:3606)
SharedLibrary : libffmpg.so
/home/baris/workspace/FFmpegTest/obj/local/armeabi/objs/ffmpg/
FFmpegTest.o: In function `Java_com_test_Test_decodeVideo':
/home/baris/workspace/FFmpegTest/jni/FFmpegTest.c:43: undefined
reference to `av_register_all'
/home/baris/workspace/FFmpegTest/jni/FFmpegTest.c:46: undefined
reference to `av_open_input_file'
/home/baris/workspace/FFmpegTest/jni/FFmpegTest.c:50: undefined
reference to `av_find_stream_info'
/home/baris/workspace/FFmpegTest/jni/FFmpegTest.c:54: undefined
reference to `dump_format'
/home/baris/workspace/FFmpegTest/jni/FFmpegTest.c:70: undefined
reference to `avcodec_find_decoder'
/home/baris/workspace/FFmpegTest/jni/FFmpegTest.c:76: undefined
reference to `avcodec_open'
/home/baris/workspace/FFmpegTest/jni/FFmpegTest.c:80: undefined
reference to `avcodec_alloc_frame'
/home/baris/workspace/FFmpegTest/jni/FFmpegTest.c:83: undefined
reference to `avcodec_alloc_frame'
/home/baris/workspace/FFmpegTest/jni/FFmpegTest.c:88: undefined
reference to `avpicture_get_size'
/home/baris/workspace/FFmpegTest/jni/FFmpegTest.c:90: undefined
reference to `av_malloc'
/home/baris/workspace/FFmpegTest/jni/FFmpegTest.c:95: undefined
reference to `avpicture_fill'
/home/baris/workspace/FFmpegTest/jni/FFmpegTest.c:121: undefined
reference to `av_free_packet'
/home/baris/workspace/FFmpegTest/jni/FFmpegTest.c:100: undefined
reference to `av_read_frame'
/home/baris/workspace/FFmpegTest/jni/FFmpegTest.c:125: undefined
reference to `av_free'
/home/baris/workspace/FFmpegTest/jni/FFmpegTest.c:126: undefined
reference to `av_free'
/home/baris/workspace/FFmpegTest/jni/FFmpegTest.c:129: undefined
reference to `av_free'
/home/baris/workspace/FFmpegTest/jni/FFmpegTest.c:132: undefined
reference to `avcodec_close'
/home/baris/workspace/FFmpegTest/jni/FFmpegTest.c:135: undefined
reference to `av_close_input_file'
/home/baris/workspace/FFmpegTest/jni/FFmpegTest.c:104: undefined
reference to `avcodec_decode_video'
/home/baris/workspace/FFmpegTest/jni/FFmpegTest.c:110: undefined
reference to `img_convert'
collect2: ld returned 1 exit status
make: *** [/home/baris/workspace/FFmpegTest/obj/local/armeabi/
libffmpg.so] Error 1


here is my last Android.mk

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
# Here we give our module name and source file(s)
LOCAL_MODULE := ffmpg
LOCAL_SRC_FILES := FFmpegTest.c
LOCAL_SHARED_LIBRARIES := ffmpeg
LOCAL_C_INCLUDES := $(LOCAL_PATH)/ffmpeg/
LOCAL_LDLIBS += -lz -llog
include $(BUILD_SHARED_LIBRARY)
include $(all-subdir-makefiles)


On 31 Aralık, 14:41, Udayakumar Rayala <uday.ray...@gmail.com> wrote:
> You would have to specify LOCAL_SHARED_LIBRARIES parameter instead of
> LOCAL_LDLIBS.
>
> LOCAL_SHARED_LIBRARIES := ffmpeg
>
> Assuming that in the sub directories, you are building a shared library with
> module name ffmpeg (as mentioned inhttp://androidcore.com/android-programming-tutorials/641-how-to-compi...
> ).
> ...
>
> tamamını oku »

Udayakumar Rayala

unread,
Dec 31, 2010, 8:52:46 PM12/31/10
to andro...@googlegroups.com
Try ndk-build with V=1 command line option. This will show the exact command executed to compile.

Most probably, the LOCAL_C_INCLUDES might not have been set properly. That is the reason why i had to create a variable called MY_LOCAL_PATH.

Try the following build file. If this doesnt work post the log file from this command ~/workspace/FFmpegTest$ /home/baris/ndk/ndk-build V=1

> MY_LOCAL_PATH := $(call my-dir)
> LOCAL_PATH :=$(MY_LOCAL_PATH)
include $(CLEAR_VARS)
# Here we give our module name and source file(s)
LOCAL_MODULE    := ffmpg
LOCAL_SRC_FILES := FFmpegTest.c
LOCAL_SHARED_LIBRARIES := ffmpeg
LOCAL_C_INCLUDES := $(MY_LOCAL_PATH)/ffmpeg/
LOCAL_LDLIBS += -lz -llog
include $(BUILD_SHARED_LIBRARY)
include $(all-subdir-makefiles)
> ...
>
> tamamını oku »

baris atbas

unread,
Jan 1, 2011, 3:43:51 AM1/1/11
to android-ndk
I optimized my ffmpeg test code to understand where is the error:

#include <ffmpeg/libavcodec/avcodec.h>
#include <ffmpeg/libavformat/avformat.h>
#include <jni.h>
#include <stdio.h>

jint Java_com_test_Test_decodeVideo(JNIEnv* env, jobject
javaThis,jstring filename) {
AVFormatContext *pFormatCtx;
av_register_all();
if(av_open_input_file(&pFormatCtx, filename, NULL, 0, NULL)!=0)
return -1; // Couldn't open file
return 0;
}

and also change the android.mk according to your comments then ndk-
build V=1 ,it is the log file :

baris@ubuntu:~/workspace/FFmpegTest$ /home/baris/ndk/ndk-build V=1
rm -f /home/baris/workspace/FFmpegTest/libs/armeabi/lib*.so /home/
baris/workspace/FFmpegTest/libs/armeabi-v7a/lib*.so /home/baris/
workspace/FFmpegTest/libs/x86/lib*.so
rm -f /home/baris/workspace/FFmpegTest/libs/armeabi/gdbserver /home/
baris/workspace/FFmpegTest/libs/armeabi-v7a/gdbserver /home/baris/
workspace/FFmpegTest/libs/x86/gdbserver
rm -f /home/baris/workspace/FFmpegTest/libs/armeabi/gdb.setup /home/
baris/workspace/FFmpegTest/libs/armeabi-v7a/gdb.setup /home/baris/
workspace/FFmpegTest/libs/x86/gdb.setup
Compile thumb : ffmpg <= /home/baris/workspace/FFmpegTest/jni/
FFmpegTest.c
/home/baris/ndk/build/prebuilt/linux-x86/arm-eabi-4.4.0/bin/arm-eabi-
gcc -I/home/baris/ndk/build/platforms/android-8/arch-arm/usr/include -
fpic -mthumb-interwork -ffunction-sections -funwind-tables -fstack-
protector -fno-short-enums -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -
D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -Wno-psabi -march=armv5te -
mtune=xscale -msoft-float -mthumb -Os -fomit-frame-pointer -fno-strict-
aliasing -finline-limit=64 -I/home/baris/workspace/FFmpegTest/jni/
ffmpeg/ -I/home/baris/workspace/FFmpegTest/jni -DANDROID -Wa,--
noexecstack -O2 -DNDEBUG -g -c -MMD -MP -MF /home/baris/workspace/
FFmpegTest/obj/local/armeabi/objs/ffmpg/FFmpegTest.o.d /home/baris/
workspace/FFmpegTest/jni/FFmpegTest.c -o /home/baris/workspace/
FFmpegTest/obj/local/armeabi/objs/ffmpg/FFmpegTest.o
SharedLibrary : libffmpg.so
/home/baris/ndk/build/prebuilt/linux-x86/arm-eabi-4.4.0/bin/arm-eabi-
gcc -nostdlib -Wl,-soname,libffmpg.so -Wl,-shared,-Bsymbolic /home/
baris/workspace/FFmpegTest/obj/local/armeabi/objs/ffmpg/FFmpegTest.o -
Wl,--whole-archive -Wl,--no-whole-archive /home/baris/ndk/build/
prebuilt/linux-x86/arm-eabi-4.4.0/bin/../lib/gcc/arm-eabi/4.4.0/
libgcc.a /home/baris/workspace/FFmpegTest/obj/local/armeabi/
libffmpeg.so /home/baris/ndk/build/platforms/android-8/arch-arm/usr/
lib/libc.so /home/baris/ndk/build/platforms/android-8/arch-arm/usr/lib/
libstdc++.so /home/baris/ndk/build/platforms/android-8/arch-arm/usr/
lib/libm.so -Wl,--no-undefined -Wl,-z,noexecstack -L/home/baris/ndk/
build/platforms/android-8/arch-arm/usr/lib -lz -llog -Wl,-rpath-link=/
home/baris/ndk/build/platforms/android-8/arch-arm/usr/lib -o /home/
baris/workspace/FFmpegTest/obj/local/armeabi/libffmpg.so
/home/baris/workspace/FFmpegTest/obj/local/armeabi/objs/ffmpg/
FFmpegTest.o: In function `Java_com_test_Test_decodeVideo':
/home/baris/workspace/FFmpegTest/jni/FFmpegTest.c:17: undefined
reference to `av_register_all'
/home/baris/workspace/FFmpegTest/jni/FFmpegTest.c:19: undefined
reference to `av_open_input_file'
collect2: ld returned 1 exit status
make: *** [/home/baris/workspace/FFmpegTest/obj/local/armeabi/
libffmpg.so] Error 1



On 1 Ocak, 03:52, Udayakumar Rayala <uday.ray...@gmail.com> wrote:
> Try ndk-build with V=1 command line option. This will show the exact command
> executed to compile.
>
> Most probably, the LOCAL_C_INCLUDES might not have been set properly. That
> is the reason why i had to create a variable called MY_LOCAL_PATH.
>
> Try the following build file. If this doesnt work post the log file from
> this command *~/workspace/FFmpegTest$ /home/baris/ndk/ndk-build V=1*
> > > > > > 'attribute_deprecated'...
>
> tamamını oku »

Udayakumar Rayala

unread,
Jan 1, 2011, 5:23:45 AM1/1/11
to andro...@googlegroups.com
I tried modifying my Android.mk file to include $(all-subdir-makefiles) at the end of the file but it didnt work. I had to add it before my module definition. I am surprised it worked for you.

I usually delete obj and libs folders before doing ndk-build or use -B option with ndk-build so that it doesnt use the files from the previous compile. I see from your log output that libffmpeg is not build in this run. Does your Android.mk files look exactly the one which are posted in the previous link?

- Uday,

>
> tamamını oku »

baris atbas

unread,
Jan 1, 2011, 6:05:15 AM1/1/11
to android-ndk
I tried to change my android.mk like yours. and it looks like that :

MY_LOCAL_PATH := $(call my-dir)
include $(MY_LOCAL_PATH)/ffmpeg/Android.mk
LOCAL_PATH := $(MY_LOCAL_PATH)
include $(CLEAR_VARS)
# Here we give our module name and source file(s)
LOCAL_MODULE := ffmpg
LOCAL_SRC_FILES := FFmpegTest.c
LOCAL_SHARED_LIBRARIES := ffmpeg
LOCAL_C_INCLUDES := $(MY_LOCAL_PATH)/ffmpeg/
LOCAL_LDLIBS += -lz -llog
include $(BUILD_SHARED_LIBRARY)

then ndk-build command :

....
Compile thumb : swscale <= utils.c
Compile thumb : swscale <= yuv2rgb.c
StaticLibrary : libswscale.a
SharedLibrary : libffmpeg.so
Install : libffmpeg.so => libs/armeabi/libffmpeg.so
SharedLibrary : libffmpg.so
/home/baris/workspace/FFmpegTest/obj/local/armeabi/objs/ffmpg/
FFmpegTest.o: In function `Java_com_test_Test_decodeVideo':
/home/baris/workspace/FFmpegTest/jni/FFmpegTest.c:17: undefined
reference to `av_register_all'
/home/baris/workspace/FFmpegTest/jni/FFmpegTest.c:19: undefined
reference to `av_open_input_file'
collect2: ld returned 1 exit status
make: *** [/home/baris/workspace/FFmpegTest/obj/local/armeabi/
libffmpg.so] Error 1

same error occured. maybe in native function I dont use ffmpeg
correctly. and last time I post you include all subdir makefiles
command is at the end of the android.mk
> ...
>
> tamamını oku »

baris atbas

unread,
Jan 1, 2011, 4:41:30 PM1/1/11
to android-ndk
Thanks to your useful comments, Problem is solved :)
> > > > > LOCAL_PATH...
>
> tamamını oku »

soulseek

unread,
Jan 5, 2011, 3:35:34 AM1/5/11
to android-ndk
Could you please post your Android.mk file how it looks like now?
Because I have a the same problem and don`t know how to fix it. I
tried out to take your makefile from the post before but I also get
always the "undefined reference" errors.

For further information, I also followed the tutorial from your 1st
post.

My C-file looks like:
========================================================================================
#include <jni.h>
#include <string.h>
#include <stdlib.h>
#include <android/log.h>
#include "libavformat/avformat.h"

void Java_mercedes_ui_Main_helloLog(JNIEnv * env, jobject this,
jstring file)
{
jboolean isCopy;
char * mediaFile = (*env)->GetStringUTFChars(env, file, &isCopy);

AVFormatContext *format_ctx;
av_register_all();
if (av_open_input_file(&format_ctx, mediaFile, NULL, 0, NULL) < 0) {
printf ("Cannot open file %s\n", mediaFile);
exit(1);
}

dump_format(format_ctx, 0, mediaFile, 0);
AVMetadataTag *tag = NULL;
while ((tag=av_metadata_get(format_ctx->metadata, "", tag,
AV_METADATA_IGNORE_SUFFIX)))
__android_log_print(ANDROID_LOG_INFO, tag->key, tag->value);


(*env)->ReleaseStringUTFChars(env, file, mediaFile);
}
========================================================================================
And my Android.mk
========================================================================================
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_C_INCLUDES := $(LOCAL_PATH)/ffmpeg/
LOCAL_LDLIBS := -L /media/Linux/SW_Projekt/AndroidCarStreamer/obj/
local/armeabi -lffmpeg -llog
LOCAL_STATIC_LIBRARIES += avformat avcodec avutil postproc swscale
LOCAL_MODULE := mediaServer
LOCAL_SRC_FILES := idTagReader.c
include $(BUILD_SHARED_LIBRARY)
========================================================================================


Thanks in advance!
> ...
>
> read more »

Udayakumar Rayala

unread,
Jan 5, 2011, 9:21:38 PM1/5/11
to andro...@googlegroups.com
Did you pre-build ffmpeg and using it as a library? If that is the case, then you dont need to specify LOCAL_STATIC_LIBRARIES.

You can follow the below step as a starting point and then modify as you want:

1. Place ffmpeg in jni folder. and follow the steps in How to compile ffmpeg
2. Place idTagReader.c in jni folder outside ffmpeg.
3. Add the following Android.mk file.

MY_LOCAL_PATH := $(call my-dir)
include $(all-subdir-makefiles)
LOCAL_PATH :=$(MY_LOCAL_PATH)
include $(CLEAR_VARS)
LOCAL_MODULE    := mediaServer
LOCAL_SRC_FILES := idTagReader.c
LOCAL_C_INCLUDES := $(MY_LOCAL_PATH) $(MY_LOCAL_PATH)/ffmpeg
LOCAL_SHARED_LIBRARIES := ffmpeg 
LOCAL_LDLIBS += -lz -llog
include $(BUILD_SHARED_LIBRARY)

4. Add the following Application.mk file.

APP_MODULES      := ffmpeg mediaServer

5. Compile with ndk-build. It will generate 2 shared libraries libffmpeg.so and libmediaServer.so.

If you are still getting the errors, post the output of ndk-build with V=1 command line option.

- Uday.


soulseek

unread,
Jan 10, 2011, 4:14:43 AM1/10/11
to android-ndk
Thank very much for your help! But I still get the same error
messages. But I found out that when I download
http://rockplayer.freecoder.org/download/rockplayer_ffmpeg.zip,
extract it into the ffmpeg folder in the jni folder and take your make
files, than everything compiles fin :-) So thanks again!



P.S.: This is my output with errors:

[soulseek@sabayon] ffmpeg $ ndk-build V=1
rm -f /media/Linux/SW_Projekt/AndroidCarStreamer/libs/armeabi/lib*.so /
media/Linux/SW_Projekt/AndroidCarStreamer/libs/armeabi-v7a/lib*.so /
media/Linux/SW_Projekt/AndroidCarStreamer/libs/x86/lib*.so
rm -f /media/Linux/SW_Projekt/AndroidCarStreamer/libs/armeabi/
gdbserver /media/Linux/SW_Projekt/AndroidCarStreamer/libs/armeabi-v7a/
gdbserver /media/Linux/SW_Projekt/AndroidCarStreamer/libs/x86/
gdbserver
rm -f /media/Linux/SW_Projekt/AndroidCarStreamer/libs/armeabi/
gdb.setup /media/Linux/SW_Projekt/AndroidCarStreamer/libs/armeabi-v7a/
gdb.setup /media/Linux/SW_Projekt/AndroidCarStreamer/libs/x86/
gdb.setup
Gdbserver : [arm-linux-androideabi-4.4.3] libs/armeabi/gdbserver
mkdir -p /media/Linux/SW_Projekt/AndroidCarStreamer/libs/armeabi
install -p /media/Linux/SW_Projekt/android_ndk_linux/toolchains/arm-
linux-androideabi-4.4.3/prebuilt/gdbserver /media/Linux/SW_Projekt/
AndroidCarStreamer/libs/armeabi/gdbserver
Gdbsetup : libs/armeabi/gdb.setup
echo "set solib-search-path /media/Linux/SW_Projekt/AndroidCarStreamer/
obj/local/armeabi" > /media/Linux/SW_Projekt/AndroidCarStreamer/libs/
armeabi/gdb.setup
echo "directory /media/Linux/SW_Projekt/android_ndk_linux/platforms/
android-8/arch-arm/usr/include /media/Linux/SW_Projekt/
AndroidCarStreamer/jni/ffmpeg/libavcodec /media/Linux/SW_Projekt/
AndroidCarStreamer/jni/ffmpeg/libavcodec/.. /media/Linux/SW_Projekt/
AndroidCarStreamer/jni/ffmpeg/libavcore /media/Linux/SW_Projekt/
AndroidCarStreamer/jni/ffmpeg/libavcore/.. /media/Linux/SW_Projekt/
AndroidCarStreamer/jni/ffmpeg/libavfilter /media/Linux/SW_Projekt/
AndroidCarStreamer/jni/ffmpeg/libavfilter/.. /media/Linux/SW_Projekt/
AndroidCarStreamer/jni/ffmpeg/libavformat /media/Linux/SW_Projekt/
AndroidCarStreamer/jni/ffmpeg/libavformat/.. /media/Linux/SW_Projekt/
AndroidCarStreamer/jni/ffmpeg/libavutil /media/Linux/SW_Projekt/
AndroidCarStreamer/jni/ffmpeg/libavutil/.. /media/Linux/SW_Projekt/
AndroidCarStreamer/jni/ffmpeg /media/Linux/SW_Projekt/
AndroidCarStreamer/jni /media/Linux/SW_Projekt/AndroidCarStreamer/jni/
ffmpeg/libpostproc /media/Linux/SW_Projekt/AndroidCarStreamer/jni/
ffmpeg/libpostproc/.. /media/Linux/SW_Projekt/android_ndk_linux/
sources/cxx-stl/system" >> /media/Linux/SW_Projekt/AndroidCarStreamer/
libs/armeabi/gdb.setup
Install : libffmpeg.so => libs/armeabi/libffmpeg.so
mkdir -p /media/Linux/SW_Projekt/AndroidCarStreamer/libs/armeabi
install -p /media/Linux/SW_Projekt/AndroidCarStreamer/obj/local/
armeabi/libffmpeg.so /media/Linux/SW_Projekt/AndroidCarStreamer/libs/
armeabi/libffmpeg.so
/media/Linux/SW_Projekt/android_ndk_linux/toolchains/arm-linux-
androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-strip --
strip-unneeded /media/Linux/SW_Projekt/AndroidCarStreamer/libs/
armeabi/libffmpeg.so
SharedLibrary : libmediaServer.so
/media/Linux/SW_Projekt/android_ndk_linux/toolchains/arm-linux-
androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-g++ -
Wl,-soname,libmediaServer.so -shared --sysroot=/media/Linux/SW_Projekt/
android_ndk_linux/platforms/android-8/arch-arm /media/Linux/
SW_Projekt/AndroidCarStreamer/obj/local/armeabi/objs-debug/mediaServer/
idTagReader.o /media/Linux/SW_Projekt/AndroidCarStreamer/obj/local/
armeabi/libffmpeg.so /media/Linux/SW_Projekt/android_ndk_linux/
platforms/android-8/arch-arm/usr/lib/libc.so /media/Linux/SW_Projekt/
android_ndk_linux/platforms/android-8/arch-arm/usr/lib/libstdc++.so /
media/Linux/SW_Projekt/android_ndk_linux/platforms/android-8/arch-arm/
usr/lib/libm.so -Wl,--no-undefined -Wl,-z,noexecstack -L/media/Linux/
SW_Projekt/android_ndk_linux/platforms/android-8/arch-arm/usr/lib -lz -
llog -Wl,-rpath-link=/media/Linux/SW_Projekt/android_ndk_linux/
platforms/android-8/arch-arm/usr/lib -lsupc++ -o /media/Linux/
SW_Projekt/AndroidCarStreamer/obj/local/armeabi/libmediaServer.so
/media/Linux/SW_Projekt/AndroidCarStreamer/obj/local/armeabi/objs-
debug/mediaServer/idTagReader.o: In function
`Java_mercedes_ui_Main_helloLog':
/media/Linux/SW_Projekt/AndroidCarStreamer/jni/idTagReader.c:16:
undefined reference to `av_register_all'
/media/Linux/SW_Projekt/AndroidCarStreamer/jni/idTagReader.c:18:
undefined reference to `av_open_input_file'
/media/Linux/SW_Projekt/AndroidCarStreamer/jni/idTagReader.c:24:
undefined reference to `dump_format'
/media/Linux/SW_Projekt/AndroidCarStreamer/jni/idTagReader.c:27:
undefined reference to `av_metadata_get'
collect2: ld returned 1 exit status
make: *** [/media/Linux/SW_Projekt/AndroidCarStreamer/obj/local/
armeabi/libmediaServer.so] Error 1


On 5 Jan., 21:21, Udayakumar Rayala <uday.ray...@gmail.com> wrote:
> Did you pre-build ffmpeg and using it as a library? If that is the case,
> then you dont need to specify LOCAL_STATIC_LIBRARIES.
>
> You can follow the below step as a starting point and then modify as you
> want:
>
> 1. Place ffmpeg in jni folder. and follow the steps in How to compile
> ffmpeg<http://androidcore.com/android-programming-tutorials/641-how-to-compi...>
> <http://androidcore.com/android-programming-tutorials/641-how-to-compi...>2.
> Place idTagReader.c in jni folder outside ffmpeg.
> 3. Add the following Android.mk file.
>
> MY_LOCAL_PATH := $(call my-dir)
> include $(all-subdir-makefiles)
> LOCAL_PATH :=$(MY_LOCAL_PATH)
> include $(CLEAR_VARS)
> LOCAL_MODULE    := mediaServer
> LOCAL_SRC_FILES := idTagReader.c
> LOCAL_C_INCLUDES := $(MY_LOCAL_PATH) $(MY_LOCAL_PATH)/ffmpeg
> LOCAL_SHARED_LIBRARIES := ffmpeg
> LOCAL_LDLIBS += -lz -llog
> include $(BUILD_SHARED_LIBRARY)
>
> 4. Add the following Application.mk file.
>
> APP_MODULES      := ffmpeg mediaServer
>
> 5. Compile with ndk-build. It will generate 2 shared libraries libffmpeg.so
> and libmediaServer.so.
>
> If you are still getting the errors, post the output of ndk-build with V=1
> command line option.
>
> - Uday.
>
> ...
>
> Erfahren Sie mehr »
Message has been deleted
Message has been deleted

Nikhil Dhavale

unread,
Feb 4, 2011, 6:11:38 AM2/4/11
to android-ndk
I am trying similar type of library usage. But I get following issue.
/cygdrive/e/Android/FFMppegg/jni/Android.mk:3: /cygdrive/e/Android/
FFMppegg/jni/
ffmpeg/Android.mk: No such file or directory
make: *** No rule to make target `/cygdrive/e/Android/FFMppegg/jni/
ffmpeg/Androi
d.mk'. Stop.
Implying something is wrong with Android.mk file. Can you please help.
Nikhil Dhavale
> ...
>
> read more »

soulseek

unread,
Feb 4, 2011, 6:21:43 AM2/4/11
to android-ndk
Can you pleas post your /cygdrive/e/Android/FFMppegg/jni/Android.mk
and `/cygdrive/e/Android/FFMppegg/jni/ffmpeg/Android.mk' files?
and is this file `/cygdrive/e/Android/FFMppegg/jni/ffmpeg/Android.mk'
in the ffmpeg folder? Because I had sometimes this message "No rule to
make target" when the file I wanted to include was missing ;-)
> > > > > > > reference to...
>
> Erfahren Sie mehr »

Udayakumar Rayala

unread,
Feb 4, 2011, 9:05:14 AM2/4/11
to andro...@googlegroups.com
I have attached the Android.mk files. 

jni.zip

soulseek

unread,
Feb 5, 2011, 6:47:56 AM2/5/11
to android-ndk
Could you also upload your ffmpeg folder with all files somewhere
please? Because, I cant replicate your error. I have to delete the
cmdutils.c from the local source files in the jni/ffmpeg/Android.mk
because I have no version.h and when I use my config.sh I get some
other errors (like: error: expected ';', ',' or ')' before 'v1' but I
think it has to do with my config.sh script)

But it starts to compile as you can see:

jni $ ndk-build
Gdbserver : [arm-linux-androideabi-4.4.3] libs/armeabi/gdbserver
Gdbsetup : libs/armeabi/gdb.setup
Compile thumb : ffmpeg <= ffmpeg.c
./jni/ffmpeg/ffmpeg.c: In function 'do_video_out':
./jni/ffmpeg/ffmpeg.c:1085: warning: passing argument 2 of 'sws_scale'
from incompatible pointer type
./jni/ffmpeg/libswscale/swscale.h:195: note: expected 'const uint8_t *
const*' but argument is of type 'uint8_t **'
Compile thumb : avformat <= 4xm.c
Compile thumb : avformat <= adtsenc.c
.
.
.
> ...
>
> Erfahren Sie mehr »
>
>  jni.zip
> 1KAnzeigenHerunterladen

hanrelan

unread,
Feb 6, 2011, 11:45:46 PM2/6/11
to android-ndk
I followed your instructions, and though ffmpeg compiles fine, my C
file doesn't compile.

It errors out because of undefined references to all the ffmpeg
functions.

Here is my Android.mk:
MY_LOCAL_PATH := $(call my-dir)
include $(all-subdir-makefiles)
LOCAL_PATH :=$(MY_LOCAL_PATH)
include $(CLEAR_VARS)
LOCAL_MODULE := videoFrameExtractor
LOCAL_SRC_FILES := videoFrameExtractor.c
LOCAL_C_INCLUDES := $(MY_LOCAL_PATH) $(MY_LOCAL_PATH)/ffmpeg
LOCAL_SHARED_LIBRARIES := ffmpeg
LOCAL_LDLIBS += -lz -llog
include $(BUILD_SHARED_LIBRARY)

And the error messages from ndk-build V=1:

Install : libffmpeg.so => libs/armeabi/libffmpeg.so
...
SharedLibrary : libvideoFrameExtractor.so
/home/rohan/programming/android-ndk-r5b/toolchains/arm-linux-
androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-g++ -
Wl,-soname,libvideoFrameExtractor.so -shared --sysroot=/home/rohan/
programming/android-ndk-r5b/platforms/android-8/arch-arm /home/rohan/
programming/LongitudeVideo/obj/local/armeabi/objs/videoFrameExtractor/
videoFrameExtractor.o /home/rohan/programming/LongitudeVideo/obj/
local/armeabi/libffmpeg.so /home/rohan/programming/android-ndk-r5b/
platforms/android-8/arch-arm/usr/lib/libc.so /home/rohan/programming/
android-ndk-r5b/platforms/android-8/arch-arm/usr/lib/libstdc++.so /
home/rohan/programming/android-ndk-r5b/platforms/android-8/arch-arm/
usr/lib/libm.so -Wl,--no-undefined -Wl,-z,noexecstack -L/home/rohan/
programming/android-ndk-r5b/platforms/android-8/arch-arm/usr/lib -lz -
llog -Wl,-rpath-link=/home/rohan/programming/android-ndk-r5b/platforms/
android-8/arch-arm/usr/lib -lsupc++ -o /home/rohan/programming/
LongitudeVideo/obj/local/armeabi/libvideoFrameExtractor.so
/home/rohan/programming/LongitudeVideo/obj/local/armeabi/objs/
videoFrameExtractor/videoFrameExtractor.o: In function
`initializeVideoDecoder':
/home/rohan/programming/LongitudeVideo/jni/videoFrameExtractor.c:21:
undefined reference to `av_register_all'
/home/rohan/programming/LongitudeVideo/jni/videoFrameExtractor.c:22:
undefined reference to `av_parser_init'
/home/rohan/programming/LongitudeVideo/jni/videoFrameExtractor.c:23:
undefined reference to `avcodec_alloc_frame'
/home/rohan/programming/LongitudeVideo/jni/videoFrameExtractor.c:25:
undefined reference to `avcodec_find_decoder'
/home/rohan/programming/LongitudeVideo/jni/videoFrameExtractor.c:30:
undefined reference to `avcodec_alloc_context'
... etc etc
collect2: ld returned 1 exit status
make: *** [/home/rohan/programming/LongitudeVideo/obj/local/armeabi/
libvideoFrameExtractor.so] Error 1


Any ideas on how to solve the linker problem?

Thanks

On Jan 5, 9:21 pm, Udayakumar Rayala <uday.ray...@gmail.com> wrote:
> Did you pre-build ffmpeg and using it as a library? If that is the case,
> then you dont need to specify LOCAL_STATIC_LIBRARIES.
>
> You can follow the below step as a starting point and then modify as you
> want:
>
> 1. Place ffmpeg in jni folder. and follow the steps in How to compile
> ffmpeg<http://androidcore.com/android-programming-tutorials/641-how-to-compi...>
> <http://androidcore.com/android-programming-tutorials/641-how-to-compi...>2.
> ...
>
> read more »

Udayakumar Rayala

unread,
Feb 7, 2011, 1:39:14 PM2/7/11
to andro...@googlegroups.com
Hi,

Your build file looks fine to me. I am not sure why the linker is not able to find the shared library even though the library location is present in the arguments.

I have checked in my entire jni folder into git hub. Download and compare it with yours.

Currently, i have just added only the jni folder. Planning to soon put a sample application also.


Let me know if that solves the compile problem.

- Uday.

> ...
>
> read more »

hanrelan

unread,
Feb 7, 2011, 7:05:59 PM2/7/11
to android-ndk
Ah thank you. I replaced my ffmpeg folder and my build files with
yours and edited them for my project and it worked fine.
Still don't know why my build wasn't work, but I suspect it's related
to my ffmpeg compile.

Thanks again
> ...
>
> read more »

B U J J I

unread,
Feb 8, 2011, 10:52:49 AM2/8/11
to andro...@googlegroups.com
hi all,
Thanks for the valuable post.
when i am trying to compile ffmpeg (version -6) with ndk-build it works fine.
but i want to put the source in mydroid and compile it.
when  same code is put it into mydroid/external/ its giving  error like below...

external/ffmpeg/libavformat/metadata_compat.c:132: error: the address of 'number' will always evaluate as 'true'
external/ffmpeg/libavformat/metadata_compat.c:133: error: the address of 'number' will always evaluate as 'true'
make: *** [out/target/product/generic/obj/STATIC_LIBRARIES/libavformat_intermediates/metadata_compat.o] Error 1


please help me to compile it with mydroid source code.
what changes i need to do.

Thanks,
Bujji

> ...
>
> read more »

Nikhil Dhavale

unread,
Feb 10, 2011, 5:06:11 AM2/10/11
to android-ndk
Can you direct me where will I get help for building vlc libraries in
Android. Also are there build made which could be downloaded. Help
would be appreciated.
Nikhil Dhavale

On Feb 5, 4:47 pm, soulseek <markus.brou...@gmail.com> wrote:
> Could you also upload yourffmpegfolder with all files somewhere
> please? Because, I cant replicate your error. I have to delete the
> cmdutils.c from the local source files in the jni/ffmpeg/Android.mk
> because I have no version.h and when I use my config.sh I get some
> other errors (like: error: expected ';', ',' or ')' before 'v1' but I
> think it has to do with my config.sh script)
>
> But it starts to compile as you can see:
>
> jni $ ndk-build
> Gdbserver      : [arm-linux-androideabi-4.4.3] libs/armeabi/gdbserver
> Gdbsetup       : libs/armeabi/gdb.setup
> Compile thumb  :ffmpeg<=ffmpeg.c
> ./jni/ffmpeg/ffmpeg.c: In function 'do_video_out':
> ./jni/ffmpeg/ffmpeg.c:1085: warning: passing argument 2 of 'sws_scale'
> from incompatible pointer type
> ./jni/ffmpeg/libswscale/swscale.h:195: note: expected 'const uint8_t *
> const*' but argument is of type 'uint8_t **'
> Compile thumb  : avformat <= 4xm.c
> Compile thumb  : avformat <= adtsenc.c
> .
> .
> .
>
> On 4 Feb., 09:05, Udayakumar Rayala <uday.ray...@gmail.com> wrote:
>
> > I have attached theAndroid.mk files.
>
> > On Fri, Feb 4, 2011 at 4:51 PM, soulseek <markus.brou...@gmail.com> wrote:
> > > Can you pleas post your /cygdrive/e/Android/FFMppegg/jni/Android.mk
> > > and `/cygdrive/e/Android/FFMppegg/jni/ffmpeg/Android.mk' files?
> > > and is this file `/cygdrive/e/Android/FFMppegg/jni/ffmpeg/Android.mk'
> > > in theffmpegfolder? Because I had sometimes this message "No rule to
> > > make target" when the file I wanted to include was missing ;-)
>
> > > On 4 Feb., 12:11, Nikhil Dhavale <nikhildhavale...@gmail.com> wrote:
> > > > I am trying similar type of library usage. But I get following issue.
> > > > /cygdrive/e/Android/FFMppegg/jni/Android.mk:3: /cygdrive/e/Android/
> > > > FFMppegg/jni/
> > > >ffmpeg/Android.mk: No such file or directory
> > > > make: *** No rule to make target `/cygdrive/e/Android/FFMppegg/jni/
> > > >ffmpeg/Androi
> > > > d.mk'.  Stop.
> > > > Implying something is wrong withAndroid.mk file. Can you please help.
> > > > Nikhil Dhavale
>
> > > > On Jan 2, 2:41 am, baris atbas <barisat...@gmail.com> wrote:
>
> > > > > Thanks to your useful comments, Problem is solved :)
>
> > > > > On 1 Ocak, 13:05, baris atbas <barisat...@gmail.com> wrote:
>
> > > > > > I tried to change myandroid.mk like yours. and it looks like that :
> > > > > > > I tried modifying myAndroid.mk file to include
> > > $(all-subdir-makefiles) at
> > > > > > > the end of the file but it didnt work. I had to add it before my
> > > module
> > > > > > > definition. I am surprised it worked for you.
>
> > > > > > > I usually delete obj and libs folders before doing ndk-build or use
> > > -B
> > > > > > > option with ndk-build so that it doesnt use the files from the
> > > previous
> > > > > > > compile. I see from your log output that libffmpeg is not build in
> > > this run.
> > > > > > > Does yourAndroid.mk files look exactly the one which are posted in
> > > the
> > > > > > > previous link?
>
> > > > > > > -Uday,
>
> > > > > > > On Sat, Jan 1, 2011 at 2:13 PM, baris atbas <barisat...@gmail.com>
> > > wrote:
> > > > > > > > I optimized myffmpegtest code to understand where is the error:
>
> > > > > > > > #include <ffmpeg/libavcodec/avcodec.h>
> > > > > > > > #include <ffmpeg/libavformat/avformat.h>
> > > > > > > > #include <jni.h>
> > > > > > > > #include <stdio.h>
>
> > > > > > > > jint Java_com_test_Test_decodeVideo(JNIEnv* env, jobject
> > > > > > > > javaThis,jstring filename) {
> > > > > > > >  AVFormatContext *pFormatCtx;
> > > > > > > >   av_register_all();
> > > > > > > >   if(av_open_input_file(&pFormatCtx, filename, NULL, 0, NULL)!=0)
> > > > > > > >    return -1; // Couldn't open file
> > > > > > > >   return 0;
> > > > > > > > }
>
> > > > > > > > and also change theandroid.mk according to your comments then
> ...
>
> read more »

soulseek

unread,
Feb 17, 2011, 12:39:09 PM2/17/11
to android-ndk
Well if you want to build vlc I dont know how I could help you, or do
you still want to compile ffmpeg and include it to your project?
> ...
>
> Erfahren Sie mehr »

Hyukmin Kwon

unread,
Jun 22, 2012, 7:16:54 AM6/22/12
to andro...@googlegroups.com
On Jun 21, 2012 8:02 PM, "rajesh" <sdip...@gmail.com> wrote:
Hi Uday , 

I am trying to develop the ffmpeg Android app with ndk which should convert the images to video file. please help me to do that. and also can you tel me i can use the above github file to convert the same which i have   asked you above ?? 

Regards ,
Rajesh K . 


On Tuesday, February 8, 2011 12:09:14 AM UTC+5:30, Udayakumar Rayala wrote:
Hi,

Your build file looks fine to me. I am not sure why the linker is not able to find the shared library even though the library location is present in the arguments.

I have checked in my entire jni folder into git hub. Download and compare it with yours.

Currently, i have just added only the jni folder. Planning to soon put a sample application also.


Let me know if that solves the compile problem.

- Uday.


--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/android-ndk/-/0SVDUESR2OUJ.

Narendra Singh Rathore

unread,
Nov 11, 2012, 7:48:09 AM11/11/12
to andro...@googlegroups.com


On Wed, Nov 7, 2012 at 7:36 PM, Angel delusion <angelde...@gmail.com> wrote:
hi,
I am new in android and i am building app which converting Images to video and i am using ffmpeg. i have tired to run ffmpeg.so file with command line but it not works.so any one tell me how i can do this with ffmpeg.


On Thursday, December 30, 2010 9:19:28 PM UTC+5:30, baris atbas wrote:
Hi everyone,

I have a little knowledege about android ndk.  In my application, I
will use FFmpeg library.

 
Hi Angel, try this -
 
 
 
Thanks & Regards,
NSR
Reply all
Reply to author
Forward
0 new messages