πΎ Archived View for bbs.geminispace.org βΊ s βΊ Gemini βΊ 21913 captured on 2024-12-17 at 15:09:40. Gemini links have been rewritten to link to archived content
-=-=-=-=-=-=-
How have people implemented audio streaming? I've been trying to implement this and running into lots of issues. Either the server sends audio to the client too quickly as if the client is loading a static file, or Lagrange won't play the audio at all.
I am not sure how to debug this or what others have done.
Nov 18 Β· 4 weeks ago
π¦ eaglestone Β· Nov 18 at 11:10:
I'm shocked this works at all! I thought the whole point of the protocol was explicitly to break this kind of thing. Not that I'm over here making tsk-tsk fingers at you or something.
Do you know who all else has done this successfully? I also imagine there are other things that have been done that Lagrange doesn't support (or at least well) - it looked like there was a live chat at one point that I couldn't join with it because it didn't handle streaming data in a way that the chat server wanted it to.
Maybe it's time for some research and a PR? :)
πΉοΈ skyjake [mod...] Β· Nov 18 at 11:59:
Streaming is not an "official" feature of Gemini. It's more of a side effect of letting the server send unlimited amounts of data in the response as there is no way to declare a content length beforehand. Some clients want to download the full response before processing it, while others can show intermediate results. Lagrange basically re-renders the page periodically while receiving data.
When it comes to audio, streaming is only partially supported in Lagrange. It's mostly 3rd party functionality so it depends on the codec and the platform whether streaming will work. IIRC, the only codecs that should be streamable everywhere are WAV and Ogg Vorbis. MP3 will use native decoders on some platforms (e.g., mobile) and those wait until the Gemini request has completed before decoding.
There is a caveat, though: all of the streamed audio data is kept in memory, i.e., the input buffer does not roll. In other words, listening to a long audio stream could use more RAM than one might expect.
π requiem Β· Nov 18 at 12:38:
I still think we should use other protocols for streaming media. Like RTSP or something.
π satch [OP] Β· Nov 18 at 12:46:
@requiem agreed - this is more of a curiousity project than anything else, I definitely don't think Gemini is the right protocol for audio streaming.
I'm going to try with ogg and see if anything changes. My tests so far are on MacOS, I will test on other platforms once I get that working.
π satch [OP] Β· Nov 18 at 13:12:
ogg vs mp3 doesn't seem to change anything for me on MacOS :/
π°οΈ lufte Β· Nov 18 at 15:07:
Are you writing your own client? If the server is sendig the file too quickly it is because you are reading it too quickly.
πΈ HanzBrix Β· Nov 18 at 16:14:
I find this very interesting, I was thinking of incorporating sound in a game I am making, just short fx clips, did not know ogg was required to make it stream. π
π satch [OP] Β· Nov 18 at 16:46:
@lufte Testing using Lagrange
π mbays Β· Nov 18 at 17:08:
I've found that piping to "mpv --cache-secs=5 -" works well for most audio/video formats. (I don't know which clients support piping to a command though, maybe not many.)
π pista Β· Nov 19 at 15:03:
Yes, it works. Skyjake helped me with it a while ago. There is an extra setting needed in gmcapsule to allow streaming. Was able to run icecast radio via gemini.
For server-side, imho, it simpler to use socket proxy for any http streaming server e.g. icecast
I did something similar for NEX protocol (TLS-less) with Nginx also:
# /etc/nginx/nginx.conf stream { server { listen 1915; proxy_pass 127.0.0.1:1915; } }
About client-side, close to work about this feature in my browser, seems Lagrange developers did great work around streaming, because this question require manual memory buffer management, multiple codecs routing, timing control and other things.
πΈ HanzBrix Β· Nov 24 at 14:52:
@ps Developer*, far as I know skyjake has made the whole client himself, as well as BBS, GMCapsule and Cosmos.
@HanzBrix wondeful, the Father of Geminispace!
I spent about 1k hours for browser implementation and did nothing yet comparing to Lagrange features. Only 100% love to geminispace make this work amount possible @skyjake
π pista Β· Nov 24 at 15:33:
Heβs a real champion and the Gemini community is lucky to have him.