java音频转wav、获取wav时长ITeyesina - 乐橙lc8

java音频转wav、获取wav时长ITeyesina

2019-02-06 09:51:40 | 作者: 辰良 | 标签: 代码,网址,时长 | 浏览: 4738

网址https://www.sauronsoftware.it/projects/jave/download.php下载jar包


转wav代码
File source = new File(tempPath);
File target = new File(targetPath);
AudioAttributes audio = new AudioAttributes();
audio.setCodec("pcm_alaw");
audio.setBitRate(new Integer(64000));
audio.setChannels(new Integer(1));
audio.setSamplingRate(new Integer(8000));
EncodingAttributes attrs = new EncodingAttributes();
attrs.setFormat("wav");
attrs.setAudioAttributes(audio);
Encoder encoder = new Encoder();
encoder.encode(source, target, attrs);


取得wav时长代码

        File source = new File("C:\\22.wav");
        Encoder encoder = new Encoder();
        try {
             MultimediaInfo m = encoder.getInfo(source);
             long ls = m.getDuration();
             System.out.println(ls+" "+ls/1000);
        } catch (Exception e) {
            e.printStackTrace();
        }

 

版权声明
本文来源于网络,版权归原作者所有,其内容与观点不代表乐橙lc8立场。转载文章仅为传播更有价值的信息,如采编人员采编有误或者版权原因,请与我们联系,我们核实后立即修改或删除。

猜您喜欢的文章