Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems decoding live mp3 stream #18

Open
DeusExLibris opened this issue Jan 27, 2016 · 1 comment
Open

Problems decoding live mp3 stream #18

DeusExLibris opened this issue Jan 27, 2016 · 1 comment

Comments

@DeusExLibris
Copy link

In order minimize the latency of a live stream being captured on one system and sent to one or more "listeners", I integrated the aurora-websockets library as a source and wanted to use this code to decode and play the mp3 stream.

Since the stream is live (encoded at 44.1k sample rate, 112k bitrate, mpeg1 layer 3), the data is received over websockets in "packets" of 3-4 frames approximately every 100ms. The decoder will process each packet in around 10ms. Because Layer3#decode looks for the next frame before decoding the current frame, the last frame of each packet will generate an underflow error and consequently skip that frame.

The result is stuttering or warbling caused by missing frame. In addition, the audio that makes it into BufferList in Queue is missing several frames per second of audio and thus consumes the Queue faster than realtime, causing the audio device to stop after several seconds.

I tried altering the logic in Layer#decode to not throw and error if there is no additional frame, but that caused the decoder to stop decoding at all. I have had to stop working on this as it would require an unknown amount of effort to resolve this and so I am looking at alternatives. However, I thought you might want this information. I am also willing to create a pull request for the code I changed, but only if it is something you would like to pursue further.

I have attached an image of a log analysis I did that clearly shows the issue.

aurora data analysis

@DeusExLibris
Copy link
Author

As it turns out, I had to revisit this as other options were not viable. In doing so, I managed to address this issue I raised above. I only fixed it in layer3.js, so it might be an issue in the decoder for other mpeg layers. I will create a pull request with the updates this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant