问题AAC JAAD JAVA-低质量的音频

时间:2018-11-05 00:03:53

标签: java audio streaming aac

我正在使用JAVA JAAD Sound Libraryhttp://jaadec.sourceforge.net/info.php)0.8.4版通过URL流执行AAC / AACPlus音频接收测试,但是音频质量较低比广播。 我想知道是否有人对它会有什么想法?

这是我正在使用的代码。

 private static void decodeAndPlayAAC() {
    SourceDataLine line = null;
    byte[] b ;
    final URL url;

    try {

        /* Link AACPlus Streaming Test */
        url = new URL("https://audio7.97fm.com.br/energia");


        ADTSDemultiplexer adts = new ADTSDemultiplexer(url.openStream());
        byte[] decoderSpecificInfo = adts.getDecoderSpecificInfo();
        byte[] frame;
        final SampleBuffer buf = new SampleBuffer();
        Decoder dec = new Decoder(decoderSpecificInfo);
        dec.getConfig().setSBREnabled(false);

        while((frame = adts.readNextFrame())!=null) {

            dec.decodeFrame(frame, buf);

            //the aacFrame array contains the AAC frame to decode
            byte[] audio = buf.getData(); //this array contains the raw PCM audio data

            if(line == null) {
                final AudioFormat aufmt = new AudioFormat(adts.getSampleFrequency(), buf.getBitsPerSample(), 2, true, buf.isBigEndian());
                System.out.println(adts.getSampleFrequency() + "" + buf.getBitsPerSample()+ ""+ "" + 2 + "" + true + "" + buf.isBigEndian());

                line = AudioSystem.getSourceDataLine(aufmt);
                line.open(aufmt);
                line.start();
            }

            line.write(audio, 0, audio.length);
        }
    } catch (LineUnavailableException | IOException e) {
        System.out.println(e);
    } finally {
        if(line!=null) {
            line.stop();
            line.close();

        }
    }
}

public static void main(String[] args) throws Exception {
      decodeAndPlayAAC();

}

音频和AM广播质量和问题不在计算机或链接上。您可以通过直接在浏览器中打开AAC链接进行检查。有人可以提供解决方案还是替代方案?

0 个答案:

没有答案