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.
Related
I am trying to use FFMPEG library for Video compression on Android.
I've compiled the library using : http://bambuser.com/opensource and https://www.quora.com/What-are-the-steps-for-integrating-FFMPEG-on-Android
Now next step is NDK build of this. But I am not sure what all will go as LOCAL_SRC_FILES, LOCAL_LDLIBS and LOCAL_C_INCLUDES.
Apart from that what function should be called for compression in this library.
Please suggest.
For ffmpeg use on Android (or other platforms) there are a number of common approachs you can take:
invoke the command line from your program via EXEC command (has some limitations and drawbacks)
use a wrapper around the ffmpeg command line C program
Directly use the ffmpeg libraries, or more accurately the libraries that ffmpeg uses
The wrapper approach may be the easiest is you simply want to get the functionality working quickly.
There are several fairly well used wrappers available on GitHub - the ones below are particularly well featured and documented (note, I have not used these as they were not so mature when I was looking at this previously, but if I was doing something like this again now I would definitely build on one of these):
http://writingminds.github.io/ffmpeg-android-java/
https://github.com/guardianproject/android-ffmpeg
Using one of the well supported and used libraries will take care of some common issues that you might otherwise encounter - having to load different binaries for different processor types, and some tricky issues with native library reloading to avoid crashes on subsequent invocations of the wrapper.
Because this approach uses the standard ffmpeg cmd line syntax for commands it also means you should be able to search and find help easily on multiple different operations (as anyone using ffmpeg in 'normal' model will use the same syntax for the ffmpeg command itself).
I use FFmpeg2.3.3 and SDL2-2.0.3 to develop an Android video player.I built the .apk success,but when I ran it,it's an error at SDL_init().I got message by SDL_error().The message was:
SDL_Init(14144): Application didn't initialize properly, did you include SDL_main.h in the file containing your main() function?
but I have #include "SDL_main.h" in the source.
Are you sure that ffmpeg was built with a cross-compiled SDL library? Does it show
"SDL support yes" in the config.log? I have been struggling with this myself. If it does indeed say "SDL support yes" can you tell me how you did it?
another way to test is to see if you can build the ffplay binary. If you can, then again, I would really appreciate it you shared your setup and config information. I have been struggling for awhile with this.
If you are correctly building ffmpeg with a cross-compiled android compatible SDL2 library then make sure your app is using the header files from the same cross-compiled SDL2 Library.
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("...");
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.
I need gstreamer for decoding H.264 video on rtp, so I used the SDK from gstreamer.com. But I found that something I need is not included, such as 264depay, x264dec, etc.. I found gst-plugins on http://cgit.freedesktop.org/gstreamer/gst-plugins-good/, I think I need to compile it in Android form, and it has Android.mk inside. What should I do to deal with it? Tried execute ndk-build, but failed.
Many thanks.