Codeigniter tutorial-upload a video and use ffmpeg to convert to flv example _ php instance

Source: Internet
Author: User
Tags codeigniter
This article describes how to use codeigniter to upload a video and convert ffmpeg to flv. For more information, see The Code is as follows:


$ File = 'video _ file ';
$ Config ['upload _ path'] = './video_folder /';
$ Config ['allowed _ types'] = 'mov | mpeg | mp3 | avi ';
$ Config ['max _ size'] = '000000 ';
$ 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 ');
}

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.