title: Spring boot + HTML 5 video streaming
body: <p>I've been learning the Spring boot framework recently and so far I'm fairly impressed by it.</p>
  
  <p>However, I've been trying to write a basic media server application and I'm not entirely sure what the correct way is to implement a controller endpoint which serves an HTML 5 video source. I've currently implemented this like so:</p>
  
  <pre><code>@GetMapping(value = "/videosrc", produces = "video/mp4")
  @ResponseBody
  public FileSystemResource videoSource(@RequestParam(value="id", required=true) int id) {
      return new FileSystemResource(new File("path to mp4 file"));
  }
  </code></pre>
  
  <p>And the HTML 5 video element looks like this: (using Thymeleaf)</p>
  
  <pre><code>&lt;video width="auto" height="240" controls style=" margin-left: auto; margin-right: auto; display: block;"&gt;
      &lt;source th:src="@{/videosrc(id=${video.id})}" type="video/mp4"&gt;
  &lt;/video&gt;
  </code></pre>
  
  <p>The video displays, however I've noticed that if I skip the video a few times it eventually slows down and then freezes up the browser. I'm not sure why this is happening but I'm assuming it's because I'm not handling the request correctly?</p>
  
  <p>Thanks</p>