I am working on programmatically removing/redacting parts of an .mp3 audio file. An example scenario is to mute/ remove the audio from 1:00 - 2:00 in a 3 minute (0:00 - 3:00) audio file. Do we have any libraries that can be useful for this scenario?
I know how to achieve this for .wav audio files using the Javax Sound API (package: javax.sound
), but it looks like this API doesn't support .mp3 files
This is how I am thinking to achieve it technically if I were to work with .wav
- The audio is composed as frames. Each frame represent a time slot. Use the
AudioInputStream read()
method to convert audio file to raw audio data (byte[]
) - Find the frame which represents the start time slot (Using the
audioInputStream.getFrameLength()
andaudioInputStream.getFrameRate()
APIs) - Find the frame which represents the end time slot (Using the
audioInputStream.getFrameLength()
andaudioInputStream.getFrameRate()
APIs) - Remove the frames between the start and end time slots in the array
- Convert the byte array to the
AudioInputStream
-AudioSystem.getAudioInputStream(ByteArrayInputStream)
References-
AudioInputStream
AudioSystem