I am developing a website for downloading videos, and I have a dilemma: downloaded videos need to be converted to FLV format for display to the visitor, but if I execute the command in a script, the script will hang for 10-15 minutes while FFMPEG converts the video.
I had the idea of โโinserting a record into the database indicating that the file needs to be processed, then using the cron job set every 5 minutes to select the records from the database that need to be processed, process them, and then update in the database where they are were processed. My concern with this is that there are too many processes running and the server crashing under stress, and does anyone have any solutions for this or a way to improve the process that I have in mind?
Ok, now this is what I mean, so the user uploads the video, and the row is added to the database, indicating that the video needs to be processed. The cron task, set every 5 minutes, checks what needs to be processed and what is being processed, say, I would do a maximum of five processes at a time, so the script will check whether any video needs to be processed and how much video is processed if it is less than five , it updates the record indicating that it is being processed, after processing the video, it updates the record indicating that it has been processed, and the cron job starts again, any thoughts?
source share