0
我正在codeigniter中工作。我在爲視頻文件創建縮略圖時遇到了問題。如果有任何人可以給我使用codeigniter生成視頻文件縮略圖的代碼。我使用下面的代碼使用ffmpeg擴展名爲圖像生成了縮略圖。它總是給出空值。當嘗試使用ffmpeg codeginiter創建視頻縮略圖時,shell_exec函數總是給出空值
function upload_video()
{
$files = $_FILES;
$cpt = count($_FILES['video']['name']);
$this->load->library('image_lib');
for($i=0; $i<$cpt; $i++)
{
$_FILES['video']['name']= $files['video']['name'][$i];
$_FILES['video']['type']= $files['video']['type'][$i];
$_FILES['video']['tmp_name']= $files['video']['tmp_name'][$i];
$_FILES['video']['error']= $files['video']['error'][$i];
$_FILES['video']['size']= $files['video']['size'][$i];
$this->load->library('upload', $this->upload_options());
$this->upload->initialize($this->upload_options());
$this->upload->do_upload('video');
$files_uploaded=$this->upload->data();
$f_name=$files_uploaded['client_name'];
$directory_path=$files_uploaded['file_path'];
$directory_path_full=$files_uploaded['full_path'];
$out=shell_exec("ffmpeg -y -i C:\xampp\htdocs\photo24\video\140902video-2012-07-05-02-29-27.mp4 -f mjpeg -ss 10 -vframes 1 160x120 C:/xampp/htdocs/photo24/video/thumb/mythumb.jpg 2>&1");
file_put_contents($dir.'cmd.log', $cmd); // to debug
//var_dump($out);
echo $file_array_data = $this->upload->display_errors();
$this->user_model->add_video($files_uploaded);
}
}
而且好像你正在做一個背景proccess所以PHP不等待線完成的端部的cmd「.... 2>&1」會發揮這種效果 – 2014-09-02 09:50:52