下载字节范围请求支持 firebase 存储

Download byte range requests support for firebase storage

我正在尝试缩小问题范围,了解 firebase 存储是否支持视频下载的字节范围请求会有所帮助。我似乎无法在任何地方找到该信息。我的网络应用程序包括视频流功能(YouTube 风格),我想知道这是否是最佳选择。如果不是,还有什么更好的选择来托管视频?

我已经按如下方式实现了这一点,但我的视频可以在除 iPhone 和 ios 设备以外的所有设备和浏览器中播放:

<video width='100%' height='315' poster='{{ value.image }}' controls loop muted playsinline>
       <source type='video/mp4' src='{{ value.video }}'>
</video>

基于广泛的研究 here 和其他在线资源,

解决方案似乎是将 controls playsinline muted 添加到 video tag 似乎有效,我的没有。

另一个问题是视频容器类型。已确认我的是mpeg4 container,在source type.

中显示为video/mp4

我看到的最后一个问题是服务器可能不支持字节范围请求,在决定转向另一个视频存储解决方案之前,我试图确定这是否与 firebase 有关。 (对这些有什么建议吗?)

谢谢。

Cloud Storage for Firebase 将您的文件存储在 Google Cloud Storage bucket, making them accessible through both Firebase and Google Cloud. This allows you the flexibility to upload and download files from mobile clients via the Firebase SDKs for Cloud Storage. In addition, you can do server-side processing such as image filtering or video transcoding using the Google Cloud Storage APIs

关于您的顾虑,如上所述,Google Cloud Storage 支持字节请求,而 Firebase Storage 也支持它。这是来自 Download an object using a byte range:

的示例代码
from google.cloud import storage


def download_byte_range(
    bucket_name, source_blob_name, start_byte, end_byte, destination_file_name
):
    """Downloads a blob from the bucket."""
    # The ID of your GCS bucket
    # bucket_name = "your-bucket-name"

    # The ID of your GCS object
    # source_blob_name = "storage-object-name"

    # The starting byte at which to begin the download
    # start_byte = 0

    # The ending byte at which to end the download
    # end_byte = 20

    # The path to which the file should be downloaded
    # destination_file_name = "local/path/to/file"

    storage_client = storage.Client()

    bucket = storage_client.bucket(bucket_name)

    # Construct a client side representation of a blob.
    # Note `Bucket.blob` differs from `Bucket.get_blob` as it doesn't retrieve
    # any content from Google Cloud Storage. As we don't need additional data,
    # using `Bucket.blob` is preferred here.
    blob = bucket.blob(source_blob_name)
    blob.download_to_filename(destination_file_name, start=start_byte, end=end_byte)

    print(
        "Downloaded bytes {} to {} of object {} from bucket {} to local file {}.".format(
            start_byte, end_byte, source_blob_name, bucket_name, destination_file_name
        )
    )

如需更多参考,您可以查看 API Reference Documentation