微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Flask 视频流在移动设备和 Chrome 上的表现非常奇怪

如何解决Flask 视频流在移动设备和 Chrome 上的表现非常奇怪

我有一个 Flask 应用程序,可以流式传输我存储在 mongodb 数据库中的视频。它在 Firefox 桌面上运行良好,但在我重新加载页面之前不允许在 chrome 桌面上擦洗。它甚至在移动设备上根本不起作用,它只是什么都不返回。这是我的代码

@app.route('/view/<postid>')
def Rview(postid):
    post_id_obj = ObjectId(postid)
    cur_post = col_posts.find_one({"_id": post_id_obj})
    if str(cur_post) == 'None':
        return render_template('error.html',head='No post found')
    else:
        location = cur_post['file'] # gets the file location from the database,stored using fs chunks
        file_mimetype = cur_post['mimetype']
        file_ext =  '.' + file_mimetype.split("/")[1]
        if file_mimetype == "video/mp4":
            return send_file(BytesIO(fs.get(location).read()),mimetype=file_mimetype,as_attachment=False,attachment_filename=(str(random.randint(10000000,99999999)) + file_ext))
        else:
            return send_file(BytesIO(fs.get(location).read()),99999999)) + file_ext))

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。