Log in

I forgot my password

Latest topics

»  change hdmi resolution of odroid-a
Yesterday at 6:37 am by odroid

» Odroid-X2 CE-marking
Yesterday at 6:36 am by odroid

» microphone in odroid u2
Yesterday at 6:36 am by odroid

» [SOLVED] Webcam in Odroid-X (Ubuntu 12.10)
Yesterday at 6:35 am by odroid

» eMMC rewrite on ODROID
Yesterday at 6:35 am by odroid

» new to odroid forums.
Yesterday at 6:35 am by odroid

» How can I install the Google Play (Android Market)?
Mon Apr 29, 2013 9:20 pm by intrf@ce

» datasheet of max77686
Tue Apr 23, 2013 8:02 am by chenaichenluo

» Flashing Android on SD card [X2]
Sat Apr 20, 2013 5:00 pm by odroid

» Only administrators?
Wed Apr 17, 2013 4:01 am by Bart of the North

» Admin view
Sun Apr 14, 2013 11:07 am by PeterPan24

» powersupply for ordoid u2
Sat Apr 13, 2013 6:03 pm by KC7NOA

» using ordroid u2 for indoor navigation
Thu Apr 11, 2013 4:59 am by jtjohnsontellis

» Source code: android emulators(NES, SNES, GG, GBC, GENS, Atari)
Mon Feb 18, 2013 3:28 am by p-Dawg

» emmc reader not working
Fri Feb 15, 2013 6:37 pm by sert00

Poll

How is your Over Clocking(ODROID-X)?
23% 23% [ 9 ]
33% 33% [ 13 ]
45% 45% [ 18 ]

Total Votes : 40

FFmpeg compiled with Android NDK 5 5 2

    FFmpeg compiled with Android NDK

    Share

    Alvaro
    Admin
    Admin

    Languages ​​spoken: English, Spanish
    Devices: ODROID, ODROID-T,ODROID-7, ODROID-A, ODROID-ADK, ODROID-BaB, ODROID-PC, ODROID-E7, ODROID-NFC, ODROID-BaB, ODROID-PC, ODROID-A4, ODROID-X, ODROID-Q, ODROID-X2, ODROID-U2, ODROID-Q2
    Posts: 1161
    Join date: 2010-05-09
    Location: Madrid, Spain

    FFmpeg compiled with Android NDK

    Post by Alvaro on Sun Oct 24, 2010 10:56 am

    Hi,

    FFmpeg compiled with Android NDK


    Android built-in codec is too small, so we need to FFmpeg. Android provides the NDK, as we use the C language code for FFmpeg which offers convenience.


    First create a standard project vPlayer Android
    Code:
    android create project-n vPlayer-t 8-p vPlayer-k me.abitno.vplayer-a PlayerView

    Then vPlayer directory
    Code:
    mkdir jni & & cd jni
    wget http://ffmpeg.org/releases/ffmpeg-0.6.tar.bz2 wget http://ffmpeg.org/releases/ffmpeg-0.6.tar.bz2
    tar xf ffmpeg-0.6.tar.bz2 && mv ffmpeg-0.6 ffmpeg && cd ffmpeg tar xf ffmpeg-0.6.tar.bz2 & & mv ffmpeg-0.6 ffmpeg & & cd ffmpeg

    In ffmpeg under a new config.sh, which reads as follows, attention to PREBUILT and PLATFORM is set correctly. Also contains some parameters you can adjust, I am mainly a player in order to configure the settings and such.
    Code:
     #! / Bin / bash

    PREBUILT=/home/abitno/Android/android-ndk-r4/build/prebuilt/linux-x86/arm-eabi-4.4.0 PREBUILT = / home/abitno/Android/android-ndk-r4/build/prebuilt/linux-x86/arm-eabi-4.4.0
    PLATFORM=/home/abitno/Android/android-ndk-r4/build/platforms/android-8/arch-arm PLATFORM = / home/abitno/Android/android-ndk-r4/build/platforms/android-8/arch-arm

    ./configure --target-os=linux \ . / Configure - target-os = linux \
       --arch=arm \ - Arch = arm \
       --enable-version3 \ - Enable-version3 \
       --enable-gpl \ - Enable-gpl \
       --enable-nonfree \ - Enable-nonfree \
       --disable-stripping \ - Disable-stripping \
       --disable-ffmpeg \ - Disable-ffmpeg \
       --disable-ffplay \ - Disable-ffplay \
       --disable-ffserver \ - Disable-ffserver \
       --disable-ffprobe \ - Disable-ffprobe \
       --disable-encoders \ - Disable-encoders \
       --disable-muxers \ - Disable-muxers \
       --disable-devices \ - Disable-devices \
       --disable-protocols \ - Disable-protocols \
       --enable-protocol=file \ - Enable-protocol = file \
       --enable-avfilter \ - Enable-avfilter \
       --disable-network \ - Disable-network \
       --disable-mpegaudio-hp \ - Disable-mpegaudio-hp \
       --disable-avdevice \ - Disable-avdevice \
       --enable-cross-compile \ - Enable-cross-compile \
       --cc= $ PREBUILT /bin/arm-eabi-gcc \ - Cc = $ PREBUILT / bin / arm-eabi-gcc \
       --cross-prefix= $ PREBUILT /bin/arm-eabi- \ - Cross-prefix = $ PREBUILT / bin/arm-eabi- \
       --nm= $ PREBUILT /bin/arm-eabi-nm \ - Nm = $ PREBUILT / bin / arm-eabi-nm \
       --extra-cflags= " -fPIC -DANDROID " \ - Extra-cflags = "-fPIC-DANDROID" \
       --disable-asm \ - Disable-asm \
       --enable-neon \ - Enable-neon \
       --enable-armv5te \ - Enable-armv5te \
       --extra-ldflags= " -Wl,-T, $ PREBUILT /arm-eabi/lib/ldscripts/armelf.x -Wl,-rpath-link= $ PLATFORM /usr/lib -L $ PLATFORM /usr/lib -nostdlib $ PREBUILT /lib/gcc/arm-eabi/4.4.0/crtbegin.o $ PREBUILT /lib/gcc/arm-eabi/4.4.0/crtend.o -lc -lm -ldl " - Extra-ldflags = "-Wl,-T, $ PREBUILT / arm-eabi/lib/ldscripts/armelf.x-Wl,-rpath-link = $ PLATFORM / usr / lib-L $ PLATFORM / usr / lib - nostdlib $ PREBUILT / lib/gcc/arm-eabi/4.4.0/crtbegin.o $ PREBUILT / lib/gcc/arm-eabi/4.4.0/crtend.o-lc-lm-ldl "

    Started running config.sh configure
    Code:
    chmod + x config.sh
    ./config.sh . / Config.sh

    configure complete, just edit the generated config.h, find the phrase
    Code:
    # define restrict restrict

    Android's GCC does not support the restrict keyword, then modified the following way
    Code:
    # Define restrict

    Edit libavutil / libm.h, static methods to remove them.
    Were modified libavcodec, libavfilter, libavformat, libavutil, libpostproc and libswscale under the Makefile, delete the following two
    Code:
     include $ (SUBDIR) .. / subdir.mak
    include $( SUBDIR ) ../config.mak include $ (SUBDIR) .. / config.mak

    To add a file in the ffmpeg av.mk, reads as follows
    Code:
    # LOCAL_PATH is one of libavutil, libavcodec, libavformat, or libswscale

    # include $(LOCAL_PATH)/../config-$(TARGET_ARCH).mak # Include $ (LOCAL_PATH )/../ config-$ (TARGET_ARCH). Mak
    include $( LOCAL_PATH ) /../config.mak include $ (LOCAL_PATH) / .. / config.mak

    OBJS := OBJS: =
    OBJS-yes := OBJS-yes: =
    MMX-OBJS-yes := MMX-OBJS-yes: =
    include $( LOCAL_PATH ) /Makefile include $ (LOCAL_PATH) / Makefile

    # collect objects # Collect objects
    OBJS- $( HAVE_MMX ) += $( MMX-OBJS-yes ) OBJS-$ (HAVE_MMX) + = $ (MMX-OBJS-yes)
    OBJS += $( OBJS-yes ) OBJS + = $ (OBJS-yes)

    FFNAME := lib $( NAME ) FFNAME: = lib $ (NAME)
    FFLIBS := $( foreach,NAME, $( FFLIBS ) ,lib $( NAME ) ) FFLIBS: = $ (foreach, NAME, $ (FFLIBS), lib $ (NAME))
    FFCFLAGS  = -DHAVE_AV_CONFIG_H -Wno-sign-compare -Wno-switch -Wno-pointer-sign FFCFLAGS =-DHAVE_AV_CONFIG_H-Wno-sign-compare-Wno-switch-Wno-pointer-sign
    FFCFLAGS += -DTARGET_CONFIG= " config- $( TARGET_ARCH ) .h " FFCFLAGS + =-DTARGET_CONFIG = \ "config-$ (TARGET_ARCH). H "

    ALL_S_FILES := $( wildcard $( LOCAL_PATH ) / $( TARGET_ARCH ) /*.S ) ALL_S_FILES: = $ (wildcard $ (LOCAL_PATH) / $ (TARGET_ARCH) / *. S)
    ALL_S_FILES := $( addprefix $( TARGET_ARCH ) /, $( notdir $( ALL_S_FILES ) ) ) ALL_S_FILES: = $ (addprefix $ (TARGET_ARCH) /, $ (notdir $ (ALL_S_FILES)))

    ifneq ( $( ALL_S_FILES ) ,) ifneq ($ (ALL_S_FILES),)
    ALL_S_OBJS := $( patsubst %.S,%.o, $( ALL_S_FILES ) ) ALL_S_OBJS: = $ (patsubst%. S,%. O, $ (ALL_S_FILES))
    C_OBJS := $( filter-out $( ALL_S_OBJS ) , $( OBJS ) ) C_OBJS: = $ (filter-out $ (ALL_S_OBJS), $ (OBJS))
    S_OBJS := $( filter $( ALL_S_OBJS ) , $( OBJS ) ) S_OBJS: = $ (filter $ (ALL_S_OBJS), $ (OBJS))
    else else
    C_OBJS := $( OBJS ) C_OBJS: = $ (OBJS)
    S_OBJS := S_OBJS: =
    endif endif

    C_FILES := $( patsubst %.o,%.c, $( C_OBJS ) ) C_FILES: = $ (patsubst%. O,%. C, $ (C_OBJS))
    S_FILES := $( patsubst %.o,%.S, $( S_OBJS ) ) S_FILES: = $ (patsubst%. O,%. S, $ (S_OBJS))

    FFFILES := $( sort $( S_FILES ) ) $( sort $( C_FILES ) ) FFFILES: = $ (sort $ (S_FILES)) $ (sort $ (C_FILES))

    Next step is to add a series of Android.mk, in the root directory jni follows
    Code:
    include $ (all-subdir-makefiles)

    In the ffmpeg directory, Android.mk
    Code:
     LOCAL_PATH: = $ (call my-dir)
    include $( CLEAR_VARS ) include $ (CLEAR_VARS)
    LOCAL_STATIC_LIBRARIES := libavformat libavcodec libavutil libpostproc libswscale LOCAL_STATIC_LIBRARIES: = libavformat libavcodec libavutil libpostproc libswscale
    LOCAL_MODULE := ffmpeg LOCAL_MODULE: = ffmpeg
    include $( BUILD_SHARED_LIBRARY ) include $ (BUILD_SHARED_LIBRARY)
    include $( call all-makefiles-under, $( LOCAL_PATH ) ) include $ (call all-makefiles-under, $ (LOCAL_PATH))

    libavformat / Android.mk
    Code:
     LOCAL_PATH: = $ (call my-dir)
    include $( CLEAR_VARS ) include $ (CLEAR_VARS)
    include $( LOCAL_PATH ) /../av.mk include $ (LOCAL_PATH) / .. / av.mk
    LOCAL_SRC_FILES := $( FFFILES ) LOCAL_SRC_FILES: = $ (FFFILES)
    LOCAL_C_INCLUDES := \ LOCAL_C_INCLUDES: = \
       $( LOCAL_PATH ) \ $ (LOCAL_PATH) \
       $( LOCAL_PATH ) /.. $ (LOCAL_PATH) / ..
    LOCAL_CFLAGS += $( FFCFLAGS ) LOCAL_CFLAGS + = $ (FFCFLAGS)
    LOCAL_CFLAGS += -include " string.h " -Dipv6mr_interface=ipv6mr_ifindex LOCAL_CFLAGS + =-include "string.h"-Dipv6mr_interface = ipv6mr_ifindex
    LOCAL_LDLIBS := -lz LOCAL_LDLIBS: =-lz
    LOCAL_STATIC_LIBRARIES := $( FFLIBS ) LOCAL_STATIC_LIBRARIES: = $ (FFLIBS)
    LOCAL_MODULE := $( FFNAME ) LOCAL_MODULE: = $ (FFNAME)
    include $( BUILD_STATIC_LIBRARY ) include $ (BUILD_STATIC_LIBRARY)

    libavcodec / Android.mk
    Code:
     LOCAL_PATH: = $ (call my-dir)
    include $( CLEAR_VARS ) include $ (CLEAR_VARS)
    include $( LOCAL_PATH ) /../av.mk include $ (LOCAL_PATH) / .. / av.mk
    LOCAL_SRC_FILES := $( FFFILES ) LOCAL_SRC_FILES: = $ (FFFILES)
    LOCAL_C_INCLUDES := \ LOCAL_C_INCLUDES: = \
       $( LOCAL_PATH ) \ $ (LOCAL_PATH) \
       $( LOCAL_PATH ) /.. $ (LOCAL_PATH) / ..
    LOCAL_CFLAGS += $( FFCFLAGS ) LOCAL_CFLAGS + = $ (FFCFLAGS)
    LOCAL_LDLIBS := -lz LOCAL_LDLIBS: =-lz
    LOCAL_STATIC_LIBRARIES := $( FFLIBS ) LOCAL_STATIC_LIBRARIES: = $ (FFLIBS)
    LOCAL_MODULE := $( FFNAME ) LOCAL_MODULE: = $ (FFNAME)
    include $( BUILD_STATIC_LIBRARY ) include $ (BUILD_STATIC_LIBRARY)

    libavfilter, libavutil, libpostproc and libswscale Android.mk as follows under
    Code:
     LOCAL_PATH: = $ (call my-dir)
    include $( CLEAR_VARS ) include $ (CLEAR_VARS)
    include $( LOCAL_PATH ) /../av.mk include $ (LOCAL_PATH) / .. / av.mk
    LOCAL_SRC_FILES := $( FFFILES ) LOCAL_SRC_FILES: = $ (FFFILES)
    LOCAL_C_INCLUDES := \ LOCAL_C_INCLUDES: = \
       $( LOCAL_PATH ) \ $ (LOCAL_PATH) \
       $( LOCAL_PATH ) /.. $ (LOCAL_PATH) / ..
    LOCAL_CFLAGS += $( FFCFLAGS ) LOCAL_CFLAGS + = $ (FFCFLAGS)
    LOCAL_STATIC_LIBRARIES := $( FFLIBS ) LOCAL_STATIC_LIBRARIES: = $ (FFLIBS)
    LOCAL_MODULE := $( FFNAME ) LOCAL_MODULE: = $ (FFNAME)
    include $( BUILD_STATIC_LIBRARY ) include $ (BUILD_STATIC_LIBRARY)

    Outermost jni / Android.mk and jni / ffmpeg / Android.mk I'm just written this way, you should be rewritten according to their needs.

    Finally, run the ndk-build, after a long wait to compile complete

    Using libffmpeg.so in Android NDK


    So I made up the compiled so file, please download the attachment. Note that this file is compiled with optimizations for NEON, NEON does not support the ARM processor may not run.

    Things seem to never written a long time, the following describes the general use of the next, hoping a little help.

    Android First you have a project to put the project libffmpeg.so libs/armeabi-v7a / in. Then be prepared to FFmpeg's source files, put them in the directory you like, such as jni / ffmpeg / in.

    Edit the items you need to use libffmpeg.so module Android.mk, in the right place to add the following
    Code:
    LOCAL_C_INCLUDES + = $ (PATH_TO_FFMPEG_SOURCE)
    LOCAL_LDLIBS += -L $( PATH_TO_LIBFFMPEG_SO ) -lffmpeg LOCAL_LDLIBS + =-L $ (PATH_TO_LIBFFMPEG_SO)-lffmpeg

    FFmpeg source code representative of the variable PATH_TO_FFMPEG_SOURCE path, PATH_TO_LIBFFMPEG_SO is to libffmpeg.so path.

    Explain this so contains only avformat, avcodec and avutil three parts, and I also put them into the Android log method applied.

    All OK, then you are free to use the FFmpeg.

    In addition, the content of this article not been tested, but the content of images, but basically that is the case.
    Recommended FFmpeg beginners look at this http://dranger.com/ffmpeg/ffmpeg.html

    Conclusion


    I think if someone can be encouraged to have a good player for Android and completely free. In our case, if only for S5PC110 optimized, go very well and very fluid.

    Will anyone dare?

    Download:
    Code:
    http://www.mediafire.com/?qqsm8r6nz256y70
    http://www.fileserve.com/file/9NPhyfz
    http://www.multiupload.com/C5CFK45VYO


    Thanks,

    Alvaro

    001
    Member
    Member

    Devices: 7
    Posts: 1
    Join date: 2011-05-19

    Re: FFmpeg compiled with Android NDK

    Post by 001 on Thu May 19, 2011 11:00 am

    Alvaro,

    Did someone take you up on the offer?

    001

    wankeye
    Member
    Member

    Devices: odroid-a
    Posts: 3
    Join date: 2011-07-25

    Re: FFmpeg compiled with Android NDK

    Post by wankeye on Mon Jul 25, 2011 7:59 am

    Thank you for your share! I have a problem with creating an executable file using ffprobe.c and cmdutils.c.Of course I copy the whole directory to android's directory framework/ and it printed prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/../lib/gcc/arm-eabi/4.4.3/../../../../arm-eabi/bin/ld: out/target/product/pandaboard/obj/STATIC_LIBRARIES/libswscale_intermediates/libswscale.a(utils.o): in function sws_init_context:frameworks/lim-omx-0.6/limoi-components/ffmpeg/src/libswscale/utils.c:786: error: undefined reference to 'av_get_cpu_flags' .
    What's matter?
    Thanks for attention!


    Last edited by wankeye on Mon Jul 25, 2011 8:01 am; edited 1 time in total (Reason for editing : adding)

    Alvaro
    Admin
    Admin

    Languages ​​spoken: English, Spanish
    Devices: ODROID, ODROID-T,ODROID-7, ODROID-A, ODROID-ADK, ODROID-BaB, ODROID-PC, ODROID-E7, ODROID-NFC, ODROID-BaB, ODROID-PC, ODROID-A4, ODROID-X, ODROID-Q, ODROID-X2, ODROID-U2, ODROID-Q2
    Posts: 1161
    Join date: 2010-05-09
    Location: Madrid, Spain

    Re: FFmpeg compiled with Android NDK

    Post by Alvaro on Mon Jul 25, 2011 10:54 am

    Hi wankeye,

    I'm trying to reproduce a mistake, I've tried everything just to put it on and not give me any error ... Can you try again, doing all the steps? If it still fails publishes the entire log and carefully try to solve the error.

    Thanks,

    Alvaro

    wankeye
    Member
    Member

    Devices: odroid-a
    Posts: 3
    Join date: 2011-07-25

    Re: FFmpeg compiled with Android NDK

    Post by wankeye on Mon Jul 25, 2011 2:40 pm

    Hi Alvaro,I was successfully creating ffmpeg.so with the source version is 0.8 following you tips,and I really apriciated it. but I have problem creating an executable file ffprobe with the files ffprobe.c and cmdutils.c.

    Thank you for attention and what you did for us.

    vikas44
    Member
    Member

    Devices: ODROID, ODROID-T, ODROID-S, ODROID-7, ODROID-A, ODROID-ADK, ODROID-BaB
    Posts: 1
    Join date: 2011-10-11

    Re: FFmpeg compiled with Android NDK

    Post by vikas44 on Tue Oct 11, 2011 5:26 pm

    Hello wankeye,

    I am facing problem in creating ffmpeg.so file which I need to use on android side.
    I tried above steps, and i try to comment or resolve error one by one ... but it seems its a never ending process.
    Could please share your JNI folder, I would be great help.

    Thanks & BR,
    Vikas

    o89m
    Member
    Member

    Devices: none
    Posts: 1
    Join date: 2011-12-09

    Re: FFmpeg compiled with Android NDK

    Post by o89m on Fri Dec 09, 2011 4:17 pm

    I am not a lawyer, but wouldn't using both --enable-nonfree and --enable-gpl make it illegal to distribute the resulting binaries? If you enable GPL libraries, the resulting binaries must be GPL which means that the user must be free to modify them in any way he wants. He can not do that if they contain nonfree code.

    SwordBearer
    Member
    Member

    Languages ​​spoken: English
    Devices: ODROID
    Posts: 1
    Join date: 2013-01-07

    Re: FFmpeg compiled with Android NDK

    Post by SwordBearer on Mon Jan 07, 2013 9:37 am

    Thanks,I compiled ffmpeg.so successfully for Android NDK,but I find a error when i use libswscale:
    libswscale/utils.c:786: error: undefined reference to 'av_get_cpu_flags'
    it means can't link to the 'av_get_cpu_flag' method ,but this method has been defined,
    why still has this error?
    Thanks for attention!

      Current date/time is Sat May 25, 2013 2:35 pm