Comment by ๐Ÿ’Ž istvan

=> Re: "Is streaming media possible? Was trying to set up a radio..." | In: s/GmCapsule-Issues

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.

=> ๐Ÿ’Ž istvan [OP]

2024-09-04 ยท 5 months ago

8 Later Comments โ†“

=> ๐Ÿ•น๏ธ 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.

Original Post

=> ๐ŸŒ’ s/GmCapsule-Issues

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...

=> ๐Ÿ’ฌ istvan ยท 9 comments ยท 1 like ยท 2024-09-04 ยท 5 months ago

Proxy Information
Original URL
gemini://bbs.geminispace.org/u/istvan/19386
Status Code
Success (20)
Meta
text/gemini; charset=utf-8
Capsule Response Time
51.368096 milliseconds
Gemini-to-HTML Time
1.471926 milliseconds

This content has been proxied by September (ba2dc).