0

I'm currently making a website that will host videos for users to view. I'm unsure about two things.

  1. How do I store video on the website ( Storage is very limited on the server atm ) - Should I compress the videos that are uploaded, if so how should I go about doing that? ( Create a zip of the videos?, is there a library for video compression? (ect) )
  2. How do I then stream the video to users. Should I send the video in buffers, how do I do that - If the video is stored in a compressed format.. how do I uncompress and then stream it to the user requesting.

I'm very unsure of how to build this as I've never built anything that streams files before. So apologies for all the questions. Which ever direction I take, more questions arise.

I would really appreciate any feedback.

Lorza
  • 459
  • 8
  • 23

1 Answers1

2

Give multer a gander.

Multer is a node.js middleware for handling multipart/form-data, which is primarily used for uploading files. It is written on top of busboy for maximum efficiency.

https://www.npmjs.com/package/multer

How to store a file with file extension with multer?

And gulp-zip is worth the look too.

https://www.npmjs.com/package/gulp-zip

For streaming, compression might be an option (assuming you are are using express).

https://www.npmjs.com/package/compression

For streaming use fs.createReadStream(...)

https://medium.com/@daspinola/video-stream-with-node-js-and-html5-320b3191a6b6

maelswarm
  • 1,163
  • 4
  • 18
  • 37