简体   繁体   中英

cut audio data in the stream with java

i know how to read bytes from file and save, but how can i read seconds from an audio file and save in a new file? is there any method for this?how many bytes contains 1 second?maybe it sounds stupied but i have no idea.

ps i want to record only 20 seconds from an audio file and save this 20 seconds to another file.. i know how to write to a new file, but how to write only some part(20 seconds) of an audio file

thx in advance roni

It depends on the format you are using for capturing the audio stream. For example if your are using raw (uncompressed) audio, 16 bits per sample, stereo, and 44Khz (which means 44100 samples per second), then you need to store 2*(16/8)*44100 bytes per second. Additionally, if you want to write some kind of standard file that other applications can read, you will need to decide on a container format. For raw (uncompressed) audio, Microsoft wave files are commonly used, and it will require you to write a header with some metadata at the begining of your file.

Update:

You can try using AudioFileWriter .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM