how to divide an audio file (mp3 or wav) i

2019-09-17 12:19发布

问题:

I have mp3 and wav audio files. I want to divide them into smaller files programmatically.

Is there any easy-to-use Java library I can use to process the audio file, seek the silent segments, and divide the file somewhere in a silent segment?

回答1:

This page: http://www.labbookpages.co.uk/audio/javaWavFiles.html has WavFile class you can use to read wave files (the download link to WavFile.tar.gz is in the top right corner - WavFile.tar.gz). Seeking the silent segments can be done by scanning through the file and finding ranges where the average of the absolute sample values (i.e. ignoring sign) is lower than a certain threshold. Mp3 files are probably most easily processed by converting to wav first, although round-tripping the segments back to mp3 may degrade quality.