Hey <> I need to trim / cut / edit a audio file in my app, I tried to use ffmpeg but I don\'t know how to install this library or how to even use it.. so , can someone give m
There are a number of open source Android ffmpeg projects, the one which appears to be most used or discussed being:
https://github.com/guardianproject/android-ffmpeg
This provides ffmpeg on an Android platform and a related project provides a Java wrapper (using the Runtime.getRuntime().exec approach, not JNI as I thought originally) to allow you use it from a regular Java Android app:
https://github.com/guardianproject/android-ffmpeg-java
The top project above includes build instructions and some examples to test the installation.
Some examples of the Java Wrapper project method declarations that are using ffmpeg binary are shown below. You can see the full code in the file 'android-ffmpeg-java/src/org/ ffmpeg/android/FfmpegController.java' in the android-ffmpeg-java project you have downloaded:
public void extractAudio (Clip mdesc, String audioFormat, File audioOutPath, ShellCallback sc) throws IOException, InterruptedException
{ ...
public void concatAndTrimFilesMPEG (ArrayList<Clip> videos,Clip out, boolean preConvert, ShellCallback sc) throws Exception
{ ...
public Clip convertToMPEG (Clip mediaIn, String outPath, ShellCallback sc) throws Exception
{ ...
If you take a look at these you should be able to see how to add one that does exactly what you require. Essentially, these methods call the cmd line ffmpeg with the parameters required for a specific task, using the Runtime.getRuntime().exec function.
A couple of things to be aware of, from past experience using Runtime.getRuntime().exec on Android: