>  기사  >  백엔드 개발  >  codeigniter教程之上传视频并使用ffmpeg转flv示例_PHP教程

codeigniter教程之上传视频并使用ffmpeg转flv示例_PHP教程

WBOY
WBOY원래의
2016-07-13 10:37:321141검색

复制代码 代码如下:

$file = 'video_file';
$config['upload_path'] = './video_folder/';
$config['allowed_types'] = 'mov|mpeg|mp3|avi';
$config['max_size'] = '50000';
$config['max_width']   = '';
$config['max_height']   = '';

$this->upload->initialize($config);
$this->load->library('upload', $config);

if(!$this->upload->do_upload($file))
{
// If there is any error
$err_msgs .= 'Error in Uploading video '.$this->upload->display_errors().'
';
}
else
{
$data=array('upload_data' => $this->upload->data());
$video_path = $data['upload_data']['file_name'];
  $directory_path = $data['upload_data']['file_path'];
$directory_path_full      = $data['upload_data']['full_path'];
$file_name = $data['upload_data']['raw_name'];

// ffmpeg command to convert video

exec("ffmpeg -i ".$directory_path_full." ".$directory_path.$file_name.".flv");

// $file_name is same file name that is being uploaded but you can give your custom video name after converting So use something like myfile.flv.

/// In the end update video name in DB
$array = array(
'video' => $file_name.'.'.'flv',
);
$this->db->set($array);
$this->db->where('id',$id); // Table where you put video name
$query = $this->db->update('user_videos');
}

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/735248.htmlTechArticle复制代码 代码如下: $file = 'video_file'; $config['upload_path'] = './video_folder/'; $config['allowed_types'] = 'mov|mpeg|mp3|avi'; $config['max_size'] = '50000'; $config['...
성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.