发布于 2014-08-15 16:14:56 | 123 次阅读 | 评论: 0 | 来源: 网友投递

这里有新鲜出炉的CodeIgniter 用户指南,程序狗速度看过来!

CodeIgniter开源PHP开发框架

CodeIgniter 是一个简单快速的PHP MVC框架。EllisLab 的工作人员发布了 CodeIgniter。许多企业尝试体验过所有 PHP MVC 框架之后,CodeIgniter 都成为赢家,主要是由于它为组织提供了足够的自由支持,允许开发人员更迅速地工作。


这篇文章主要介绍了codeigniter上传视频并使用ffmpeg转成flv的示例,这在做视频站时非常有用,需要的朋友可以参考下

 

代码如下:

$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().'<br />';
}
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');
}

 



最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务