Question

Managing large video / audio file uploads and streaming (Laravel project)

Posted October 16, 2021 115 views
PHPPHP FrameworksStorageLaravel

Hi all,

maybe someone can point me in the right direction. I have developed a Laravel PHP project which allows people to upload and watch large video files (as well as audio files). Those files are confident and specific to a group of users, i.e. they shall not be publicly accessible. For now, the PHP code takes care of the permissions as to who can upload a video for which group and who can watch a video. It’s also important that those videos can be streamed in a speedy fashion for the users who are authorized to watch them.

If I think about the traditional way, managing such files requires me to e.g. offer a “resume upload” function, ideally converting the file to the best format (MP4 or such) to conserve storage space, then storing the file in a file directory under a unique name, and finally offering it for download or viewing in the authorized user’s browser. But I’m not sure if this will scale and it seems very old school to handle it all in PHP.

I heard about Azure Media Services which might help with handling such large video files but I would like to try something like this on DO first (sensing better documentation and community support since I’m new to all this).

Here are my specific questions:

  • Which DO file storage can be recommended for storing and accessing large video files (several GB per file and easily quite a few TB overall)?
  • How can end users upload new videos to that storage? I would assume that they log in to my PHP app, and then start uploading from there (do I need to build in upload resume functions in case of network interruptions?). In the background, the file gets a unique name and is being sent to storage or (ideally) gets processed first into a uniform video file format (such as MP4 or something)…?
  • Is the server-side handling of uploads a potential issue due to network bottlenecks or other limitations? How can I make sure that several users can upload large videos at the same time?
  • Accordingly, how do I deliver files for streaming through my app?

Ideally, I would like to use an endpoint which takes care of uploads (including resuming of uploads), compilation of the video files, naming them in a unique fashion, storing them, and streaming them. The only info I would require is the name of the file and a URL that can be given to the authorized user to watch the video.

Many thanks in advance!

Cheers,
Ingo

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
1 answer

Which DO file storage can be recommended for storing and accessing large video files (several GB per file and easily quite a few TB overall)?

DigitalOcean Spaces
https://www.digitalocean.com/products/spaces/

I would assume that they log in to my PHP app, and then start uploading from there (do I need to build in upload resume functions in case of network interruptions?). In the background, the file gets a unique name and is being sent to storage or (ideally) gets processed first into a uniform video file format (such as MP4 or something)…?

Yes. You’ll need to build resume functionality. No idea the complexity of implementing such a feature, but I believe it’s something you’ll have to handle in your Laravel code. The logic of how that will happen, no idea.

Is the server-side handling of uploads a potential issue due to network bottlenecks or other limitations? How can I make sure that several users can upload large videos at the same time?

If you expect the number of uploads to be as big as YouTube today, then you’re gonna need YouTube’s kinda infrastructure and scale. Depending on your user base, you can always scale your backend server and performance, and increase your bandwidth demands accordingly on DigitalOcean.

Accordingly, how do I deliver files for streaming through my app?

DigitalOcean CDN
https://www.digitalocean.com/community/tutorials/using-a-cdn-to-speed-up-static-content-delivery

by Hanif Jetha
A content delivery network can be a quick and effective solution for improving the scalability and availability of your web sites. By caching static assets on a geographically distributed network of optimized servers, you can greatly reduce page load times and latencies for end users. In addition, CDNs allow you to significantly reduce your bandwidth usage by absorbing user requests and responding from cache at the edge, thus lowering your bandwidth and infrastructure costs.