I am now developing a website about sharing videos in the Internet . the flow is as follows: the user upload the video -> the server-side receives the video and uses ffmpeg to convert the video format to flv -> the user goes on doing other things in the site. now I want to establish another thread to do the convert work(use ffmpeg to convert the video format to flv) such that the user can do other thing without waiting the video converted to flv. but don't know how!
PHP does not support threads. You should use background tasks run by a cron script to do that.
You could have a table with the jobs to be processed, for example, containing the file name on disk, the status (pending, converting, ready), etc, then have a script take all the pending jobs, change their status to converting, convert the files, then change the status to ready. This way you can also present the information to the user, and you could have multiple scripts running if you wish to convert more than one file at the same time.
Looks like a job for a job server. Just add it as a background task
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With