ffmpeg

435 views
Skip to first unread message

Abhi

unread,
May 25, 2010, 2:37:54 PM5/25/10
to android-ndk
has anybody been able to successfully compile and run ffmpeg on
android using the NDK? I have been trying to figure out without any
luck yet. Any help would be appreciated

THanks,

ABhi

--
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.

Eugene Mymrin

unread,
May 26, 2010, 3:15:28 AM5/26/10
to andro...@googlegroups.com

eugene

unread,
May 26, 2010, 9:06:04 PM5/26/10
to android-ndk
Hi Eugene
That version has the following written below the "ffmpeg-android"
title:
"This is for use with Android source tree, not NDK."

I haven't tried it, but it does seems to indicate that it's not for
NDK...
Have you gotten this to work?

Does anybody know how to build ffmpeg for use in the NDK?
If so, and if you could be so kind, could you please tell us any tips
for building it, or how you did it, or where you got the information
from?

Thanks and kind regards
Eugene


On May 26, 5:15 pm, Eugene Mymrin <emym...@gmail.com> wrote:
> http://gitorious.org/~olvaffe/ffmpeg/ffmpeg-android
>

Eugene Mymrin

unread,
May 27, 2010, 5:03:38 AM5/27/10
to andro...@googlegroups.com
Hi,

When I've spotted this android-ffmpeg project for the first time there
was no "This is for use with Android source tree, not NDK" statement.
Or I haven't noticed it.
Source tree seems to be in the same state as 6 months ago.
Just try it, it should compile fine.
The only thing it lacks is application.mk.
FFmpeg snapshot used in this project is rather old, consider merging
it with latest FFmpeg sources (only from my experience this may be
challenging).

Eugene

Abhi

unread,
Jun 7, 2010, 10:02:09 AM6/7/10
to android-ndk
eugene,

The link you sent works only with android-ndk 1.5. Is there any latest
ffmpeg installation instruction set for the newest ndk release?

THanks

ABhi

On May 27, 5:03 am, Eugene Mymrin <emym...@gmail.com> wrote:
> Hi,
>
> When I've spotted this android-ffmpeg project for the first time there
> was no "This is for use with Android source tree, not NDK" statement.
> Or I haven't noticed it.
> Source tree seems to be in the same state as 6 months ago.
> Just try it, it should compile fine.
> The only thing it lacks is application.mk.
> FFmpeg snapshot used in this project is rather old, consider merging
> it with latest FFmpeg sources (only from my experience this may be
> challenging).
>
> Eugene
>

Eugene Mymrin

unread,
Jun 9, 2010, 7:34:01 AM6/9/10
to andro...@googlegroups.com
Not that I know of.
It should be relatively easy to patch this project so that it works
with ndk-build (create your own android.mk, add entries for libavutil,
libavcodec and libavformat libraries ...)

selmixxx

unread,
Jun 10, 2010, 6:43:17 PM6/10/10
to android-ndk
i just started with ffmpeg from scratch - download ffmpeg from git,
configure it, build libavformat,libavcodec and libavutil to static
libraries using ordinary make and then use ndk tools to compile my
code which links with static libraries of ffmpeg.

however i am ndk beginner so its possible that i am doing everything
the wrong way. result is that it mostly works, but sometimes i get
crashes in emulator which i can't solve for now (program works, then
it somehow breaks... it seems to besomething random or what...). when
i will find what exactly is wrong i may post some exact instructions
here

Abhi

unread,
Jun 14, 2010, 10:43:56 AM6/14/10
to android-ndk
Eugene,

Things that you suggested are out of my scope right now. I am still in
infancy in terms of developing Native applications using NDK. But my
project right now deals with ffmpeg and so taking a leap considering
the time limitations.

Any well-defined instruction set would help. Thanks a lot.

Abhi

On Jun 10, 6:43 pm, selmixxx <miso.sel...@gmail.com> wrote:
> i just started withffmpegfrom scratch - downloadffmpegfrom git,
> configure it, build libavformat,libavcodec and libavutil to static
> libraries using ordinary make and then use ndk tools to compile my
> code which links with static libraries offfmpeg.
>
> however i am ndk beginner so its possible that i am doing everything
> the wrong way. result is that it mostly works, but sometimes i get
> crashes in emulator which i can't solve for now (program works, then
> it somehow breaks... it seems to besomething random or what...). when
> i will find what exactly is wrong i may post some exact instructions
> here
>
> On May 25, 8:37 pm, Abhi <abhishek.r.sha...@gmail.com> wrote:
>
> > has anybody been able to successfully compile and runffmpegon
> >androidusing the NDK? I have been trying to figure out without any
> > luck yet. Any help would be appreciated
>
> > THanks,
>
> > ABhi
>
> > --
> > You received this message because you are subscribed to the Google Groups "android-ndk" group.
> > To post to this group, send email toandr...@googlegroups.com.
> > To unsubscribe from this group, send email toandroid-nd...@googlegroups.com.

selmixxx

unread,
Jun 14, 2010, 5:28:14 PM6/14/10
to android-ndk
here is what i do (its seriously inspired by http://gitorious.org/~olvaffe/ffmpeg/ffmpeg-android
but i wasn't able to make it work for me so i started from beginning)

1) get ffmpeg from git

#!/bin/bash
git clone git://git.ffmpeg.org/ffmpeg/
pushd ffmpeg
git clone git://git.ffmpeg.org/libswscale/
popd

2) configure it - check options and paths and suit them according to
your needs. note thet you may use for example --disable-demuxers --
enable-demuxer-mp3 etc. to have support only to important formats,
also for codecs, devices.... + disable everything what cannot cleanly
compile and you don't need it.
options to --extra-cflags and --extra-ldflags are taken from how ndk-
build invokes compiler, some from various web sources, experiment as
you wish


#!/bin/bash
pushd ffmpeg

make distclean

PREBUILT=$HOME/Documents/SDK/android-ndk/build/prebuilt/linux-x86/arm-
eabi-4.4.0
PREBUILTLIB=$PREBUILT/lib/gcc/arm-eabi/4.4.0
PLATFORM=$HOME/Documents/SDK/android-ndk/build/platforms/android-8/
arch-arm
PREFIX=`pwd`
./configure --target-os=linux \
--arch=armv5te \
--enable-cross-compile \
--cc=$PREBUILT/bin/arm-eabi-gcc \
--cross-prefix=$PREBUILT/bin/arm-eabi- \
--nm=$PREBUILT/bin/arm-eabi-nm \
--extra-cflags="-fpic -DANDROID -I$PLATFORM/usr/include -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_A
RCH_5TE__ -march=armv5te -mtune=xscale -msoft-float -Os -fomit-frame-
pointer -fno-strict-aliasing -finline-limit=64 -Wa,--noexecstack" \
--prefix=$PREFIX \
--extra-ldflags="-Wl,-T,$PREBUILT/arm-eabi/lib/ldscripts/armelf.x -Wl,-
rpath-link=$PLATFORM/usr/lib -L$PLATFORM/usr/lib -nostdlib -
nodefaultlibs $PREBUILTLIB/crtbegin.o $PREBUILTLIB/crtend.o -lgcc -lc -
lm" \
--enable-static
\
--disable-shared
\
--disable-ffmpeg
\
--disable-ffplay \
--disable-ffprobe \
--disable-ffserver \
--disable-debug \
--enable-small \
--enable-pic
popd

3) build ffmpeg

#!/bin/bash
pushd ffmpeg
make -j 2 TARGET_ARCH=arm APP=ffmpeg-org
popd

4) now you can use libraries (.a) and headers in your ndk project. or
symlink. or use longer paths in your includes and options. its up to
you

---

this works, and my program succesfully runs most of the time, however
sometimes i get strange errors (i am using only emulator right now so
i can't confirm on real device), see this thread:
http://groups.google.com/group/android-ndk/browse_frm/thread/cbc280a4d4c68057

i don't know if its caused by wrong choice of options when invoking
gcc, or if its problem of ffmpeg, or emulator... if you will have some
problems and you will find solution please post it here. we should
share information to have better progress

good luck

Yadnesh

unread,
Jun 25, 2010, 2:47:00 AM6/25/10
to android-ndk
Hi,

I have followed similar process and have the ffmpeg static libraries
built for use with Android. The problem is that I am not able to use
these in the executable that I am building using Android NDK.

For the sample executable that I am trying to build I use following
Android.mk
=========================================================
LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
LOCAL_ARM_MODE := arm
LOCAL_MODULE := tutorial1
LOCAL_SRC_FILES := tutorial1.c
LOCAL_CFLAGS := -Lout/apps/ffmpeg-android/armeabi
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../android_ffmpeg06/ffmpeg-0.6
LOCAL_LDLIBS := -Lbuild/platforms/android-5/arch-arm/usr/lib -llog -
lz
LOCAL_STATIC_LIBRARIES := avformat avutil avcodec postproc swscale
include $(BUILD_EXECUTABLE)
=========================================================

command: make -j 2 TARGET_ARCH=arm APP=tutorial
gives error no rule to make target .... --> it expects rule to make
the ffmpeg static libraries

So I added (after google search) following line to end of my
Android.mk
include $(LOCAL_PATH)/../../../android_ffmpeg06/ffmpeg-0.6/Android.mk


Now command: make -j 2 TARGET_ARCH=arm APP=tutorial
works well and compiles again all the ffmpeg static libraries and
proceeds to create the "tutorial" executable. In this I get linker
error "undefined symbol"

All these functions (causing error undefined symbol) are in libavcodec/
arm

on investigation I found that source in libavcodec is getting compiled
but there is no attempt to compile code from libavcodec/arm

Is having this code built necessary or I just comment out statements
responsible for the error?
If building code in libavcodec/arm (I think it is must to build this)
is MUST, could anyone give pointers about getting the Makefile right?

I have attempted listing the libavcodec/arm/*.c files in
"LOCAL_SRC_FILES :=" But I end up getting multiple errors like
=========================================================
/tmp/ccopFvxf.s:94: Error: selected processor does not support `wldrd
wr2,[r2]'
=========================================================

Any idea how this could be resolved?

Regards,
Yadnesh


On Jun 15, 2:28 am, selmixxx <miso.sel...@gmail.com> wrote:
> here is what i do (its seriously inspired byhttp://gitorious.org/~olvaffe/ffmpeg/ffmpeg-android
> but i wasn't able to make it work for me so i started from beginning)
>
> 1) getffmpegfrom git
> i can't confirm on real device), see this thread:http://groups.google.com/group/android-ndk/browse_frm/thread/cbc280a4...
>
> i don't know if its caused by wrong choice of options when invoking
> gcc, or if its problem offfmpeg, or emulator... if you will have some
> problems and you will find solution please post it here. we should
> share information to have better progress
>
> good luck
>
> On Jun 14, 4:43 pm, Abhi <abhishek.r.sha...@gmail.com> wrote:
>
> > Eugene,
>
> > Things that you suggested are out of my scope right now. I am still in
> > infancy in terms of developing Native applications using NDK. But my
> > project right now deals withffmpegand so taking a leap considering
> > the time limitations.
>
> > Any well-defined instruction set would help. Thanks a lot.
>
> > Abhi
>
> > On Jun 10, 6:43 pm, selmixxx <miso.sel...@gmail.com> wrote:
>
> > > i just started withffmpegfrom scratch - downloadffmpegfrom git,
> > > configure it, build libavformat,libavcodec and libavutil to static
> > > libraries using ordinary make and then use ndk tools to compile my
> > > code which links with static libraries offfmpeg.
>
> > > however i am ndk beginner so its possible that i am doing everything
> > > the wrong way. result is that it mostly works, but sometimes i get
> > > crashes in emulator which i can't solve for now (program works, then
> > > it somehow breaks... it seems to besomething random or what...). when
> > > i will find what exactly is wrong i may post some exact instructions
> > > here
>
> > > On May 25, 8:37 pm, Abhi <abhishek.r.sha...@gmail.com> wrote:
>
> > > > has anybody been able to successfully compile and runffmpegon
> > > >androidusing the NDK? I have been trying to figure out without any
> > > > luck yet. Any help would be appreciated
>
> > > > THanks,
>
> > > > ABhi
>
> > > > --
> > > > You received this message because you are subscribed to the Google Groups "android-ndk" group.> > > To post to this group, send emailtoan...@googlegroups.com.> > > To unsubscribe from this group, send emailtoandroid-...@googlegroups.com.

selmixxx

unread,
Jul 2, 2010, 9:06:38 AM7/2/10
to android-ndk
i don't use LOCAL_STATIC_LIBRARIES, instead i use
LOCAL_LDLIBS += -L$(LOCAL_PATH)/ffmpeg/libavcodec -L$(LOCAL_PATH)/
ffmpeg/libavformat -L$(LOCAL_PATH)/ffmpeg/libavutil
LOCAL_LDLIBS += -lavformat -lavcodec -lavutil -lgcc -lm -lz

this works, but i guess its very ugly and it violates everything about
what is new build system about, but i am not able to write .mk files
which would work... (especially when ffmpeg is configure based and i
want it configurable without manual changes to .mk files)

when i will have time (or something elese will force me) i will try to
make it work with ndk as ndk people wanted. for now i will live with
what i have. if someone has better way please let me know

Reply all
Reply to author
Forward
0 new messages