CodeIgniter Tutorial upload video and use FFmpeg to turn the FLV sample _php instance

Source: Internet
Author: User
Tags codeigniter

Copy Code code 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 '. $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

EXEC ("Ffmpeg-i". $directory _path_full. " ". $directory _path. $file _name.". flv ");

$file _name is same file name this is being uploaded but your can give your custom video name over converting so use som Ething like myfile.flv.

In the "End Update" name in DB
$array = Array (
' Video ' => $file _name '. ' FLV ',
);
$this->db->set ($array);
$this->db->where (' id ', $id); Table where you put the 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.