Live data from Hacker News

Serve Your Music Collection Using HTML5, Backbone, and Flask

git.zx2c4.com

1–10 of 86 posts

Re: Serve Your Music Collection Using HTML5, Backbone, and Flask

#3

How did you deal with multiple simultaneous requests? (two clients streaming at the same time, two clients encoding at the same time, etc)

The Linux process scheduler deals with it, I guess. I suppose I could add some kind of my own limiting mechanism, but since encoding ties up the application process, I figure it's limited to how uwsgi works with this kind of thing (multiple child processes, threads, event loops, whatever).

I really wish there was an nginx header like X-Accel-Redirect called X-Accel-FD where I could pass it a file descriptor to send the data directly, with SIGPIPE set up fine. That way I wouldn't have to buffer from the application process.

Wait a second. Here's an idea -- maybe I can just pass a fifo file to X-Accel-Redirect... I'll give that a whirl. One potential issue here is that it's not going to behave nicely with the client terminating the connection prematurely -- it'll leave a zombified process or a filled pipe or both. So maybe this isn't best then. Any suggestions here? I'd like to not wind up rolling my own nginx module for this.

That said, the current solution works very well, and in my tests works great with several clients transcoding. My server is pretty underpowered, but it doesn't seem to have much of an issue.

Re: Serve Your Music Collection Using HTML5, Backbone, and Flask

#5
post #3

How did you deal with multiple simultaneous requests? (two clients streaming at the same time, two clients encoding at the same time, etc)

The Linux process scheduler deals with it, I guess. I suppose I could add some kind of my own limiting mechanism, but since encoding ties up the application process, I figure it's limited to how uwsgi works with this kind of thing (multiple child processes, threads, event loops, whatever). I really wish there was an nginx header like X-Accel-Redirect called X-Accel-FD where I could pass it a file descriptor to send t…

I wouldn't worry about it. At the scale I could see it being an issue I think the right answer becomes to simply store all the transcoded versions on disk and serve them directly. It would in all likelihood be more cost effective to pay for the storage than to pay for the CPU time to encode everything on the fly given the small size of audio files.

Re: Serve Your Music Collection Using HTML5, Backbone, and Flask

#7
post #6

Looks really interesting. Do you have a live demo, possibly with public-domain music? Would love to try it out without yet building it on a server.

No live demo, unfortunately. I think archive.org has plenty of public-domain music in ogg format. Want to put something together and I'll link to it in the README? This would be quite nice indeed to have.

On the plus side though, it's super easy to try it out locally using the built-in server:

Give backend/app.cfg the path of the music on your computer. Then run backend/local_server.py. Browse to localhost:5000 in your web browser, and you're set.

Info here: http://git.zx2c4.com/zmusic-ng/about/#standalone

Re: Serve Your Music Collection Using HTML5, Backbone, and Flask

#10
post #8

Curious as to why you aren't hosting this on github? I would have loved to star it and then come back later.

I don't use github. I use cgit and gitolite. I also don't use Google Music or Amazon Music; I use ZX2C4 Music. I don't use Picasa either - I use PhotoFloat http://zx2c4.com/projects/photofloat/ . Pattern? I don't like relying on cloud services I can't maintain myself. Schneier's got some essay out there called "Feudal Security" or the like that's a decent summary of this position.

(I also happen to be the maintainer of cgit...)

Anyway, if you really must have it, I do mirror all my git repos to github as a free backup. Look under my account -- zx2c4.

Post reply on HN