Skip to main content

Topic: Algorithm to cut mp3 into fully decodable segments (Read 2817 times) previous topic - next topic

0 Members and 1 Guest are viewing this topic.
  • darkbyte
  • [*][*][*]
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.
  • Last Edit: 23 May, 2013, 02:32:55 PM by darkbyte
WavPack -b4x4hc
Opus --cvbr --bitrate 256 --framesize 5

  • darkbyte
  • [*][*][*]
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!
WavPack -b4x4hc
Opus --cvbr --bitrate 256 --framesize 5

  • 2Bdecided
  • [*][*][*][*][*]
  • Developer
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.

  • darkbyte
  • [*][*][*]
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.
  • Last Edit: 24 May, 2013, 07:07:12 AM by darkbyte
WavPack -b4x4hc
Opus --cvbr --bitrate 256 --framesize 5

Algorithm to cut mp3 into fully decodable segments
Reply #4