Cloud storage provider for music streaming

241
  1. I found two solutions for cloud storage that offer a good price for data transfer. The first option is starting from 5$/mo, 1TB included and 0.01$ / GB for extra traffic. https://www.digitalocean.com/. The second one starts from 9EUR/mo, 1TB included and the cost for any extra traffic is 0.5EUR/TB.

  2. just-audio has support for HLS and MPEG-DASH. Therefore, for the server-side, a good solution is nginx with the rtmp module.

Credits to: https://docs.peer5.com/guides/setting-up-hls-live-streaming-server-using-nginx/

The setup is pretty much straight forward:

git clone https://github.com/sergey-dryabzhinsky/nginx-rtmp-module.git

sudo apt-get install build-essential libpcre3 libpcre3-dev libssl-dev

wget http://nginx.org/download/nginx-1.19.0.tar.gz
tar -xf nginx-1.19.0.tar.gz
cd nginx-1.19.0

./configure --with-http_ssl_module --add-module=../nginx-rtmp-module
sudo make install

Then, for the configuration file follow the instructions accesing the above link.

In order to obtain the .ts chunks, I used ffmpeg with the following command.

ffmpeg -i example.mp3 -c:a libmp3lame -b:a 128k -map 0:0 -f segment -segment_time 10 -segment_list outputlist.m3u8 -segment_format mpegts output%03d.ts

Move the output files in the song's folder from the configured hls_path.

Because only https is supported (http is supported only for testing purpose, not recommended in production), the final step is to register a SSL certificate and for this I used Let's encrypt. https://letsencrypt.org/getting-started/ If you have ssh access, cerbot is a good option https://certbot.eff.org/.

Finally everything can be tested directly from the app or via a HLS client: http://players.akamai.com/players/hlsjs

Paste the link of the song in the akami player and it should work. Example: https://your_domain.com/hls/song_name/outputlist.m3u8

Share:
241
Alexandru Rusu
Author by

Alexandru Rusu

πŸ‘‹ I am a Senior Flutter Developer / Consultant / Contractor / Freelancer 𝐰𝐒𝐭𝐑 πŸ•+ 𝐲𝐞𝐚𝐫𝐬 𝐨𝐟 𝐞𝐱𝐩𝐞𝐫𝐒𝐞𝐧𝐜𝐞, using my expertise to identify & implement clients’ needs with regards to their software solutions. About my skills: β€’ Cross-Platform: Flutter, Kivy β€’ Backend: Dart, Python, C, Linux, Firebase, Docker, Algorithms β€’ Software Architecture: Domain-Driven Design, Test-Driven Design, Clean code, Microservices, Unit testing β€’ Leadership: People and Communication skills, Planning, Ability to teach and mentor 🌍 Only interested in remote work. πŸ“© Drop me a message if you think my expertise could help your organization! πŸ“ž Phone: +40 768 050 010 πŸ“§ Email: [email protected] πŸ’¬ Skype: agrusu_1

Updated on November 28, 2022

Comments

  • Alexandru Rusu
    Alexandru Rusu over 1 year

    As an intro, I'm developing an app with Flutter that has an audio section.

    I would like to address two subjects.

    1. For the moment the audio is stored in the cloud, more specific using Firebase. The main problem is that the pricing is not very supportive when the bandwidth threshold is exceeded. Also, as I discovered, each song is downloaded completely when trying to play it. Therefore, it doesn't matter that I want play 10 seconds or 1 minute of a song, the same traffic is generated. I'm using just_audio package as audio library and I'm wondering if there is a solution to integrate a stream base solution that implies buffering.

    2. As I've seen in the debug logs, a HTTP request is sent every time a song (from the cloud) is requested to play. Now, my concerns are that I can't use just_audio for streaming. Is there a cloud solution that fulfills a good compromise between price and bandwidth, even if the song is downloaded entirely each time the play action is required? I'm taking in consideration to develop an offline mode for the audio section, so that each song could be played from the local memory. Even so, it must be a user option, not a by default feature.

    • Scott Stensland
      Scott Stensland about 3 years
      http live streaming ( HLS ) protocol is architected to put 99% of its savvy into the client side so the hls server is extremely simple to where you can write your own hls server in a day or two so if your client side can render hls this is a good option ... many VPS offer cheap cloud machines with unlimited bandwidth or at least several terabytes/mo for about $20 ... lookup ovh.com or hetzner.com offers 20tb for 20 euro/mo
    • Ryan Heise
      Ryan Heise about 3 years
      I agree with the previous suggestion of using HLS. But if you try out the dev channel of just_audio, you can try passing an AudioLoadConfiguration into the constructor to configure and limit the buffer sizes. If you're using ConcatenatingAudioSource you may want to also follow github.com/ryanheise/just_audio/issues/294
    • Alexandru Rusu
      Alexandru Rusu about 3 years
      Yesterday I read more about the options of just_audio and I discovered that the library provides three types of audio sources: ProgressiveAudioSource, DashAudioSource, HlsAudioSource. As far as I can see, ProgressiveAudioSource is used by default when using setUrl method. Not sure why is called 'progressive' and I didn't find a relevant info about this. I started to read about dash and hls, because I'm not so familiar. As far I can see, HLS works with a sort of file with .m3u8 extension. If .m3u8 file is a bunch of data, a list of songs, how will the song selection be made in this case?
    • Alexandru Rusu
      Alexandru Rusu about 3 years
      @ScottStensland, what do you think about this option for the server side? docs.peer5.com/guides/…
    • Scott Stensland
      Scott Stensland about 3 years
      sounds reasonable ... would be good to post an answer to this question with a minimal setup once you nail this ... have fun
    • Alexandru Rusu
      Alexandru Rusu about 3 years
      Finally, I found a solution and I describe it down below. Greetings.