使用java包:
开发环境:java语言,jdk1.7 win 10。两个方法都好使。
服务器:java,jdk1.7 windows server 2008 腾讯云。服务器两个方法都报错。
方法一:
File mp3 = new File(mp3filepath);
File pcm = new File(pcmfilepath);
//原MP3文件转AudioInputStream
AudioInputStream mp3audioStream =AudioSystem.getAudioInputStream(mp3);
服务器报错:javax.sound.sampled.UnsupportedAudioFileException: could not get audio input stream from input file
方法二:
MpegAudioFileReader mp = new MpegAudioFileReader();
AudioInputStream in = mp.getAudioInputStream(mp3);
AudioFormat baseFormat = in.getFormat();
targetFormat = new AudioFormat(
AudioFormat.Encoding.PCM_SIGNED,//encoding
baseFormat.getSampleRate(), //sampleRate
16,//sampleSizeInBits
baseFormat.getChannels(),//channels
baseFormat.getChannels() * 2,//frameSize
baseFormat.getSampleRate(), //frameRate
false);
audioInputStream = AudioSystem.getAudioInputStream(targetFormat, in);
服务器报错: java.lang.IllegalArgumentException: Unsupported conversion: PCM_SIGNED 16000.0 Hz, unknown bits per sample, mono, unknown frame size, little-endian from MPEG2L3 16000.0 Hz, unknown bits per sample, mono, unknown frame size, 27.777779 frames/second,
求大神指导!