๐Ÿ’พ Archived View for bbs.geminispace.org โ€บ s โ€บ GmCapsule-Issues โ€บ 12 captured on 2024-12-17 at 15:13:31. Gemini links have been rewritten to link to archived content

View Raw

More Information

-=-=-=-=-=-=-

[#12] Is streaming media possible? Was trying to set up a radio stream like hashnix.club has to rebroadcast Icecast over Gemini.

My approach was to place a script in the CGI directory that prints "20 audio/mpeg\r\n", and then opens a handle to the Icecast stream and begins reading and printing it 1024 bytes at a time.

When I do this from gmcapsule, the page loads forever whereas hashnix is opening an audio player (tested in Lagrange).

Not sure if something is wrong in my approach, or if gmcapsule is hanging where it waits for the script to terminate before returning output. Since it's a stream it isn't designed to terminate.

๐Ÿž Issue #12 in s/GmCapsule-Issues

๐Ÿ’Ž istvan

Sep 04 ยท 3 months ago ยท ๐Ÿ‘ Houjimmy

9 Comments โ†“

๐Ÿ’Ž istvan [OP] ยท Sep 04 at 04:35:

If I kill Icecast broadcast with CTRL+C, the CGI script finishes loading and the music begins playing from wherever the stream first connected.

This looks like it's downloading forever until the script terminates (because the stream terminates), and then it's playing all the captured data as music from the start.

Tried peeking at the headers of gemini://hashnix.club/cgi/hashnixradio.cgi and it seems they are also just sending "20 audio/mpeg\r\n" followed by a passthru of the Icecast stream.

Would love to know if I'm doing it wrong or if I'm trying to make gmcapsule do something that is not supported.

๐Ÿ•น๏ธ skyjake [mod...] ยท Sep 04 at 04:54:

Streaming CGI responses is supported in GmCapsule but it comes with a couple of restrictions:

[cgi.streamtest]
path    = /mystream
command = /usr/bin/streamer-example
stream  = true

๐Ÿ’Ž istvan [OP] ยท Sep 04 at 06:32:

What does multiprocessing mean in this case? What limitations or effects does it involve?

๐Ÿ•น๏ธ skyjake [mod...] ยท Sep 04 at 06:44:

By default, GmCapsule starts multiple separate processes to handle client requests. This allows it to have true concurrency for long-running requests. However, when running in a single process (`processes = 0`), Python's global interpreter lock means that only one of the threads that handle requests is able to execute code at the same time. Even in this case, I/O is not limited, so data transfers can be ongoing to/from multiple clients.

Even without multiple processes, you still can have multiple threads so the server is not going to lock up or anything, it just will be running slower, using a single thread at any given time.

๐Ÿ’Ž istvan [OP] ยท Sep 04 at 11:49:

Thank you very much for the detailed explanation!

๐Ÿฆ Houjimmy ยท Sep 04 at 16:24:

Man, I found your link and started to watch your streaming. Is working pretty well and there is not much data usage, 15mb in 10 minutes. I also liked the music. Thank you for your hard work, I will probably listen to it every time I connect in Gemini.

๐Ÿ’Ž istvan [OP] ยท Sep 04 at 19:45:

@Houjimmy Not my stream! That stream is curated by the Hashnix community users. Not trying to steal credit for their creativity.

๐Ÿ’Ž istvan [OP] ยท Sep 04 at 21:53:

Edit: My mistake. I missed the [server] section.

๐Ÿฆ Houjimmy ยท Sep 06 at 05:26:

Ok, I did not know. Anyway, is a good streaming. Thanks for sharing.