3

I have a Java backend running on Tomcat 7. I'd like to add support for an HTTP request that would begin streaming an MP4 video from Java code in Tomcat, and not sure where to begin. I believe HTTP GET somehow supports A/V streaming, but not entirely sure.

Let's pretend that the MP4 file is located at /opt/videos/myvid.mp4, and that the Tomcat instance has file permissions to read/write to that directory and file. Now let's pretend that an HTTP GET (or whatever supports streaming) request comes in, and we need to start streaming myvid.mp4 to the client - in pure Java, from inside a Controller class. How would this work?

IAmYourFaja
  • 55,468
  • 181
  • 466
  • 756
  • 1
    Try checking this thread : http://stackoverflow.com/questions/2308181/how-can-i-code-a-server-client-video-and-audio-streaming-application – Fincio May 12 '14 at 14:11
  • Thanks @Fincio (+1) - I guess this is a bit more low-level than I was thinking it would be. Are there any libraries that abstract this out a little higher? Thanks again! – IAmYourFaja May 12 '14 at 14:30
  • Oh, and why the closevote? – IAmYourFaja May 12 '14 at 14:30

1 Answers1

1

I had to accomplish a similar task a year ago. I found a nice short and working servlet on: http://balusc.omnifaces.org/2009/02/fileservlet-supporting-resume-and.html

Actually, tomcat itself is doing streaming quite well. But, I did not figure out how to use files outside the webapp/war directory.

Toni Bünter
  • 93
  • 1
  • 6
  • Awesome, dude, this really works for me! (well, I added some modification to work with my environment) You just saved lots of my time :) – Alanight May 11 '18 at 10:35