Mix two audio files using ffmpeg on android platform - android

I am trying to mix two sound files(1. a background music 2.a recording file or a mp3 file) into a single one in android platform.
I setup the Android NDK platform for my project and done with compiling the ffmpeg library and generated the required SO file, now i want to use the amerge function( http://ffmpeg.org/ffmpeg-filters.html#amerge )in android but i don't know how to implement this command in android,I am having not much idea on Android NDK level coding. So any help, any idea will be appreciated.
Note: If you require more info to answer or any doubt in understanding this question feel free to ask, i'll be happy to share more info.

If you are not familiar with FFMPEG, you can compile a binary 'ffmpeg' and use standard command line by Runtime.getRuntime().exec("...");

Related

What is the difference between FFmpeg Android and FFmpeg Android Java?

I'm trying to use FFmpeg in a new app and found these two repositories on GitHub: http://hiteshsondhi88.github.io/ffmpeg-android/ and http://hiteshsondhi88.github.io/ffmpeg-android-java/.
What are their differences? I mean, Android NDK is just a way to put native code together with your Java code, right? If so, using FFmpeg-android as a shared native library and using FFmpeg-android-java which seems to be a java library that encapsulates calls to the shared native library, are the same thing. Or am I wrong?
Thank you
The second one includes a full android project and precompiled libraries. The first one is only a bunch of shell scripts that will download and compile different tools (including ffmpeg) using the NDK that you provide.

android sound overlap command line ffmpeg not working

I want to mix(not concatenate) 2 audio files in android. For ex : first file has audio and second file has voice. I want to mix these 2 files and generate output file who have music and voice playing simultaneously.
I know about ffmpeg. i have compile ffmpeg using android NDK. but i do not know how to run ffmpeg command using android
other way instead of ffmpeg is also ok.
Thanks a lot..
Check out those resources for Audio/Video tasks with FFmpeg for Android:
Tutorial to compile FFmpeg for Android:
http://www.roman10.net/how-to-build-ffmpeg-with-ndk-r9/
FFMpeg API examples:
http://ffmpeg.org/doxygen/trunk/examples.html
Also if you search github for FFmpeg and Android you'll find a lot of resources.
Hope this helps,
Cheers.

Running FFMPEG in Android [duplicate]

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.

How can I make 3gp video with mp3 audio file and images?

I am trying to create a 3gp video file by combining an mp3 audio clip and an image for my android application. That is:
mp3 + image = 3gp video clip.
I did so much research on this but found that help available was limited.
Please let me know how to do this.
If you are looking to do that outside of your application then check out this post which gives ffmpeg command that can be used to achieve the same.
Also ffmpeg can also be compiled for android and used using the JNI as discussed in this post.
copying the best answer for quick reference:
Here are the steps I went through in getting ffmpeg to work on Android:
Build static libraries of ffmpeg for Android. This was achieved by
building olvaffe's ffmpeg android port (libffmpeg) using the Android
Build System. Simply place the sources under /external and make
away. You'll need to extract bionic(libc) and zlib(libz) from the
Android build as well, as ffmpeg libraries depend on them.
Create a dynamic library wrapping ffmpeg functionality using the
Android NDK. There's a lot of documentation out there on how to work with the
NDK. Basically you'll need to write some C/C++ code to export the
functionality you need out of ffmpeg into a library java can
interact with through JNI. The NDK allows you to easily link against
the static libraries you've generated in step 1, just add a line
similar to this to Android.mk: LOCAL_STATIC_LIBRARIES := libavcodec
libavformat libavutil libc libz
Use the ffmpeg-wrapping dynamic library from your java sources. There's enough documentation on JNI out there, you should be fine.
Regarding using ffmpeg for playback, there are many examples (the ffmpeg binary itself is a good example), here's a basic tutorial. The best documentation can be found in the headers.
The process is called transcoding. Pointers:
convert avi to 3gp using ffmpeg
FFMPEG on Android
Compile a port of ffmpeg to android. You'll get an ffmpeg executable file, put in your app. Setup you app to extract it in its data directory and mark it as executable. Then use it with ffmpeg command line options.
Build a wrapper JNI class, if you need to call it from java code only.

How can I get Vorbis libraries on Android?

OK, i've spent most of the day trying to do this, and I figure I've got to be missing something fairly obvious.
Vorbis files are apparently natively supported on the Android SDK. Is there any way to access these libraries as a developer.
Situation: I've got a project that uses the libvorbis and libogg libraries, to load an ogg file. The whole thing compiles and works fine on OSX, linux, iOS etc. and i was trying to port it to android.
Using the NDK to compile the project, i get the error:
fatal error: vorbis/codec.h: No such file or directory
compilation terminated.
(I assume it would carry on to say that it can't find vorbisfile.h)
Question 1: Can access the vorbis API in C on Android? Or indeed, is there any Vorbis API?
Without too much effort, i stumbled across Tremor and Tremolo - ARM vorbis libraries, but I can't find any information on how to get them to compile using the Android SDK.
Question 2: Can someone offer any help with this?
Let me know if i can provide any other information to help.
You might look at android/ffmpeg/x264 project as an example. x264 is not ogg/vorbis, but it is a clear example of linking ffmpeg with adjunct libs in android build and link scenario.
Note: this will take quite a bit of time to work thru.
If you understand the example of building with x264, then you should be able to swap in obb/vorbis libs in place of x264 and get it all to link on an android build.
This assumes you are good with the NDK and cross toolchains and with git projects and sub-modules (x264 , ogg, vorbis)
maybe you can use the vorbis-java-1.0.0-beta of Xiph.org, this is a java package, you can port it to Android.

Categories

Resources