Skip to content

Instantly share code, notes, and snippets.

@ChangJoo-Park
Created November 1, 2013 06:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChangJoo-Park/7261658 to your computer and use it in GitHub Desktop.
Save ChangJoo-Park/7261658 to your computer and use it in GitHub Desktop.
Using JAVE(Java Audio Video Encoder) example add external library jave 1.0.2 version
package jave_example;
import it.sauronsoftware.jave.AudioAttributes;
import it.sauronsoftware.jave.Encoder;
import it.sauronsoftware.jave.EncoderException;
import it.sauronsoftware.jave.EncodingAttributes;
import it.sauronsoftware.jave.InputFormatException;
import java.io.File;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
File source = new File("1.mp4");
File target = new File("target.mp3");
AudioAttributes audio = new AudioAttributes();
audio.setCodec("libmp3lame");
audio.setBitRate(new Integer(128000));
audio.setChannels(new Integer(2));
audio.setSamplingRate(new Integer(44100));
EncodingAttributes attrs = new EncodingAttributes();
attrs.setFormat("mp3");
attrs.setAudioAttributes(audio);
Encoder encoder = new Encoder();
try {
encoder.encode(source, target, attrs);
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InputFormatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (EncoderException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
@westlinkin
Copy link

Hi, I'm using it in Android, but some error happened.
Here is the logcat:

10-09 19:43:15.105  19646-19646/com.team_wye.videoparser W/System.err﹕ it.sauronsoftware.jave.EncoderException: java.io.IOException: Error running exec(). Command: [/data/data/com.team_wye.videoparser/cache/jave-1/ffmpeg, -i, /storage/emulated/0/DCIM/Camera/qw.mp4, -vn, -acodec, libmp3lame, -ab, 128000, -ac, 2, -ar, 44100, -f, mp3, -y, /storage/emulated/0/DCIM/Camera/1.mp3] Working Directory: null Environment: null
10-09 19:43:15.105  19646-19646/com.team_wye.videoparser W/System.err﹕ at it.sauronsoftware.jave.Encoder.encode(Encoder.java:831)
10-09 19:43:15.105  19646-19646/com.team_wye.videoparser W/System.err﹕ at it.sauronsoftware.jave.Encoder.encode(Encoder.java:713)
10-09 19:43:15.105  19646-19646/com.team_wye.videoparser W/System.err﹕ at team_wye.com.videoparser.MainActivity.onCreate(MainActivity.java:44)
10-09 19:43:15.105  19646-19646/com.team_wye.videoparser W/System.err﹕ at android.app.Activity.performCreate(Activity.java:5720)
10-09 19:43:15.105  19646-19646/com.team_wye.videoparser W/System.err﹕ at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1102)
10-09 19:43:15.105  19646-19646/com.team_wye.videoparser W/System.err﹕ at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2208)
10-09 19:43:15.105  19646-19646/com.team_wye.videoparser W/System.err﹕ at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2317)
10-09 19:43:15.105  19646-19646/com.team_wye.videoparser W/System.err﹕ at android.app.ActivityThread.access$800(ActivityThread.java:143)
10-09 19:43:15.105  19646-19646/com.team_wye.videoparser W/System.err﹕ at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1258)
10-09 19:43:15.105  19646-19646/com.team_wye.videoparser W/System.err﹕ at android.os.Handler.dispatchMessage(Handler.java:102)
10-09 19:43:15.105  19646-19646/com.team_wye.videoparser W/System.err﹕ at android.os.Looper.loop(Looper.java:135)
10-09 19:43:15.105  19646-19646/com.team_wye.videoparser W/System.err﹕ at android.app.ActivityThread.main(ActivityThread.java:5070)
10-09 19:43:15.105  19646-19646/com.team_wye.videoparser W/System.err﹕ at java.lang.reflect.Method.invoke(Native Method)
10-09 19:43:15.105  19646-19646/com.team_wye.videoparser W/System.err﹕ at java.lang.reflect.Method.invoke(Method.java:372)
10-09 19:43:15.105  19646-19646/com.team_wye.videoparser W/System.err﹕ at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:836)
10-09 19:43:15.105  19646-19646/com.team_wye.videoparser W/System.err﹕ at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:631)
10-09 19:43:15.106  19646-19646/com.team_wye.videoparser W/System.err﹕ Caused by: java.io.IOException: Error running exec(). Command: [/data/data/com.team_wye.videoparser/cache/jave-1/ffmpeg, -i, /storage/emulated/0/DCIM/Camera/qw.mp4, -vn, -acodec, libmp3lame, -ab, 128000, -ac, 2, -ar, 44100, -f, mp3, -y, /storage/emulated/0/DCIM/Camera/1.mp3] Working Directory: null Environment: null
10-09 19:43:15.106  19646-19646/com.team_wye.videoparser W/System.err﹕ at java.lang.ProcessManager.exec(ProcessManager.java:211)
10-09 19:43:15.106  19646-19646/com.team_wye.videoparser W/System.err﹕ at java.lang.Runtime.exec(Runtime.java:173)
10-09 19:43:15.106  19646-19646/com.team_wye.videoparser W/System.err﹕ at java.lang.Runtime.exec(Runtime.java:128)
10-09 19:43:15.106  19646-19646/com.team_wye.videoparser W/System.err﹕ at it.sauronsoftware.jave.FFMPEGExecutor.execute(FFMPEGExecutor.java:103)
10-09 19:43:15.106  19646-19646/com.team_wye.videoparser W/System.err﹕ at it.sauronsoftware.jave.Encoder.encode(Encoder.java:829)
10-09 19:43:15.106  19646-19646/com.team_wye.videoparser W/System.err﹕ ... 15 more
10-09 19:43:15.106  19646-19646/com.team_wye.videoparser W/System.err﹕ Caused by: java.io.IOException: Permission denied
10-09 19:43:15.106  19646-19646/com.team_wye.videoparser W/System.err﹕ at java.lang.ProcessManager.exec(Native Method)
10-09 19:43:15.106  19646-19646/com.team_wye.videoparser W/System.err﹕ at java.lang.ProcessManager.exec(ProcessManager.java:209)
10-09 19:43:15.106  19646-19646/com.team_wye.videoparser W/System.err﹕ ... 19 more

Can you tell me where I did wrong? Thanks in advance.

@muhammad-umair-khan
Copy link

Have you solved this issue?Because i am also facing the same problem.If u have resolved it then kindly help me how to solve it
Thanx

@liukuo362573
Copy link

I also face the same problem,some people said because of permission

@pierrealexvezinet
Copy link

Hi have you resolved the problem, i'have the same error ! Thanks

@RichaGarg123
Copy link

Hi, What changes need to be made in order to convert .wav to .mp3 ? Tried doing that I am getting an error saying could not find codec parameters

@cinder92
Copy link

cinder92 commented Feb 7, 2017

hello @westlinkin did you find how to solve that error? i have the same!

@Drabu
Copy link

Drabu commented May 30, 2018

Same issue with permission

@TheRiotJoker
Copy link

4 years later, same issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment