slact / nchan

Fast, horizontally scalable, multiprocess pub/sub queuing server and proxy for HTTP, long-polling, Websockets and EventSource (SSE), powered by Nginx.
https://nchan.io/
Other
3.01k stars 292 forks source link

ffmpeg publishing #208

Open samsonradu opened 8 years ago

samsonradu commented 8 years ago

Hi,

I'd like to know if there's a way to publish binary data via an ffmpeg process, so basically a long-living publisher which keeps POST-ing chunked data. It's not working for me (no errors in logs).

Think it's related to #180 but on the publisher level.

ffmpeg -i /dev/video0 -f mpeg1video http://localhost:88/pub?id=1

slact commented 8 years ago

There's currently no way to publish one message per chunk from a single POST request. However, I can definitely see how this might be useful, and I'll try to add this feature in a release or two.

slact commented 8 years ago

Having said that, there is a way to publish straight from ffmpeg:

ffmpeg -i /dev/video0 -chunked_post 0 -multiple_requests 1 -f mpeg1video http://localhost:88/pub?id=1
samsonradu commented 8 years ago

Thanks for the quick reply! -chunked_post 0 seems to kill the ffmpeg process for me. Also it might be inefficient to fire another request for each chunk of data (considering >20fps). Guess I ll have to wait for the feature :)

slact commented 8 years ago

I'm not sure what the deal with -chunked_post 0 is, but new-request-per-data-chunk might not be so bad. The only actual overhead is the HTTP headers, and not the connection handshake. As per ffmpeg docs, -multiple_requests 1 uses a persistent connection. You may want to benchmark it to check the actual performance.

samsonradu commented 8 years ago

Update from the #IRC #ffmpeg channel, it cannot do that, fire a new http req per chunk. Also the multiple_requests flag actually means toggling the Connection: Keep-Alive header.

slact commented 8 years ago

Noted, thanks for the update. I'll see what I can do about adding chunked message publishing.

samsonradu commented 8 years ago

Any news on this one?

slact commented 8 years ago

Not yet, I'm afraid. I've been kind of busy fixing bugs, and also with last week's Nginx Conference. I might be able to get this done in a week or two, but I could probably do it sooner if properly incentivized.

samsonradu commented 8 years ago

Thanks for the quick reply, saw quite a few commits lately indeed, thought it might be hidden somewhere. No rush on it.

slact commented 8 years ago

I'll definitely update this ticket and let you know once it's in.