Streaming videos from S3 bucket

▼魔方 西西 提交于 2020-07-17 06:45:09

问题


I am working on video streaming with nodejs server. I have used Amazon S3 bucket as video storage. While nodejs is running in an Amazon EC2 instance. In order to stream a specific video file in response to a client's request, the file needs to be downloaded from S3 bucket to EC2 instance (nodejs server) first, which is a time consuming process and client has to wait for several seconds before the first video segment is sent from nodejs to client. I am looking for a way to remove the downloading time interval. My questions are :

1# Is there a way to directly stream from S3 bucket?

or

2# Does S3 storage allows to get small chunks of stored file instead of downloading the whole file?

Note : Video stream is supposed to be used by iOS video players. I am a newbie to video streaming and S3 storage.

Kindly suggest me the best possible solution in this scenario.


回答1:


You need to use the following AWS services to achieve on-demand video streaming from S3 bucket in a standard way.

1) Amazon Elastic Transcoder

Amazon Elastic Transcoder is media transcoding in the cloud. It is designed to be a highly scalable, easy to use and a cost effective way for developers and businesses to convert (or “transcode”) media files from their source format into versions that will playback on devices like smartphones, tablets and PCs.

Convert your video files to HLS format (the most widely supported streaming protocol)

2) Amazon CloudFront – Content Delivery Network (CDN)

Amazon CloudFront is a global content delivery network (CDN) service that accelerates delivery of your websites, APIs, video content or other web assets. It integrates with other Amazon Web Services products to give developers and businesses an easy way to accelerate content to end users with no minimum usage commitments.

CloudFront to prepare and deliver files to their player

Related Links:-

using-amazon-cloudfront-for-video-streaming

Steps to setup the video streaming




回答2:


One can use a combination of the methods described here:

https://github.com/davidgatti/How-to-Stream-Movies-using-NodeJS

And S3's "Range" parameter for getting chunks from S3. I was able to reproduce video streaming using these methods. It might not be the most performant.




回答3:


I want to first clarify that "Streaming" is technically different from "Playing a Video" (progressive downloads). So showing a video from S3 is not really "Streaming". That is a "Progressive Download".

If you want to do HLS Streaming, you can't do it with just S3.

You need: S3 + CloudFront + MediaConvert.

MediaConvert will convert your mp4 into a m3u8 (playlist) and a bunch of .ts files (segments). You can also encrypt your stream if you want when submitting to MediaConvert. Then you use a player like VideoJS to stream your video - it even works with encrypted video streams.

-- Ravi Jayagopal

https://S3MediaVault.com



来源:https://stackoverflow.com/questions/41361407/streaming-videos-from-s3-bucket

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!