I am converting a video using ffmpeg from php in Windows using following code
<?php
exec('ffmpeg -i input.mp4 -ar 22050 -ab 32k -r 25 -s 480x360 -vcodec h264 -qscale 2.5 output.flv');
?>
While converting script hangs until conversion completed.
What can i do about it? So that it can run in background
If your system is Linux I would just background the task by adding ' &' to the end of the command.
exec('ffmpeg -i input.mp4 -ar 22050 -ab 32k -r 25 -s 480x360 -vcodec h264 -qscale 2.5 output.flv &');
Or to be even more thorough (i.e. even if apache dies the file will still be transcoded):
exec('bash -c "exec nohup setsid ffmpeg -i input.mp4 -ar 22050 -ab 32k -r 25 -s 480x360 -vcodec h264 -qscale 2.5 output.flv > /dev/null 2>&1 &"')
Don't you have to call ffmpeg.exe on windows?