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.
Related
anyone know how to merge a single image with already selected video in android through any library because i cannot find any solution for this issue i have checked some libraries such as FFmpeg and OpenCV but they seem not to help in my case
Thanks!
ffmpeg can definitely overlay an image over a video if this is what you are looking for.
The documentation provides some some examples - they key option is 'filter-complex':
ffmpeg -i video.mkv -i image.png -filter_complex '[0:v][1:v]overlay[out]' -map
'[out]' out.mkv
See here for the official documentation: https://ffmpeg.org/ffmpeg.html and look at '-filter_complex filtergraph (global)'
ffmpeg is designed as a command line tool, but there exist 'wrapper' projects to allow it be used from an Android app. A well supported example is below but others exist also:
https://github.com/WritingMinds/ffmpeg-android-java
The above includes a sample APK so you can try out the ffmpeg command you need with that to ensure it works before adding to your own project.
We know ffmpeg to convert an mp3 to wav, as in the following command:
ffmpeg -i testlong.mp3 -f wav output.wav
However, I would like to know how to achieve the above command line function with C language.
ps: I want to achieve in the Android devices, convert audio formats,
in addition to ffmpeg, I do not know what a good solution.
Thanks!
Compile ffmpeg for android
Below link has some way to perform that.
https://trac.ffmpeg.org/wiki/CompilationGuide/Android
Now you can put all code of ffmpeg in JNI folder and use its methods in c to Java methods and use it in java activity.
Other method is just cross compile ffmpeg and install it in android.
then using system() call in java use that ffmpeg -i testlong.mp3 -f wav output.wav
One way is to compile the entire ffmpeg.c file into your application and then generate the command line within your application, then pass it on into ffmpeg's main() (that you will probably rename). The other way is to study the its source code, online tutorials, ... and write your own converter based on that.
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 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.
I want to use ffmpeg library in my Android app to play .ts video file format.I am trying to run sample app given at GitHub Appunite.
So far I have managed to compile ffmpeg library & build .so files.I am working on Ubuntu 10.10 & using NDK r8.
Sample app works fine & plays file formats like .mp4 & .3gp but it doesn't play .FLV & .ts file (which is my requirement).
Whenever I try to play .ts or .FLV files it says "Could not open stream"
In Logcat it shows
E/player.c(28005): player_set_data_source Could not open video file: file:///mnt/sdcard/football.ts (-1094995529: Invalid data found when processing input)
I am trying this for weeks.So far I have not got any way. Please help
Thanks
Issue was with the some ts files but some ts files are working fine.There may be properties differences between ts files.