HydrogenAudio

Lossy Audio Compression => MP3 => MP3 - Tech => Topic started by: darkbyte on 2013-05-23 19:32:01

Title: Algorithm to cut mp3 into fully decodable segments
Post by: darkbyte on 2013-05-23 19:32:01
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.
Title: Algorithm to cut mp3 into fully decodable segments
Post by: darkbyte on 2013-05-23 23:34:06
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! (http://blog.bjrn.se/2008/10/lets-build-mp3-decoder.html)
Title: Algorithm to cut mp3 into fully decodable segments
Post by: 2Bdecided on 2013-05-24 10:15:26
You know that, even without the bitreservoir, the decoded segments must overlap in the time domain?

Cheers,
David.
Title: Algorithm to cut mp3 into fully decodable segments
Post by: darkbyte on 2013-05-24 12:06:58
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.
Title: Algorithm to cut mp3 into fully decodable segments
Post by: Sebastian Mares on 2013-05-24 13:59:24
http://audiocogs.org/codecs/mp3/ (http://audiocogs.org/codecs/mp3/)