# Vinofy - Video Streaming
## CloudFlare Stream backed by cloud storage service AWS S3 Bucket
All videos will be uploaded to S3 by the user via AWS provided tools, once a file is uploaded a cloud function will be executed sending a request to CloudFlare with the necessary info and then storing result metadata in a location of choice, CloudFlare will then proceed to download, encode, host, and distributed the file that will be served to end users.
## Motivation
The idea is to be able to use a self-manage video streaming solution that let Vinofy’s users upload a video, encode it in an adequate format for streaming and provide access to it. Plus, to host the videos in a platform that provides with services and tools that may be relevant in the future for Vinofy, let us re-encode them, and give full control and flexibility over the videos (ex: migration to a different platform).
### Benefits
* Simple setup
* Full access and control over videos
* Being able to encode the videos in more formats in the future
* Being able to migrate the videos to another platform if required
* Encoded videos are provided via CDN
* Being able to require authentication for video upload if considered necessary
* On-demand pricing model
* Video encoding overhead is delegated to a 3rd party
### Drawbacks
* CloudFlare will have to download the source video from S3 in order to encoded, this will mean more bandwidth usage that we will need to pay (can be mitigated in the future by using AWS media encoding service)
* If we decide to move away from CloudFlare, we will need to update all the URLs stored in the metadata
## Design alternatives
### CloudFlare Stream backed by cloud storage service Google Cloud Storage
* It is and alternative but Google Cloud Storage will require the video to be upload to our server and then be sent to GCS
### CloudFlare Stream backed by Firebase Cloud Storage
* It is possible for the client to directly upload videos to firebase and we may require authentication if necessary
* Data store in firebase can be difficult to migrate
* Firebase does not provided as many services as amazon does for future operations over the data stored
### MUX video backed by cloud storage service AWS S3 Bucket
* MUX video is an alternative to CloudFlare streaming, a full comparison would be required to decide which is better, though both alternative have a simple setup.
### Storing the source videos directly in CloudFlare Stream storage
* This could solve the need for downloading the source video from a different network space
* Data migration does not seem to be documented by CloudFlare
* For authentication we would need to write logic in the middle of the client and CloudFlare
### Building the full store, encoding, hosting an distribution solution in AWS
* Most data transfers inside AWS are free
* This might be the best solution for our app when having a bigger audience
* Moving from the main solution to this one does seem a viable choice in the future
### Conclusion
Using CloudFlare Stream backed by cloud storage service AWS S3 Bucket is a fully Server-less and easy setup solution that provide enough flexibility.
## Considerations
* There is lack of discussion about CloudFlare Stream on the internet
* Pricing should be carefully study for all of these solutions
* A solutions architect may provide a bigger and more detailed picture