I have followed lots of tutorials for buildinf ffmpeg.so file like
http://enoent.fr/blog/2014/06/20/compile-ffmpeg-for-android/
http://www.roman10.net/how-to-build-ffmpeg-with-ndk-r9/
and many more tutorials but at last i have stuck to this error every time i dont know how to resolve it please any one knows how to solve it then help me
my build.sh file look like this
NDK=C:/Users/Benzatine/Downloads/android-ndk-r10e
SYSROOT=$NDK/platforms/android-19/arch-arm/
TOOLCHAIN=$NDK/toolchains//arm-linux-androideabi-4.8/prebuilt/windows-x86_64
function build_one
{
./configure \
--prefix=$PREFIX \
--enable-shared \
--disable-static \
--disable-doc \
--disable-ffmpeg \
--disable-ffplay \
--disable-ffprobe \
--disable-ffserver \
--disable-avdevice \
--disable-doc \
--disable-symver \
--cross-prefix=$TOOLCHAIN/bin/arm-linux-androideabi- \
--target-os=linux \
--arch=arm \
--enable-cross-compile \
--sysroot=$SYSROOT \
--extra-cflags="-Os -fpic $ADDI_CFLAGS" \
--extra-ldflags="$ADDI_LDFLAGS" \
$ADDITIONAL_CONFIGURE_FLAG
make clean
make
make install
}
CPU=arm
PREFIX=$(pwd)/android/$CPU
ADDI_CFLAGS="-marm"
build_one
But when it executes make command it gives following error
LD libswscale/libswscale-3.so
c:/users/benzatine/downloads/android-ndk-r10e/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld.exe: error: libavutil/libavutil.so:1:1: syntax error, unexpected '!', expecting $end
c:/users/benzatine/downloads/android-ndk-r10e/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld.exe: error: libavutil/libavutil.so: not an object or archive
collect2.exe: error: ld returned 1 exit status
library.mak:111: recipe for target 'libswscale/libswscale-3.so' failed
make: *** [libswscale/libswscale-3.so] Error 1
every time i try to build ffmpeg this error occure how to resolve it please someone help me
I am going to assume that you are building it on Windows system based on the error message.
I just found this post on Facebook group so I am not going to take any credit for it.Bascially he just use other project and tweak it to make it work forcefully.It use Android 'Love' version and compile it in Windows system.
FFMpeg (https://www.ffmpeg.org), one of the most used libary written in C programming language for multimedia related task.
It has a lot of feature to add multimedia support for your application but the trouble being a 'C' library we have
port it into other language if you don't want to create your application in C/C++. Trust me porting it into
different language is a lot of work which are filled with error. Luckily you can find tutorial and easy build
script in the internet but unfountenly , they are only written by assumption that you are porting it
into nix based OS and the few tutorial on porting it on Windows OS does not work (atleast for me. :) )
But the main reason I am using ffmpeg is to add a multimedia feature to the android which are not
provided by standard Android API. I found some pre-made android project on an internet
which use FFMpeg 'Love' version. Here is the project.
In case you are wondering how to use it in your Android project , here are the step
1) Add a native support to the Android Project by right-clicking the Android Tools>Add Native Support...
2) Copy 'armeabi' folder to 'libs' folder of your project
3) Replace 'obj' folder with the 'obj' of ffmpeg project in the attached file
4) Add 'ffmpeg' folder to the 'jni' folder
5) Replace 'Androd.mk' folder with the 'Android.mk' of the ffmpeg project in the attached file
6) Write your code in C/C++ and enjoy
As always if you have any trouble or question you can comment them and I will answer them as soon as possible
Attached file:http://robot-mitya.googlecode.com/files/MyFfmpegTest.zip
Source:http://dmitrydzz-hobby.blogspot.com/2012/04/how-to-build-ffmpeg-and-use-it-in.html
Related
I'm working on an android app, and I have to convert webm files to mp3.
I really want to make a custom ffmpeg build, because it reduces the ffmpeg executable size to only 2MB.
My library works absolutely fine when running on my PC, but i'm struggling to build it for android... It seems like NDK architecture has changed and tutorials are outdated, and I can't find a proper and recent guide for android compiling...
I also would like to target all architectures (aarch64, armv7, i686, and x86_64)...
I've been on this for hours, fixed many errors, but still nothing has worked ><.
Please help me ! :\
PS. I'm compiling on Linux, here is my configuration script:
#!/bin/bash
API=31 # target android api
OUTPUT=/home/romain/dev/android/ffmpeg_build
NDK=/home/romain/android-sdk/ndk/23.0.7599858
TOOLCHAIN=$NDK/toolchains/llvm/prebuilt/linux-x86_64
SYSROOT=$TOOLCHAIN/sysroot
TOOL_PREFIX="$TOOLCHAIN/bin/aarch64-linux-android"
CC="$TOOL_PREFIX$API-clang"
CXX="$TOOL_PREFIX$API-clang++"
./configure \
--prefix=$OUTPUT \
--target-os=android \
--arch=$ARCH \
--cpu=$CPU \
--disable-everything \
--disable-everything \
--disable-network \
--disable-autodetect \
--enable-small \
--enable-decoder=opus,vorbis \
--enable-demuxer=matroska \
--enable-muxer=mp3 \
--enable-protocol=file \
--enable-filter=aresample \
--enable-libshine \
--enable-encoder=libshine \
--cc=$CC \
--cxx=$CXX \
--sysroot=$SYSROOT \
--extra-cflags="-0s -fpic"
make
make install
The prefix should point to $SYSROOT/usr/ and you misunderstood what --prefix mean. Its not output directory. Other than that i think nothing problematic than that (if it still happen please provide ffbuild/config.log)
The repository pointed to by the previous answer is no longer being maintained.
Here is an updated one.
This is the android branch: https://github.com/arthenica/ffmpeg-kit/tree/main/android
When i build the x264 ndk library , i face a problem .
I've compiled both in window and liunx environment.i got the same mistakes...
like this:
In file included
from c:\users\xxx\appdata\local\android\sdk\ndk-bundle\toolchains\
aarch64-linux-android-4.9\prebuilt\windows-x86_64\lib\gcc\aarch64-linux-android\4.9.x\include-fixed\syslimits.h:7:0,
from c:\users\xxx\appdata\local\android\sdk\ndk-bundle\toolchains\
aarch64-linux-android-4.9\prebuilt\windows-x86_64\lib\gcc\aarch64-linux-android\4.9.x\include-fixed\limits.h:34,
from ./common/common.h:123,
from ./x264cli.h:30,
from ./input/input.h:31,
from ./filters/video/video.h:29,
from ./filters/video/depth.c:26:
c:\users\xxx\appdata\local\android\sdk\ndk-bundle\toolchains\aarch64-linux-android-4.9\
prebuilt\windows-x86_64\lib\gcc\aarch64-linux-android\4.9.x\include-fixed\limits.h:168:61:
error: no include path in which to search for limits.h
#include_next <limits.h> /* recurse down to the real one */
make: *** [.depend] Error 1
Here is my script:
SYSROOT=$NDK/platforms/android-21/arch-arm64
TOOLCHAIN=$NDK/toolchains/aarch64-linux-android-4.9/prebuilt/windows-x86_64
CC=$TOOLCHAIN/bin/aarch64-linux-android-gcc-4.9.x
#CXX=$TOOLCHAIN/bin/aarch64-linux-android-g++
CROSS_PREFIX=$TOOLCHAIN/bin/aarch64-linux-android-
EXTRA_CFLAGS="-march=armv8-a -D__ANDROID__"
EXTRA_LDFLAGS="-nostdlib"
./configure --prefix=$PREFIX \
--host=arm-linux \
--sysroot=$SYSROOT \
--cross-prefix=$CROSS_PREFIX \
--extra-cflags="$EXTRA_CFLAGS" \
--extra-ldflags="$EXTRA_LDFLAGS" \
--enable-pic \
--enable-static \
--enable-strip \
--disable-cli \
--disable-win32thread \
--disable-avs \
--disable-swscale \
--disable-lavf \
--disable-ffms \
--disable-gpac \
--disable-lsmash \
--disable-asm \
--disable-opencl
does anyone know how to solve it? thanks every much.
To build with latest NDK You need to use --deprecated-headers while creating standalone toolchain.
Some additional info: NDK unified headers
This problem occurs when you use recent versions of android ndk. Please, use older versions like android ndk r13b. I have successfully built on my mac machine using android ndk r13b.
Link given below:
https://dl.google.com/android/repository/android-ndk-r13b-darwin-x86_64.zip
Please, use one specific to your platform.
You can also follow this link https://osburneblog.wordpress.com/2017/06/01/cross-compiling-ffmpeg-and-libx264-for-android/ know more about build process.
I've been trying to compile FFMPEG so I can use it with my Android application with commands. The result should be 1 static file, "ffmpeg", that is not package dependent. No .so files.
I managed to compile it with guardianProject and everything is working but the source was too old and lacks options I need.
I'm using the latest Ubuntu on VirtualBox, all essentials are installed and updated (gawk, yasm, aptitude, etc...).
There are multiple examples around the web. Here are the issues I've experienced with each of the options I tried. I'd appreciate help with either one of the following errors:
Guardian project - I managed to compile it and get the ffmpeg file but it uses an old version of ffmpeg that doesn't include the "-movFlags faststart" option. I tried throwing the new ffmpeg (2.3.3) in there but it just throws error. (I ran git submodule init and update)
JayH5 - A more generic build file that basically should work with every ffmpeg. I updated the build script to work with the latest NDK and it seems to be working but than it fails on /home/dor/Desktop/ndk/android-ndk-r10/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86/bin/arm-linux-androideabi-pkg-config not found, library detection may fail.
I read about this and it seems to require a hack, which I don't understand how to implement.
Trovao - this is a very nice project and the build script even downloads the latest ffmpeg and x264 sources, and I even succeeded in compiling it to FFMPEG and X264 files but when I use it, I get this error: could not load library "libx264.so.142 which is weird, as x264 is there and the whole idea of this project is to cancel the need of .so files.
I'd appreciate help with figuring out how to solve any of the issues. I prefer using the JayH5 build script as it seems the most straight forward out there...
JayH5 build file:
#!/bin/bash
# set the base path to your Android NDK (or export NDK to environment)
if [[ "x$NDK_BASE" == "x" ]]; then
NDK_BASE=/opt/android-ndk
echo "No NDK_BASE set, using $NDK_BASE"
fi
NDK_PLATFORM_VERSION=14
NDK_ABI=arm
NDK_COMPILER_VERSION=4.8
NDK_SYSROOT=$NDK_BASE/platforms/android-$NDK_PLATFORM_VERSION/arch-$NDK_ABI
NDK_UNAME=`uname -s | tr '[A-Z]' '[a-z]'` # Convert Linux -> linux
HOST=$NDK_ABI-linux-androideabi
NDK_TOOLCHAIN_BASE=$NDK_BASE/toolchains/$HOST-$NDK_COMPILER_VERSION/prebuilt/$NDK_UNAME-x86
CC="$NDK_TOOLCHAIN_BASE/bin/$HOST-gcc --sysroot=$NDK_SYSROOT"
LD=$NDK_TOOLCHAIN_BASE/bin/$HOST-ld
BUILD_PATH=build/ffmpeg
./configure \
$DEBUG_FLAG \
--arch=arm \
--target-os=linux \
--enable-runtime-cpudetect \
--enable-pic \
--disable-shared \
--enable-static \
--cross-prefix=$NDK_TOOLCHAIN_BASE/bin/$NDK_ABI-linux-androideabi- \
--sysroot="$NDK_SYSROOT" \
--extra-cflags="-march=armv7-a -mfloat-abi=softfp -fPIC -DANDROID" \
--extra-ldflags="" \
--enable-ffmpeg \
--disable-ffplay \
--disable-ffprobe \
--disable-ffserver \
--disable-network \
After 2 days of compiling FFMPEG files that just didn't work, I finally succeeded!
In the above build.sh file, just add these 4 lines and the bottom to avoid the prebuilt/linux-x86/bin/arm-linux-androideabi-pkg-config not found, library detection may fail error.
Add to file:
$ADDITIONAL_CONFIGURE_FLAG
make clean
make
make install
Don't forget to chmod 775 ffmpeg file after the process is finished.
Really hope this will help others!
If you want FFMPEG with libX264 support, use this project - just perfect.
https://github.com/hiteshsondhi88/ffmpeg-android/
I've been tryin' to compile x264 for Android with Thread Support...But with no success...
I've managed to compile the same without thread support...The configure command is as follows :
./configure --prefix=$PREFIX \
--enable-pic \
--host=arm-linux \
--disable-cli \
--cross-prefix=$PREBUILT/bin/arm-linux-androideabi- \
--sysroot=$PLATFORM
where PREBUILT=$NDK/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86 and
PLATFORM=$NDK/platforms/android-14/arch-arm
I've also tried with and without the option --enable-static and extra-ldflags="-lpthread", but when attempted make it ends with errors.
Is there any way to accomplish the above said...?
The error that seemed to appear in config.log in context to thread support was cannot find lpthread...
That got resolved by manually removing the -lpthread from the configure file.
But then the configuration started failing at the test that included the struct cpu_set_t and CPU_COUNT()...
Seems that certain libc functions and definitions are not included in the code provided with Android NDK (R8D)...In the above case CPU_COUNT() and the definition for struct cpu_set_t...
The workaround for the above was to patch sched.h with the latest version...
There are a few bug reports in the Android Issue List describing the same problem which would hopefully be addressed in the next NDK release...
Also x264 could be compiled to include the " ARM Support Feature " by including the option --extra-cflags="-mfloat-abi=softfp"...
I'm trying to build all-in-one static binary of FFMPEG with NDK r7b and everything works fine untill i try to build it with RTMP support.
I'm usind sources from https://github.com/guardianproject/android-ffmpeg with librtmp2.4 and custom config like this
.configure \
--target-os=linux \
--cross-prefix=arm-linux-androideabi- \
--arch=arm \
--sysroot=/home/andrey/android-ndk-r7b/platforms/android-3/arch-arm \
--enable-static \
--disable-shared \
--disable-symver \
--enable-small \
--disable-devices \
--disable-avdevice \
--enable-gpl \
--enable-librtmp \
--prefix=../build/ffmpeg/armeabi \
--extra-cflags=-I../rtmpdump/librtmp \
--extra-ldflags=-L../rtmpdump/librtmp \
and rtmpdump directory lays on the same level as ffmpeg.
As i understand last two strings in my config says where compiler may find sources of librtmp.
But all i get is ERROR: librtmp not found
I'm not expereienced with NDK and obviosly i missing some important part but i can't find it by myself.
This is challenging, but I think I have a solution. The problem at configure-time is that FFmpeg wants to detect a proper librtmp installation via the pkg-config management system.
I'm assuming your have successfully cross-compiled librtmp in the directory referenced by ../rtmpdump. Edit the FFmpeg configure script and search for the line:
enabled librtmp && require_pkg_config librtmp librtmp/rtmp.h RTMP_Socket
Comment that out (put a '#' at the front of the line). Now, re-run configure, only with these modifications:
--extra-cflags="-I/full/path/to/rtmpdump"
It may help to have an absolute path here. Also, omit /librtmp/ at the end since the #include directives already prefix the header files with librtmp/. Next:
--extra-ldflags="-L/full/path/to/rtmpdump -lrtmp"
Again, absolute path, and specify the library to link against since we commented out that logic via configure.
Now, configure should succeed and the cross-compilation should also be happy. The final ffmpeg binary should report the family of RTMP modules under protocols:
ffmpeg -protocols
[...]
rtmp
rtmpe
rtmps
rtmpt
rtmpte
Note that I don't have an NDK dev environment to test this on. But I tested on my desktop Ubuntu system by compiling librtmp (without the package being installed via pkg-config) and then performing the above steps.