1

I'm really confused about this whole WebFlux library. Everything I read seems to contradict the previous thing.

Basically, I'm trying to serve a 30->60 minute MP4 file to about ~100 concurrent users without blocking the main thread. I've read that WebFlux can do exactly this using NIO, and it does so efficiently.

My question is, how would I serve this long video using WebFlux on Spring MVC through a @GetMapping with the video name in the parameters? I tried just using this: https://melgenek.github.io/spring-video-service but the video only plays when the ENTIRE thing is buffered. So a 10-minute clip will only begin to play after it's fully downloaded. Am I supposed to put a maximum limit on the range? I'm new to web development so I don't know much about HTML servers/clients

João Dias
  • 16,277
  • 6
  • 33
  • 45
Jeff Douqn
  • 19
  • 6
  • You don't need Webflux for ~100 concurrent users - you can easily do that with a traditional blocking model. There's nothing *wrong* with Webflux in this case of course, but it's not a requirement. – Michael Berry Oct 20 '20 at 08:44
  • @MichaelBerry Possibly, but I want to learn WebFlux since it's apparently better. So when my infrastructure needs to scale, I wont have to re-do everything. – Jeff Douqn Oct 20 '20 at 08:46
  • Sure - (sorry, comment was half way through and hit the wrong button) - that tutorial looks fine after a quick glance. I suspect the reason you have to wait for everything to buffer is nothing to do with Webflux, but instead because you're serving files where the moov atom (or MP4 header) isn't located at the start of the file (often at the end by default.) Try moving it to the start (see https://stackoverflow.com/questions/8061798/post-processing-in-ffmpeg-to-move-moov-atom-in-mp4-files-qt-faststart) and see if that helps. – Michael Berry Oct 20 '20 at 08:49
  • @MichaelBerry That did it! Weirdly enough though, it's not working in Google Chrome? I'm just using the default video tag too, nothing else. – Jeff Douqn Oct 20 '20 at 08:56
  • Nothing jumps to mind I'm afraid. Do other standard video tags work ok in Chrome? – Michael Berry Oct 20 '20 at 08:59
  • @MichaelBerry I tried using webp, nothing. No errors, nothing, and it's making the same request as Firefox. I even tried downloading MP4 files off the internet, and they wont play either. Super weird, going to google around for awhile I guess – Jeff Douqn Oct 20 '20 at 09:33
  • No idea I'm afraid - not my area of expertise! Might be some issue with not running over https or running on localhost as Chrome sometimes gets a bit funny over those things - but that's a pure guess. – Michael Berry Oct 20 '20 at 10:08
  • It's something to do with this WebFlux library. Generic blocking style setup still works on all browsers. No idea why it works on Firefox, but not Chrome. Accept-Ranges is on afterall.. – Jeff Douqn Oct 20 '20 at 13:27

0 Answers0