Reputation: 773
I allow users to upload videos and then they get converted using ffmpeg. The video takes a really long time to convert which usually results in an error. I have done my research with no luck as to where I should get started.
Basically what I want to do is allow the user to upload the video and then display a message that says video is being processed and you will be notified when available. In the meantime I want the video to be converted behind the scenes and allow the user to leave the page or even close the browser. I am using a Windows server.
How can I accomplish this?
Upvotes: 0
Views: 840
Reputation: 20430
Here is a basic run-down of how to make your own queue using a scheduling system such as Cron:
queue
containing (id, created_at, file_path, id_user, result, error)
. The file_path
contains the location of the uploaded video to process, the result is null
before processing and then true/false
afterwards depending on success, and if it failed error
contains any messages. The primary key of the user table can be saved here too, if appropriate.ps aux | grep (scriptname)
to help here, if you are running in a *nix-like operating system.Inside your web application, you need to somewhat modify the workflow - rather than expecting a video to be processed immediately, you need to:
This approach is very useful for shared hosting where you cannot install your own queue processors. However, if you are on a VPS or cloud system, you may wish to look into Gearman or one of many other queueing systems. They are a bit more complex than the above, but have more features for managing queues of work.
Upvotes: 2