PHP文件应该在此命令完成后执行FFmpeg命令,它应该将数据带入数据库。但是,我发现exec($command--FFmpeg)
已经完成,运行得很好,但数据不在数据库中。
我已设置php.ini ignore_user_abort = On
它可以在后台运行PHP进程
我可以如下
set_time_limit(0);
$tumbfileName = time();
$filepath = dirname(dirname(dirname(__FILE__))) . "/files/video/";
$cmd = 'ffmpeg -i ' . dirname(dirname(dirname(__FILE__))).$content . ' -c:v libx264 -strict -2 ' . $filepath . "post_" . $tumbfileName . '.mp4';
exec($cmd, $output, $error);
$cmdImg="ffmpeg -y -ss 2 -i ".dirname(dirname(dirname(__FILE__))).$content." -vframes 1 -f image2 -s 400*300 ".$filepath . "notice_thumb_" . $tumbfileName . '.jpg';
//$cmdImg = "ffmpeg -i " . dirname(dirname(dirname(__FILE__))).$content . " -f image2 -ss 10 -s 400*300 -vframes 10 " . $filepath . "notice_thumb_" . $tumbfileName . '.jpg';
exec($cmdImg, $outputImg, $errorImg);
$data = array(
'content' => "/files/video/"."post_" . $tumbfileName . '.mp4',
'author' => 'management',
'deadline' => $deadline,
'type' => $type,
'datetime' => time(),
'thumb' => "/files/video/"."notice_thumb_" . $tumbfileName . '.jpg'
);
$flag = $this->db->insert('notice_info', $data);