Stream large video files from REST endpoin

1
Hi, Maybe someone can help me with the issue I’m having when trying to stream mp4 video files. I have create simple REST endpoint to return mp4 file and the microflow looks like this: I’m adding ‘video/mp4’ header as the ‘Content-Type’ header: If I try to stream small mp4 file (around 400kb) then everything works fine. The request returns the data and if I open it in chrome the video is playing as expected. The issue is when I try to return larger file (around 10mb) when opening in Chrome the vide doesn’t start playing and in the console I’m seeing this error: com.mendix.systemwideinterfaces.MendixRuntimeException: org.eclipse.jetty.io.EofException     at com.mendix.util.classloading.Runner.doRunUsingClassLoaderOf(Runner.java:36) Caused by: org.eclipse.jetty.io.EofException: null     at org.eclipse.jetty.io.ChannelEndPoint.flush(ChannelEndPoint.java:283)   Maybe anyone has had experience and can have some suggestions on this?
asked
2 answers
2

Hi Karlis,

The problem is that the browser is trying to load the entire video in a single HTTP request which will not work for such large files.
To fix this In addition to the content-type header, videos need more headers to allow for buffering, scrubbing etc.
Specifically, you need to check the content-range and content-length headers in the incoming request and serve the appropriate bytes. The response should contain the same headers.
For more details see https://ianmcdowell.net/projects/http-mp4-streaming/
Some example code on how to do this with Java https://gist.github.com/fehmicansaglam/1781977

Hope this helps

answered
0

Contact Menno de Haas on Slack. I know he built a small module/java action to support streaming objects. Maybe he can publish it for you in the appstore

answered