a-schild / jave2

The JAVE (Java Audio Video Encoder) library is Java wrapper on the ffmpeg project
GNU General Public License v3.0
1.28k stars 249 forks source link

The example in readme doesn't work (Exit code of ffmpeg encoding run is 69) #206

Closed kimyuil closed 2 years ago

kimyuil commented 2 years ago

hello.

The example code in the readme is not working properly

I ran the code in spring boot.

pom.xml

<dependency>
      <groupId>ws.schild</groupId>
      <artifactId>jave-all-deps</artifactId>
      <version>3.3.1</version>
    </dependency>

MainApplication.java

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?

thank you. @a-schild

a-schild commented 2 years ago

This looks strange to me, since your source file is wav

attrs.setInputFormat("mp3");

If it still fails, please increase log level, so we see what happens

kimyuil commented 2 years ago

Thank you! It works.