How to Serve Streaming mp4 Videos on Google App Engine Blobstore

I am using GAE to work with large files and I can serve mp3 successfully using simple blobstoreService.serve(key, res);

. If I put the URL of the resource in the browser, the media controls appear and / or the media player starts playing. the music will start before the download is complete.

However, when I put the mp4 url ​​in Chrome, the control pops up but nothing happens. Here's what I did:

  • no content to avoid downloading. If I have posted the content, then the browser will download the video.
  • I even used ffmpeg to convert the video and put the -movflags faststart option there, but no difference.
  • I also set the response header for Accept-Ranges:bytes

    the first request, and I noticed that the next request was still asking for the full 75MB range. Should I only serve partially while the browser is requesting everything?
  • Or how to tell the browser that I would like to serve in parts, so the requests will have ranges. Is content length necessary? Should I handle the HEAD request? I believe my servlet is only handling GETs right now.
  • my url is like http://www.somesite.com/serve?folder=aa&file=ok.MP4 chrome console shows only 1MB loaded and then it stopped
  • The html code looks like below except for my GAE url - src. The mp4 example works, but if I have the gae link it doesn't show the video at all.

    <video width = "640" controls = ""> <source src = "http://www.w3schools.com/html/mov_bbb.mp4" type = "video / mp4"> Your browser does not support HTML5 video. </video>

Question

What exactly do you need to do on the GAE server side to serve video using streaming?

Answer

The noted answer contains enough information on how to serve up the mp4 file and also provides a live webpage for demo. From this demo, I was able to tell that my site can serve an mp4 file if the Chrome browser can decode it. The problem I ran into was that the codec used in ffmpeg was not recognized by Chrome. Changed to H.264, everything works fine.

Here is one example of ffmpeg command line where OK.MTS is the video camera file, output1.mp4 should be dumped:

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

      

+3


source to share


1 answer


Is your handler putting the correct Content-Type in the response headers? For proper video playback, you need to set "Content-Type: video / mp4".

Here is a test site I wrote on App Engine that plays mp3, ogg and mp4 files from Cloud Storage and BlobStore.



There is a link to an mp4 file in BlobStore that uses the serve () function to return the file. When I paste this link into chrome, the content plays correctly.

+9


source







All Articles