Jump to content

What Do You Think To This Method? PHP Forcing Server To Wait


johnsmith153

Recommended Posts

I am uploading video files, then encoding online using an online encoder.

 

(1) File sent through PHP (picked up using $_FILES)

(2) API in the PHP script then sends video to the encoding tool (this is a different company / totally different sever).

(3) Few Minutes Later, encoding tool returns info on the video (resolution, bit rate etc.)

(4) PHP script uses this info to decide what files to then produce - ie if uploaded video is widescreen etc, encode at widescreen resolution.

(5) PHP script ends, user sees message saying if everything succesful or not so far, and the encoding tool creates files in the background.

(6) Final http message can be sent by encoding tool once this is then complete in their server - although user uploading wont see this as would be 10minutes later or so.

 

The problem is, step (3) and (4) take time, so the PHP script has to be paused (on my server) - whilst I wait for the encoding tool to return the information (i.e it needs to fully receive the file as well and then send me the bitrate / resolution etc.)

 

Take steps (3) and (4) away and you have a simple process. PHP uploads the file, then everything else is done fully by the encoding tool - whilst the user can move on as the PHP script has ended - but you dont get any info on the source video, and no error checking. I.e what if source was 10 hours long - I dont want to encode this. (I am charged per GB encoded)

 

I currently use a "while" loop that checks every 10 seconds (using another API send command) if the video has been uploaded yet or not. This is obviously holding the PHP script on my server whilst this happens.)

 

Bear in mind this is a big project that I expect thousands of videos to be uploaded and viewed.

 

Do I?

 

(1) Leave steps (3) and (4) but use a standard resolution, bit rate etc. Videos will have black bars top and side and quality will be a lot less because you are guessing the source video. I am very unlikely to go with this. Also cant check video size, but can obviously check to ensure not uploading .exe .php etc.

 

(2) Do it as above but set "max_execution_time" to very high in the php.ini. I will be using a dedicated server for this when it goes public.

 

(3) Or, do it in the order below:

 

(1) File sent through PHP (picked up using $_FILES)

(2) API in the PHP script then sends video to the encoding tool (this is a different company / totally different sever).

(3) No other values are sent, just the video to be uploaded to their servers

(4) PHP script ends, user sees message saying if everything succesful or not so far - (but no files created yet obviously)

(5) When completed, http message sent by encoding tool with resolution / bit rate / video ID - although user is long gone as would be much later.

(6) This PHP only page (not user accessable of course) receives all the values from the http message (with bit rate / resolution etc.) and THEN it creates the encoding action and the files

(7) If there are any errors from here, tough luck - only admin will see them.

 

 

Still reading?!! Any ideas?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.