Streaming audio from url

This page summarizes the projects mentioned and recommended in the original post on /r/rust

Our great sponsors
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • SaaSHub - Software Alternatives and Reviews
  • stream-download-rs

    A Rust library for streaming media content from a remote location

  • Handling streaming gracefully like this is a bit complicated. I've seen a few audio applications that implement it similarly so I tried to make a library that should handle the most common use cases: https://github.com/aschey/stream-download-rs. There's an example using Rodio here: https://github.com/aschey/stream-download-rs/blob/main/examples/audio.rs. I haven't published it yet, but feel free to use it as a git dependency or just copy the code. I haven't tested it thoroughly yet so there may be race conditions or other bugs, but feel free to create an issue or message me if you end up using it and have any problems.

  • Symphonia

    Pure Rust multimedia format demuxing, tag reading, and audio decoding library

  • Are you trying to play audio from something like an internet radio station where the stream has an infinite length? The content length header is optional. It uses that to support seeking within the file. Symphonia, one of the underlying backends for Rodio, has an option to tell the decoder that the source is not seekable if the size of the file is not known. Unfortunately, Rodio currently hardcodes this setting to true https://github.com/RustAudio/rodio/blob/master/src/decoder/read_seek_source.rs#L19. I actually wrote this code a few years ago so I should know this, but I can't remember why exactly. I think there was no easy way to communicate this information to Rodio since the other backends don't have a setting like this. The other Rodio backends may handle this differently. There's a lot of great info in this discussion on the Symphonia repo about this use case which helped me with my implementation: https://github.com/pdeljanov/Symphonia/discussions/153

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts