try {
ConvertProgressListener listener = new ConvertProgressListener();
File source = new File("d:\\wavTest\\piano.wav");
File target = new File("d:\\wavTest\\piano.mp3");
AudioAttributes audio = new AudioAttributes();
audio.setCodec("libmp3lame");
audio.setBitRate(128000);
audio.setChannels(2);
audio.setSamplingRate(44100);
EncodingAttributes attrs = new EncodingAttributes();
attrs.setInputFormat("mp3");
attrs.setAudioAttributes(audio);
//Encoder encoder = new Encoder();
Encoder encoder = new Encoder();
encoder.encode(new MultimediaObject(source), target, attrs, listener);
}catch (Exception e){
e.printStackTrace();
}
ConvertProgressListener.java
public class ConvertProgressListener implements EncoderProgressListener {
public ConvertProgressListener() {
}
public void message(String m) {
}
public void progress(int p) {
double progress = p / 1000.00;
System.out.println(progress);
}
public void sourceInfo(MultimediaInfo m) {
}
}
I proceeded with a piano.wav file in the D drive.
By the printStackTrace, I could see the log.
1.0
2022-05-17 14:41:10.894 ERROR 156 --- [ restartedMain] ws.schild.jave.Encoder : Process exit code: 69 to piano.mp3
ws.schild.jave.EncoderException: Exit code of ffmpeg encoding run is 69
at ws.schild.jave.Encoder.encode(Encoder.java:638)
at ws.schild.jave.Encoder.encode(Encoder.java:481)
at ws.schild.jave.Encoder.encode(Encoder.java:351)
at com.example.excel.ExcelApplication.main(MainApplication.java:82)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
The log "1.0" at the top seems to be caused by the ConvertProgressListener.
I think there is no problem with the wav file.
Is there something wrong with the encoding settings?
Is my maven installation wrong?
hello.
The example code in the readme is not working properly
I ran the code in spring boot.
pom.xml
MainApplication.java
ConvertProgressListener.java
I proceeded with a piano.wav file in the D drive.
By the printStackTrace, I could see the log.
The log "1.0" at the top seems to be caused by the ConvertProgressListener.
I think there is no problem with the wav file. Is there something wrong with the encoding settings? Is my maven installation wrong?
thank you. @a-schild