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 ');
}