Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Algorithm to cut mp3 into fully decodable segments (Read 4696 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Algorithm to cut mp3 into fully decodable segments

I'm thinking about writing a HTML5 audio player which uses it's own streaming mechanism to pull audio data on HTTP. The code on the page would download smaller segments of the audio files then decode the audio frames in a JavaScriptNode which this way provides the buffer to the playback engine. The server have to tell the player about the possible segments of the audio file. The playtime doesn't have to be equally distributed among frames.

As i understand mp3 can be cut at any arbitary elementary stream frame and decoders can decode these segments without any problem. However because of the bit reservoir the proceeding frame(s) may refer back to the bits of the previous frame(s). This can introduce audio loss because the next segment may have data which can be only decoded with the data of the previous frame which is not available in the context of the current segment.
So the correct solution would be reordeing each segments bits to contain only bits used in the current segment. I think mp3repacker does something similar to achieve maximum frame dataspace usage.

I wonder how this thing works in the technical perspective. Can somebody suggest me documents describing the logical bitstream of an mp3 file? I've found the MPEG audio format's documentation but this only describes how the elementary stream works and provides information about the MPEG Layer III stream.

Algorithm to cut mp3 into fully decodable segments

Reply #1
I don't know how up to date this document is but this seems like a great start to learn how logical bitstream is organized: Let’s build an MP3-decoder!

 

Algorithm to cut mp3 into fully decodable segments

Reply #2
You know that, even without the bitreservoir, the decoded segments must overlap in the time domain?

Cheers,
David.

Algorithm to cut mp3 into fully decodable segments

Reply #3
You know that, even without the bitreservoir, the decoded segments must overlap in the time domain?

Cheers,
David.

No, i haven't thought about that.
I think i have to look for a Javascript mp3 decoder then and customize it for my needs.