Recently I was faced with the challenge of implementing a platform for audiobook streaming. "Streaming" seemed to be a very overused word in colloquial speech to me (same as "Artificial Intelligence"). So first I had to figure out what streaming really is and how does it differ from simply embedding the mp3 file on the webpage.
1. File format
Real streaming requires file conversion. After conversion, which will be a topic of another blog post, there is no longer one mp3 file. The conversion generates .m3u8 playlist file which the player requests once at the start of the streaming session and a bunch of .aac files that are short segments of the audio track.
2. Bandwidth usage
The segments of converted audio track are being fetched one by one and when the user clicks pause on the video player, then the segments stop being downloaded. What is more, the user can start playback from any point. How crucial it is if we are talking about audiobook chapters that can last tens of minutes or even hours! The standard progressive download doesn't have such features, so streaming is the only economically viable option if you expect heavy traffic. Services like AWS Cloudfront charge you for the data transfer.
Standard mp3 files can be easily downloaded using third-party browser plugins like Video Downloader. It is not so trivial with the streams. Again, this is very important when it comes to audiobooks, the intellectual property that is highly vulnerable to piracy. Furthermore, as the stream is downloading files incrementally you can prevent access to further listening if, for example, someone else starts using the same account.
Granting access to a stream with a signed cookie with AWS Cloudfront is a topic of another blog post in this series.
You can convert your input file to many bitrates. All this data is stored in the mentioned .m3u8 playlist file. Depending on the available bandwidth the player will automatically choose a segment from an appropriate bitrate. If the user enters the area of a poor Internet connection he can still listen to his audiobook even if the audio quality is a little bit worse. Transitioning between bitrates is seamless.