content: /*
   * This file is part of the zyan/wework-msgaudit.
   *
   * (c) 读心印 <aa24615@qq.com>
   *
   * This source file is subject to the MIT license that is bundled
   * with this source code in the file LICENSE.
   */
  
  
  package com.php127.wework.utils;
  
  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 Audio {
  
      public static void toMp3(String sourcePath, String targetPath) {
  
          File source = new File(sourcePath);
          File target = new File(targetPath);
          AudioAttributes audio = new AudioAttributes();
          audio.setCodec("libmp3lame");
          EncodingAttributes attrs = new EncodingAttributes();
          attrs.setFormat("mp3");
          attrs.setAudioAttributes(audio);
          Encoder encoder = new Encoder();
          try {
              encoder.encode(source, target, attrs);
          } catch (Exception e){
              e.printStackTrace();
          }
      }
  }
  