0
votes

I need to download a partial video from Amazon S3 Bucket in node given a certain time range from the video.

For example, Download the video starting from 3 seconds into the video and stopping at 15 seconds.

From what I have gathered so far, I can make a byte-range request using the getObject function on an S3 bucket. But, I do not know how I would go about converting a time range to a byte range in order to make that request.

Additional information:

The mp4 format video is already being displayed. Then, there would be an option to download (not display) a clip of that video by selecting a desired start time and end time.

I am assuming that a new request would need to be sent to retrieve the partial video for the user to download.

1
"in node" you need to make the fetching from your node server? Then why tag [html5-video]? Or are you in a browser? And if so, do you just need it for an html5 <video> element to use? - Kaiido
Sorry, I probably shouldn't have tagged html5-video (I removed the tag). I'm fetching from client side (react) -> lambda node.js -> s3. - Caleb
So you need to access the binary data? You are not just displaying this video? - Kaiido
First, the video is displayed. Then, a user would be allowed to download a clip of that video by selecting a desired start time and end time. A new request is sent to retrieve the partial video for the user to download. I assume a new file would be made from binary data in the response.. - Caleb
Please include this as an edit to your question since this is a total changer. There are easy ways to display a video by time ranges, there would be ways to fetch the byte ranges by analysing the moov headers yourself, but generating a new video from this, then that's a job for ffmpeg, not for a browser. - Kaiido

1 Answers

0
votes

It depends on the video format. For mp4, you can download and parse the moov, and use the index to calculate the offsets (plural because audio and video will have different offsets). But this is only possible to be key frame accurate. If it’s not mp4 is more difficult.

Start by reading iso 19964 part 14.