【问题标题】:How to Serve a Video (blob) with Google App Angine如何使用 Google App Engine 提供视频 (blob)
【发布时间】:2015-02-08 19:41:55
【问题描述】:

我正在尝试学习如何使用 blobstore 提供视频而不占用视频的所有屏幕,例如

这里我将 Video 导入为 video_model

class ViewVideo(webapp.Reque...,blobstore_handlers.BlobstoreDownloadHandler):

  def get(self):
    video_id = self.request.get('video_id')
    video_instance = None        
    if video_id:
        video_instance = video_model().get_video_content(video_id)
        self.response.headers['Content-Type'] = 'video/mp4' 
        self.send_blob(video_instance.content.key())            

class Video(db.Model):

  content = blobstore.BlobReferenceProperty()
  title = db.StringProperty()

  def get_video(self,video_id):
    return Video.get_by_id(video_id)


  def get_video_content(self,content):
    query_str = "SELECT * FROM Video WHERE content =:content"
    return db.GqlQuery(query_str,content=content).get() 

video_id 来自给定的 url,但正如你所见,我将它直接放在 send_blob() 函数中,而当我测试它时,它需要所有屏幕才能看到视频,我想知道如何提供我的应用程序中的视频没有发生这种情况,我正在考虑嵌入 HTML,但我无法弄清楚源将如何

任何帮助将不胜感激

如果缺少回答问题的内容,我会编辑它

【问题讨论】:

    标签: python google-app-engine video-streaming html5-video blobstore


    【解决方案1】:

    如果没有 HTML5,就会变得一团糟。 使用 HTML5,它变得简单而优雅。为用户的浏览器提供服务,作为您提供的任何页面的一部分,以下 HTML (5) sn-p:

    <video width="320" height="240" controls>
      <source src="/getmp4?video_id=whatever" type="video/mp4">
    Your browser does not support the video tag: please upgrade it!
    </video>
    

    并使用 ViewVideo 处理程序仅提供 /getmp4 URL,而不是您的用户通过浏览器直接获取的 URL。

    320240 和显示controls 的选项当然都是可选的——因为视频ID 更重要的是使用whatever!-)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-01-21
      • 1970-01-01
      • 2011-10-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-18
      相关资源
      最近更新 更多