Search code examples
androidfirebasevideo-streamingfirebase-storage

Downloading a video from Firebase Storage - chunk by chunk


I'm building an app with java (for android) that one of it main goals is to show a video to the client.

Right now I'm storing all my videos in firebase storage, At the beginning I wanted to stream the video (youtube style) but unfortunately firebase storage does not support it.

I read that there is an alternative way of "faking" to stream the video by downloading the video chunk by chunk and playing it one by one, that way you don’t need to wait until the whole video is downloaded locally to the phone and only after that start playing it.

You can see what I'm talking about here - Speeding up firebase storage download

So my question is which API/library/thing can I use to do it, and if somebody has an example code that he can show me ?

Thank you very much !


Solution

  • The Firebase SDK for Cloud Storage does not have any methods to stream the results.

    The options I can quickly think of:

    • Store the video in smaller chunks, each chunk in a separate file. That way you can retrieve the files one by one, and start playing when you have the minimum number of chunks.
    • Set up your own server which reads from Cloud Storage (typically at a much higher bandwidth), and then sends a response to the client in smaller chunks. For more on this, also see this answer: Video Streaming from Google Cloud Storage

    Neither of these is going to be trivial to implement, so you might want to consider if maybe a dedicated video streaming service isn't a better fit for your needs.