0

Hey I am using ffmpeg to store live camera streaming in PHP. I have already downloaded the compiled ffmpeg library and just use its path in php to store stream. The command is :

C:\ffmpeg\bin\ffmpeg -i "http://10.11.16.120:90/livestream.cgi?user=admin&pwd=&streamid=0&audio=0&filename=" -c:v libx264 -t 10 -an F:\Camera_Videos\video.mp4

Now it waits until ffmpeg compeletes its task and then php code will further run but i want to run ffmpeg in background i have also tried this by adding

> /dev/null 2>/dev/null &

but it didn't work . Pleae tell , any help would be appreciated.

Emii Khaos
  • 9,983
  • 3
  • 34
  • 57
Zohaib Khalid
  • 63
  • 1
  • 2
  • 9

1 Answers1

0

From what I understand, you basically want to run ffmpeg in the background 'asynchronously'.

I was going through a relevant SO Post on how to run a batch file in background in windows.

So you could put the following code in a file (let's say foo.bat)[Untested code]:

C:\ffmpeg\bin\ffmpeg -i "http://10.11.16.120:90/livestream.cgi?user=admin&pwd=&streamid=0&audio=0&filename=" -c:v libx264 -t 10 -an F:\Camera_Videos\video.mp4

And then in your php script you could execute foo.bat as per the answer using shell_exec or system.

I haven't tested the approach above. It just might be a good starting point for you. Hope it helps.

Community
  • 1
  • 1
Vivek Pradhan
  • 4,777
  • 3
  • 26
  • 46