bretanac93 bretanac93 - 18 days ago 6
PHP Question

How can I upload videos and convert it async in Laravel?

the thing is just like my title says, I am already uploading videos to the server, store their path in the db, and save them to the storage using the

Storage
facade, the videos have an average weight of 700MB or so, and they are for watching on the own website I am building, I'm using VideoJS to show them, but I need to convert them due to the incompatibility with different browsers, I already know that FFMPEG done this painless, but I want to know how to make it async, just like the Youtube upload video tool. The videos are uploaded from the admin dashboard only, so, there will be only one person uploading videos. Thanks for the time.

Answer

Have a look at Laravel's queue features: https://laravel.com/docs/5.3/queues

You can create a job class that takes the path/filename of the video it is supposed to processed. Then in the job's handle method you do the conversion. The Laravel documentation explains how to create a Job class and use it.