title: How to serve mp4 streaming video on Google App Engine Blobstore
body: <p>I am using GAE to serve large files, and I can successfully serve mp3 using a simple <code>blobstoreService.serve(key, res);</code> If I put the resource url in the browser, the media control will appear and/or the media player will start, and the music will start before the download is complete.</p>
  
  <p>However, when I put a mp4 url in the Chrome, the control appears but nothing happens. Here are what I have done:</p>
  
  <ol>
  <li>no content disposition to avoid download. If I put the content disposition, then the browser will download the video.</li>
  <li>I even used ffmpeg to convert the video and put -movflags faststart option there but no difference.</li>
  <li>I also set the response header to <code>Accept-Ranges:bytes</code> to the first request and I have observed that the next request still asks for full 75MB range.  Should I only serve partially even though the browser asks for all?</li>
  <li>Or how to let the browser know that I wanted to serve piece by piece so the requests will have ranges.  Is content-length necessary?  Should I process the HEAD request? I believe right now my servlet only processes GET.</li>
  <li>my url is like <a href="http://www.somesite.com/serve?folder=aa&amp;file=ok.MP4" rel="nofollow">http://www.somesite.com/serve?folder=aa&amp;file=ok.MP4</a>  the Chrome console shows that only 1MB is downloaded and then it stopped</li>
  <li><p>The html code looks like below except my GAE url is the src. The example mp4 works but if my gae link is there, it doesn't show video at all.</p>
  
  <p><strong>&lt;video width="640" controls="">
  &lt;source src="http://www.w3schools.com/html/mov_bbb.mp4" type="video/mp4">
  Your browser does not support HTML5 video.
  &lt;/video></strong></p></li>
  </ol>
  
  <h2>Question</h2>
  
  <p>What exactly are needed to do on GAE server side to serve the video using streaming?</p>
  
  <h2>Answer</h2>
  
  <p>The marked answer has sufficient information on how to serve the mp4 file and it also gives a live web page for demo.  From that demo, I was able to tell that my site could serve an mp4 file as long as the Chrome browser could decode it. The problem I encountered was due to the codec used in ffmpeg wasn't recognized by Chrome.  Changed to H.264, everything worked fine.</p>
  
  <p>Here is one example of the ffmpeg command line, where OK.MTS is the camcorder file, output1.mp4 is to be uploaded:</p>
  
  <pre><code>ffmpeg -i ok.MTS -codec:v libx264 -profile:v baseline -preset slow -b:v 500k -maxrate 800k -bufsize 1000k -vf scale=-1:432 -threads 0 -b:a 96k output1.mp4
  </code></pre>