drwdvftp423507 2014-01-22 17:28
浏览 161

php在Windows中执行exec时挂起

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

  • 写回答

1条回答 默认 最新

  • dpd3447 2014-01-22 19:57
    关注

    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?

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题