Cloud storage provider for music streaming
-
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.
-
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
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, 2022Comments
-
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.
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.
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 about 3 yearshttp 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 about 3 yearsI 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 usingConcatenatingAudioSource
you may want to also follow github.com/ryanheise/just_audio/issues/294 -
Alexandru Rusu about 3 yearsYesterday 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 about 3 years@ScottStensland, what do you think about this option for the server side? docs.peer5.com/guides/β¦
-
Scott Stensland about 3 yearssounds reasonable ... would be good to post an answer to this question with a minimal setup once you nail this ... have fun
-
Alexandru Rusu about 3 yearsFinally, I found a solution and I describe it down below. Greetings.