java wav 切割,如何分割WAV文件到使用Java更小的块?

本文介绍如何使用Java通过AudioInputStream和AudioSystem API读取100MB大小的WAV文件,将其按每2秒切分成小块,适合处理大型音频数据。涉及音频格式处理、采样率计算和文件写入细节。
摘要由CSDN通过智能技术生成

I have a very huge WAV file, about 100MB in size. I would like to use Java to read this wav file and split it into smaller chunks for every 2 seconds of audio.

Is it possible to do this in Java? Could you please suggest me an API with which I can achieve it?

Thanks in advance,

Snehal

解决方案

You can use AudioInputStream and its AudioFileFormat member (which contains an AudioFormat instance) to know what to write (format, sample rate), you can use AudioSystem to write it.

Based on the sample rate of the format you can find out how many bytes of audio are 2 seconds, and go on a loop of reading that many bytes from the AudioInputStream, writing them to a new file.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值