Chinaunix首页 | 论坛 | 博客
  • 博客访问: 395521
  • 博文数量: 119
  • 博客积分: 1796
  • 博客等级: 上尉
  • 技术积分: 890
  • 用 户 组: 普通用户
  • 注册时间: 2010-05-14 10:16
个人简介

守正

文章分类
文章存档

2013年(1)

2011年(40)

2010年(78)

分类: 嵌入式

2010-06-03 20:11:07

I spent several days trying to compile ffmpeg on android-ndk1.5. Just want to share to others. Hopefully, it can save you some time.

STEP1:

First, I get the source code from ~olvaffe/ffmpeg/ffmpeg-android. I will need to use its *.mk files.

STEP2:

Get the ffmpeg source code from I used svn, instead of git, so that I won’t need to get libswscale separately.

STEP3:

configure my ffmpeg with following cmd.

#!/bin/sh
PREBUILT=/home/myhome/android-ndk/build/prebuilt/linux-x86/arm-eabi-4.2.1
./configure –target-os=linux \
–arch=armv41 \
–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 ” \
–enable-static \
–disable-shared \
–disable-asm \
–disable-yasm \
–prefix=/home/myhome/work/ffmpeg-android-bin \
–extra-ldflags=”-Wl,-T,$PREBUILT/arm-eabi/lib/ldscripts/armelf.x -Wl,-rpath-link=/home/myhome/android-ndk/build/platforms/android-1.5/arch-arm/usr/lib -L/home/myhome/android-ndk/build/platforms/android-1.5/arch-arm/usr/lib -nostdlib /home/myhome/android-ndk/build/prebuilt/linux-x86/arm-eabi-4.2.1/lib/gcc/arm-eabi/4.2.1/crtbegin.o /home/myhome/android-ndk/build/prebuilt/linux-x86/arm-eabi-4.2.1/lib/gcc/arm-eabi/4.2.1/crtend.o -lc -lm -ldl”

** I referenced this one at http://blog.csdn.net/anakiagmail/archive/2009/08/14/4446986.aspx ** If you don’t understand chinese, I’ll show you what it describe in following steps.

STEP4:

By now, configure should be passed successfully. Copy *.mk from olvaffe’s ffmpeg source tree to your ffmpeg-original source tree. There should be a Android.mk, av.mk under ffmpeg root dir. And, Android.mk under each libavcodec, libavutil, libavformat, libpostproc, libswscale dirs. If you don’t have Android.mk under libswscale/libpostproc, just copy one from libavutil. I don’t use libavdevice, so I just ignore it. Then, comment out all config.mak & subdir.mak in */Makefile.

STEP5:

cd to your NDK root dir, type make TARGET_ARCH=arm APP=ffmpeg-org

STEP6:

you should have a lot of compilation errors. That’s okay. I’ll show you how to fix them.

* edit libavutil/internal.h, comment out all error func(s).

* comment out all “restrict” keyword related “restrict” errors. They should in libavcodec/dsputil.h, libavformat/rtpenc_h263.c, libavcodec/dnxhdenc.c,
libavcodec/dsputil.c, libavcodec/ituh263dec.c, libavcodec/mpegvideo.c.

Try make again, and here we go. Those static *.a files are now in your NDK_ROOT/out/apps/ffmpeg-org/android-1.5-arm/.

=======================================================================

h1

February 23, 2010

I spent several days trying to compile ffmpeg on android-ndk1.5. Just want to share to others. Hopefully, it can save you some time.

STEP1:

First, I get the source code from ~olvaffe/ffmpeg/ffmpeg-android. I will need to use its *.mk files.

STEP2:

Get the ffmpeg source code from I used svn, instead of git, so that I won’t need to get libswscale separately.

STEP3:

configure my ffmpeg with following cmd.

#!/bin/sh
PREBUILT=/home/myhome/android-ndk/build/prebuilt/linux-x86/arm-eabi-4.2.1
./configure –target-os=linux \
–arch=armv41 \
–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 ” \
–enable-static \
–disable-shared \
–disable-asm \
–disable-yasm \
–prefix=/home/myhome/work/ffmpeg-android-bin \
–extra-ldflags=”-Wl,-T,$PREBUILT/arm-eabi/lib/ldscripts/armelf.x -Wl,-rpath-link=/home/myhome/android-ndk/build/platforms/android-1.5/arch-arm/usr/lib -L/home/myhome/android-ndk/build/platforms/android-1.5/arch-arm/usr/lib -nostdlib /home/myhome/android-ndk/build/prebuilt/linux-x86/arm-eabi-4.2.1/lib/gcc/arm-eabi/4.2.1/crtbegin.o /home/myhome/android-ndk/build/prebuilt/linux-x86/arm-eabi-4.2.1/lib/gcc/arm-eabi/4.2.1/crtend.o -lc -lm -ldl”

** I referenced this one at http://blog.csdn.net/anakiagmail/archive/2009/08/14/4446986.aspx ** If you don’t understand chinese, I’ll show you what it describe in following steps.

STEP4:

By now, configure should be passed successfully. Copy *.mk from olvaffe’s ffmpeg source tree to your ffmpeg-original source tree. There should be a Android.mk, av.mk under ffmpeg root dir. And, Android.mk under each libavcodec, libavutil, libavformat, libpostproc, libswscale dirs. If you don’t have Android.mk under libswscale/libpostproc, just copy one from libavutil. I don’t use libavdevice, so I just ignore it. Then, comment out all config.mak & subdir.mak in */Makefile.

STEP5:

cd to your NDK root dir, type make TARGET_ARCH=arm APP=ffmpeg-org

STEP6:

you should have a lot of compilation errors. That’s okay. I’ll show you how to fix them.

* edit libavutil/internal.h, comment out all error func(s).

* comment out all “restrict” keyword related “restrict” errors. They should in libavcodec/dsputil.h, libavformat/rtpenc_h263.c, libavcodec/dnxhdenc.c,
libavcodec/dsputil.c, libavcodec/ituh263dec.c, libavcodec/mpegvideo.c.

Try make again, and here we go. Those static *.a files are now in your NDK_ROOT/out/apps/ffmpeg-org/android-1.5-arm/.

9 comments

  1. [...] ffmpeg and Android.mk Posted in 開発 | Tags: android, ffmpeg, yourfilehost « YouTubeAPIのクエリパラメータ You can leave a response, or trackback from your own site. [...]


  2. 编译出来的静态库可以用吗?我在一个动态 库里面调用ffmpeg里面的功能,提示undefined reference to ***这样的错误。同时发现,那些libavcodec.a什么的确实都生成了,并且指向的路径也对,不知道什么原因。


  3. Thanks for this tutorial!
    But I am not sure how to realize step 4 to step 5. What is your folder structure in ~/android-ndk/app did you check out the source code in
    ~/android-ndk/app/ffmpeg-org or did you a symbolic link?

    So I was only able to realize your tutorial to step 4. ;) . I am using android-ndk release 3.

    best regards Matthias


    • as long as there is a ffmpeg-org under your android-ndk/sources, doesn’t matter it is symbolic link or not. And under your android-ndk/apps/, there is a ffmpeg-org dir too. So, under android-ndk root dir, you just need to type “make APP=ffmpeg-org” cmd.


  4. There’s gotta be a better way than commenting out the restrict qualifier everywhere. Anybody figure out a way to get around this in one of the config files?


  5. I tryed step 3, but it says :

    /Users/jb/Documents/android/android-ndk-r3/build/prebuilt/darwin-x86/arm-eabi-4.2.1/bin/arm-eabi-gcc is unable to create an executable file.
    C compiler test failed.

    I don’t understand why… :( can anyone help me ?


  6. On step 5, I got the error
    “Android NDK: The APP variable contains unknown app names: ffmpeg-org
    Android NDK: Please use one of: hello-gl2 hello-jni san-angeles two-libs unit-tests “.

    So I ignored it and do the step 6, but when I try to make again, the error still there.

    Please help on this issue.


    • under your $Android-NDK-root/apps/, there should be a “ffmpeg-org” dir. and under ffmpeg-org, you will need to have a Application.mk. Please read Android-NDK tutorial/doc


  7. I don’t understand how to make understand the compiler that it will not result in an executable program… : “… is unable to create an executable file…”

    How did you manage that ??

    Thanks for the help









[Via ]

阅读(2877) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2010-09-02 12:02:14

I am in windows to compile ffmpeg for android ,in step 5, I got the error:No rule to make target "ffmpeg-org",needed by 'ndk-app-ffmpeg-org'