Check status of background convert for videos

hello guys

its been a while since my last question here :stuck_out_tongue:

am working right now on PHP script to upload and convert video files to several resolutions ( 360 - 720 ),

here a piece of my php code to convert

move_uploaded_file($file_tmp, 'upload/'.$fileName);
//where add_to_queue is simple function to add these information to queue table
$cmd = 'ffmpeg -i upload/'.$fileName.' -vf scale=480:360 -c:v libx264 -q:v 1 -strict experimental -c:a aac -b:a 160k convert/360-'.$fileName.' >/dev/null 2>/dev/null &';

now everything here is OK and working great, but I need to check if the
video encoding is completed and update the “status” column in queue
table set it to complete and delete original file in “upload” directory.

another thing , I want only 5 videos for example to be encoded at same time to save server resources.

Could you use proc_open() instead of shell_exec(), and then use proc_get_status() to figure out how it’s going? Or instead of calling ffmpeg directly, embed it in a batch file of whatever kind your OS allows, and have the final part of that batch file execute a query that updates the status column.

[off topic] Have you considered uploading the largest video to YouTube and let them handle the conversion? [/off topic]

You could use proc_open() as droopsnot said, and you could also output the response of the ffmpeg call in the cmd to a file and then parse the output for the status. And there is this function proc_close() which returns the result of the command, but i don’t know what will happen if any error occur.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.