CodeIgniter Tutorial upload video and use ffmpeg to FLV sample _php instance

Source: Internet
Author: User
Tags codeigniter
Copy CodeThe code is as follows:
$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 "is being uploaded" can give your custom video name after converting so use som Ething 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 ');
}

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.