Running FFMPEG in Android [duplicate] - android

I am trying to compile ffmpeg for a android. I have found several posts on this theme but non of these seems to work. If tried to build ffmpeg like it is posted on [1]. Did anybody successfully compile ffmpeg using theses tutorial?
I am not sure how to realize step 4 to 5.
STEP4: Configuring ...
STEP5: cd to your NDK root dir, type make TARGET_ARCH=arm APP=ffmpeg-org
It seems to me that building an application like it is explained in the tutorial in step 5 need some previous steps. Unfortunately I have no app in the folder to make. I am using the current android ndk release 3 and checked out the actual ffmpeg releases from [3] and [4]. I am thankful for every advice.
[1] http://slworkthings.wordpress.com/
[2] http://gitorious.org/~olvaffe/ffmpeg/ffmpeg-android
[3] http://ffmpeg.org/download.html

After looking around the net. The only working solution I found is supplied by Bambuser which ported ffmpeg to use in their android application.
Code is here: http://bambuser.com/opensource
Basically you copy the .so files to your jni/lib directory, along with any .h files you might need, create a JNI wrapper through javah, and it works.
EDIT:
Since this post was written a few packaged ffmpeg projects for android surfaced, one of the easiest ones to compile and use is here: https://github.com/guardianproject/android-ffmpeg .
It takes the approach of statically compiling a binary (not a library) that is ran through shell command in run time. Search github for 'android ffmpeg' for forks and related projects.
Did not find a well packaged method based JNI implementation, though.

I found a guide on ffmpeg on android here:
http://rxwen.blogspot.com/2010/05/use-ffmpeg-to-setup-streaming-server-on.html
He explains in another post how he got to do native programming on android to install ffmpeg. Hope it helps.

I will provide a more updated list of sources which will explain how to build and, in some cases, even use FFMPEG on Android.
This is the guide I liked the most: http://www.roman10.net/how-to-build-ffmpeg-with-ndk-r9/
If you need more options, you can take a look at these, which are equally good:
https://github.com/guardianproject/android-ffmpeg
https://github.com/halfninja/android-ffmpeg-x264
https://vec.io/posts/how-to-build-ffmpeg-with-android-ndk

In NDK r3, when you use the make command, the NDK will simply use the name of the folder in the "apps" folder for the name of your project. This assumes that you have your FFmpeg source files and android.mk somewhere within NDK/apps/ffmpeg-org/jni/
In otherwords, ensure that your foldername is set to ffmpeg-org.
EDIT: You might find it worthwile to use NDK r4 which changes make to ndk-build. In this new NDK, you don't need to have your project set up in any particular way, as ndk-build simply searches your project for Android.mk files to tell it what to compile.

Related

Build cpp code to run FFMPEG command in Anroid after generating .so file

I built FFMPEG so files(libavcode.so, libavfilter.so, libavformat.so,libavutil.so, libswscale.so) by following this tutorial. This tutorial is nice is helpful to build your own .so files as per your library requirement.
Why I am building own one?
I know that there is some already available libraries in github like bravobit's, tanersener's and also microshow's. These all have certain limitations like some of this will not work for target SDK 29 & 30 and tanersener's lib is good but there is problems with -filter_complex command's output and micrshow's lib is crashing in android 10 and 11 beta! So, all have specific problems. So, I am considering to create own one.
What I have and already done
After following tutorial(mention in above) I successfully generated .so files and put it into my App.
Here is the screenshot of which I already done .so files:
So, you can see that I put all files into cpp folder. As per version I only need ARMV7 and AMR64.
What is the problem?
Problem is that I have no idea how to create .cpp file to execute command and what is it actually and how to use it? I also tried some other libraries .c code but it didn't work for me. So, what is the code of cpp which can execute command? Is there any other way of this?
Note of this requirement
We can't run any executable file directly from directory in Android because its restricted in target Android 10 and 11. So, we compulsory need to build native code and call class or it's function.

How to build from src to binary for Android

I want to use some function calls(commands) designed for linux. I can use them by enter the key words in adb(Android CML).
Here I found some works some people did.
wget (because it isn't included in most Android device )
Iperf
But after reading their methods or suggestions, I can only understand that I need to use Android NDK and write the correct makefile. I have no idea about building others source code (most of them are C/C++) for linux(only need to use 'make' command mentioned in their README file). The official NDK document is for Java environment to call C lib mainly.
Are there some HOWTO, courses or suggestions for this. Thanks!
I have compiled single cpp file program. I try to compile a alternative version iperf
https://github.com/tierney/iperf
It seems to be relative to lib ,some header files, and multiple c files. I failed to compile by enter all c files normally. Is there anything I missed?
yeah you need the NDK, it offers an C/C++ compiler for Android.
In general the steps are all the same:
Setting up the NDK (I wrote a small how-to, but it's for Arch-Linux and the fish-shell, Windows how-to)
Adjusting your make file (instead of gcc compiler use Android NDK compiler, and so on)
Remember that Android uses Bionic C library, so only use functions supported by it
Run make, push the program to your device and make it executable
Of course, this is just an overview how it is done. You should try it and then ask specific questions if you run into troubles.
NDK is mostly intended to extend the Java apps, but you can download NDK and create a standalone toolchain from it (see http://www.kandroid.org/ndk/docs/STANDALONE-TOOLCHAIN.html). Now you have a cross-compilation environment which is very similar to standard Linux dev environment.
In addition, for small executables and for testing only, you can also cross-compile and link statically to the libc. This way you don't have to worry about Bionic which could be a loss of time.

p7zip on Android-Extracting 7z archive on Android

I'm writing an Android application that need to extract 7z archives.Pressed for time,I've searching of third-party libraries or source code which can be used in my project.
At first, i find J7zip from http://sourceforge.net/projects/p7zip/files/J7Zip/
After modifying the two sample classes, it works in my project, that's exciting! but the problem was: 1. It would cause out of memory errors when extracting larger archives 2. It only support archives with Copy or LZMA codec. I'am so sad about this...
Then, i find this:"J7zip on Android - Extracting From an Archive and Listing Contents" in StackOverflow. My requirement is seriously similar to this question.As it mentioned andro7z, it contains C/C++ code from: http://sourceforge.net/projects/p7zip/files/p7zip/; I believe this's a good solution for me.
andro7z not contains "How to use" doc and I'm new about JNI, i have no idea about how to modify the andro7z to suit my project. So, anyone had implemented extracting 7z archive with andro7z? Could You share me the demo code or steps to implement this? thanks!
I have finished this project by myself,the classes under folder "jni/7z" and "src" need implemented by yourself;if you need to support encrypted archive, you should call methods in 7z.dll or modify the source code in C/CPP folder, C/CPP are 7z source code.

What is an Android.mk file

A project that I am trying to build has one of these, and I want to know exactly which tools are needed to build the project. I see some reference to NDK when I search but is that the only tool? It appears that this file is making a jar file, I see no reference to native code ( c++ )
The Android.mk files in the SDK samples are required to properly include the samples in the SDK build (if you are actually venturing into that territory). These have no bearing on what you are doing when you use the sample. To the OP, I'm not sure if you are using a sample project, but if you are, you can ignore this file.
the best answer to your question is reading this article:
Android.mk file syntax specification
https://android.googlesource.com/platform/ndk/+/4e159d95ebf23b5f72bb707b0cb1518ef96b3d03/docs/ANDROID-MK.TXT
after reading it you can figure out the idea behind the android.mk file.
cheers
I've seen some of the Android sample code come with an Android.mk file for no apparent reason -- maybe this gets auto-generated upon project creation if you happen to have the NDK installed or something. Android.mk does seem to be an NDK-specific thing.
So if there's really no native code involved, then if you're looking to build from the command line, make sure you have the JDK, Ant, and Android SDK installed.
Then take a look at
http://developer.android.com/guide/developing/projects/projects-cmdline.html#UpdatingAProject
After you run the "android update project ..." step, you should hopefully be able to do an "ant debug" to build the application.

ffmpeg for a android (using tutorial: "ffmpeg and Android.mk")

I am trying to compile ffmpeg for a android. I have found several posts on this theme but non of these seems to work. If tried to build ffmpeg like it is posted on [1]. Did anybody successfully compile ffmpeg using theses tutorial?
I am not sure how to realize step 4 to 5.
STEP4: Configuring ...
STEP5: cd to your NDK root dir, type make TARGET_ARCH=arm APP=ffmpeg-org
It seems to me that building an application like it is explained in the tutorial in step 5 need some previous steps. Unfortunately I have no app in the folder to make. I am using the current android ndk release 3 and checked out the actual ffmpeg releases from [3] and [4]. I am thankful for every advice.
[1] http://slworkthings.wordpress.com/
[2] http://gitorious.org/~olvaffe/ffmpeg/ffmpeg-android
[3] http://ffmpeg.org/download.html
After looking around the net. The only working solution I found is supplied by Bambuser which ported ffmpeg to use in their android application.
Code is here: http://bambuser.com/opensource
Basically you copy the .so files to your jni/lib directory, along with any .h files you might need, create a JNI wrapper through javah, and it works.
EDIT:
Since this post was written a few packaged ffmpeg projects for android surfaced, one of the easiest ones to compile and use is here: https://github.com/guardianproject/android-ffmpeg .
It takes the approach of statically compiling a binary (not a library) that is ran through shell command in run time. Search github for 'android ffmpeg' for forks and related projects.
Did not find a well packaged method based JNI implementation, though.
I found a guide on ffmpeg on android here:
http://rxwen.blogspot.com/2010/05/use-ffmpeg-to-setup-streaming-server-on.html
He explains in another post how he got to do native programming on android to install ffmpeg. Hope it helps.
I will provide a more updated list of sources which will explain how to build and, in some cases, even use FFMPEG on Android.
This is the guide I liked the most: http://www.roman10.net/how-to-build-ffmpeg-with-ndk-r9/
If you need more options, you can take a look at these, which are equally good:
https://github.com/guardianproject/android-ffmpeg
https://github.com/halfninja/android-ffmpeg-x264
https://vec.io/posts/how-to-build-ffmpeg-with-android-ndk
In NDK r3, when you use the make command, the NDK will simply use the name of the folder in the "apps" folder for the name of your project. This assumes that you have your FFmpeg source files and android.mk somewhere within NDK/apps/ffmpeg-org/jni/
In otherwords, ensure that your foldername is set to ffmpeg-org.
EDIT: You might find it worthwile to use NDK r4 which changes make to ndk-build. In this new NDK, you don't need to have your project set up in any particular way, as ndk-build simply searches your project for Android.mk files to tell it what to compile.

Categories

Resources