Streaming Server for Videos

38 views
Skip to first unread message

Johannes Beere

unread,
Oct 27, 2016, 1:05:17 PM10/27/16
to Nitrogen Project / The Nitrogen Web Framework for Erlang
Hi,

I got Nitrogen 2.3.1 with cowboy on my FreeBSD machine running. I'm trying to build a website which is also showing video with the HTML5-video-tag. I can't get it running on Safari for MacOS and iOS. Safari always shows in the console "Failed to load resource: Plug-in handled load". After googling around it seems like Safari on MacOS and iOS expects the file streamed instead of an single blob.

Hase anyone an idea how I can solve this?

Jesse Gumm

unread,
Oct 28, 2016, 10:22:29 AM10/28/16
to nitrogenweb
Hi Johannes,

I was about to write that I thought cowboy's static handler should handle streaming by default, but I also decided to google around, and it appears that the problem is that it expects support for the range header, which it doesn't look like cowboy's static handler does by default.  It streams it with sendfile, but it doesn't actually chunk it and deal with range requests (as far as I can tell from glancing over the code).

That said, you might be able to get away with chunking it (you can return {chunked, Fun} from a Nitrogen's main module to short-circuit a chunked send using cowboy's chunking support (https://github.com/nitrogen/simple_bridge/blob/master/src/cowboy_bridge_modules/cowboy_simple_bridge.erl#L245-L246 and https://ninenines.eu/docs/en/cowboy/1.0/guide/loop_handlers/), but if that doesn't work, you may need write a custom cowboy handler to deal with the range requests.  It looks like it's on Loic's todo-list.  https://github.com/ninenines/cowboy/issues/306

Alternatively, you could try using Yaws as a backend and see if it might support streaming by default - I have no horse in this race.

I haven't personally dealt with streaming video, so I don't have a ton of insight, but I'm here to help in any way.

Hopefully this at least helps to point you in the right direction.

-Jesse


--
You received this message because you are subscribed to the Google Groups "Nitrogen Project / The Nitrogen Web Framework for Erlang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nitrogenweb+unsubscribe@googlegroups.com.
To post to this group, send email to nitro...@googlegroups.com.
Visit this group at https://groups.google.com/group/nitrogenweb.
For more options, visit https://groups.google.com/d/optout.



--
Jesse Gumm
Owner, Sigma Star Systems
414.940.4866 || sigma-star.com || @jessegumm
Reply all
Reply to author
Forward
0 new messages