问题
How to play(stream instead of download) a video file stored in GCS? The file was stored using Blobstore API in GAE Python? Presently, the video gets downloaded when I use the url, returned by send_blob, in the frontend.
I serve the video using:
video_url = "/v?video_id="+video_blobkey
::
class GCSFileServe(blobstore_handlers.BlobstoreDownloadHandler):
def get (self):
blob_key = self.request.get('video_id')
self.send_blob(blob_key)
::
app = webapp2.WSGIApplication([
('/', MainHandler),
('/v', GCSFileServe),
], debug=True)
I upload the video and store the blobkey:
filename = bucket + "/user_video_"+str (user_index) + "_" + str (i)
gcs_file = gcs.open (filename, 'w', content_type = 'video/avi')
gcs_file.write (video)
gcs_file.close ()
blobstore_filename = '/gs' + filename
video_blobkey = blobstore.create_gs_key (blobstore_filename)
On frontend, i pass the video URL to TINY Box 2 jquery modal plugin. This works perfectly if I provide youtube url instead of the video uploaded to GCS.
I saw Streaming Transfers topic in GCS docs but could understand how to use that in this context(if that is the solution).
回答1:
Finally, I figured it out myself. Actually, there was no problem with the way I am serving the video. The problem was with the Galleria jquery plugin which I was using. It can play videos from youtube, and a few more websites, but not if you specify a different URL (like of a self hosted video file).
Solution
I switched over to Videojs for playing videos on my website.
来源:https://stackoverflow.com/questions/24103934/how-to-playstream-instead-of-download-video-file-which-was-stored-in-gcs-using