Jump to content

Best way to achieve this?


RuleBritannia

Recommended Posts

Hello, I come accross this problem and im wondering how you may solve it.
 I believe I have one workign way but it might not be the best.

 

So I am executing ffmpeg though php, and directing STDERR STDOUT to a log file, my php will run this without waiting for results.

 

After the execution instance has been sent, I will check the log file to get some information directly after, The problem is, The log file has not yet been created, So it will not exist.

 

Currently, I thought to call a loop allowing for a maximum of 10 seconds to pass checking each for log existence each second, If after 10 seconds there is still no log, assume error.

 

Example just for theory purposes(not tested)

$start = 1;
$finish = 10;

while($start <= $finish)
{
    if($file_get_contents($log))
    {
        $result = file_get_contents($log);
        $finish = 10;
    }
    
sleep(1);
$start++;

}

Im assuming this may work, But there maybe a better way to acheive this, How would you do it?

 

Thanks

Edited by RuleBritannia
Link to comment
Share on other sites

Just a couple of thoughts...

1. why haven't you tested?

2. I belive you mean to increment $start to 10 in your while loop rather than $finish (as $finish is already set to 10)

 

1. I have tested and it works, I just wrote this thread before implementing my theory, Assumed it would work because it wasnt very complex.

2. yes

 

This approach works, But cant be the best way.

Link to comment
Share on other sites

to those who maybe interested.

 

I decided to take a differnt approach, instead of reading from a log file, I decided to wait for the process(let php hang) to finish and output results to a variable, then test for errors or success information, This way seems more reliable than checking for logs etc, too many problems can arise from this.

 

Thanks

Edited by RuleBritannia
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.