dqmq0654 2011-10-27 14:40
浏览 67

PHP的FFmpeg导致内部服务器错误

I have a PHP script that calls exec() to convert video files using ffmpeg. The script works fine with smaller files, but larger files, usually around 20MB, produce a 500 Internal Server Error after the conversion has run for about 45 seconds.

The max_execution_time is set to 600 seconds (10 minutes) and the max post and upload sizes are set to 1000 MB. The server is Unix based and is not running in safe mode.

Although the issue only happens with larger sizes, I'm not even sure it's a file size issue. The script will pass with a 12.6MB MOV file but will fail with an 11MB MP4 file.

Below is the exec() line from my script:

exec('ffmpeg -y -i '.escapeshellarg($uploadFile).' -vcodec libx264 -ab 128k -ac 2 -b 640k -g 300 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -maxrate 10M -bufsize 10M -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 30 '.$convertFile);

Thanks!

  • 写回答

1条回答 默认 最新

  • duanchigeng4313 2012-02-22 13:48
    关注

    I've experienced similar issues with PHP and timeouts using mod_fcgid and Apache. mod_fcgid seems to have an issue with scripts that run a long time, and no matter the amount of changing the timeout values I still couldn't get it to play nice all of the time.

    Some options I found to solve this:

    1. Don't use a PHP script - use PHP CLI and a cron job
    2. Don't use mod_fcgid on the site you are using to encode, use a CGI wrapper or even mod_php

    I'm editing this as I've found a very useful set of links which have solved my problem:

    http://profiles.ysn.com/supportforum/viewtopic.php?f=7&t=283&start=15#p1300

    http://www.virtualmin.com/node/19879

    I added:

    <IfModule !mod_fastcgi.c>
        AddHandler fcgid-script fcg fcgi fpl
        IdleScanInterval 10800
        BusyScanInterval 10800
        ZombieScanInterval 60
    </IfModule>
    

    into my fcgid.conf file and

    IPCConnectTimeout 10800
    IdleTimeout 10800
    ProcessLifeTime 10800
    BusyTimeout 10800
    

    into my httpd.conf in the relevant <VirtualHost>, restarted apache and the timeouts have stopped.

    评论

报告相同问题?

悬赏问题

  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么