CodeIgniter Tutorial: Upload and Convert video to FLV using FFmpeg.
Today, I will show, how can we upload and convert a video file to flv using FFmpeg in CodeIgniter website. FFmpeg commands runs in Linux but in Window server we need to download FFmpeg.exe file from its site. Which we have to put in our site root folder. IF your server is Linux then you also need verify that your hosting server has FFmpeg installed or you need it to be installed. For checking FFmpeg availability print phpinfo() in any file and run this command on server where you will get PHP version and other server settings. Find FFmpeg on that window if it doesn’t found then it means server has no FFmpeg installed.
Here is uploading code of video file in CodeIgniter.
$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 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');
}
23 to “CodeIgniter Tutorial: Upload and Convert video to FLV using FFmpeg.”
Post comment

Categories
- AJAX (28)
- Announcement (3)
- Blogging Tips (1)
- Codeigniter (16)
- CSS (14)
- Facebook (8)
- Freelance Tips (1)
- How-To (2)
- Joomla (1)
- JQuery (51)
- Miscellaneous (3)
- Mootools (1)
- MySQL (3)
- PHP (57)
- SEO (2)
- Technology (6)
- Tutorials (17)
- Twitter (2)
- Web Design (26)
- Web Development (58)
- WordPress (3)
Popular post
- 46 Highly Responsive Admin Templates for Your Websites
- $50 PayPal Cash & 5 Premium PHP Wall Script Prizes #Giveaway
- PHP Wall Script Clone with Real Time Features __ January 2013 Release __
- Things you should know if you are a Blogger
- Top 10 Must Have Qualities of a Freelance Web Developer
- Fundamental Factors for Mobile Compatible eCommerce Hosting
- Facebook Wall Script New Version in September 2012
Recommend


Hi To All,
I was try using this code but it”s not working. please help me.
Thank You.
this not work
please fix this
ineed it please
thanks
how can i install FFMPEG in my PC and include the ffmpeg file in php. please give me the reply as so as possible.
hi,
For windows, you need to download ffmpeg.exe from ffmpeg site. Just download that file and paste it in main root directory where your project is hosted.
And just use the simple command with exec(“ffmpeg -i OR system(“ffmpeg ” to get it working.
For Linux server, you need to install ffmpeg plugin on server but I dont how to install it.
So you should get some help.
hi i have installed ffmpeg in php also in ffmpeg in root folder that is C:\ffmpeg|ffmpeg.exe
i uplaoded n convered video files in php but now i m trying to use ths in codeigniter.. to me i see some problems in ur code culd u tell me that this code worked in ur codeigniter..
u r using this code in controller.. plz help us..
Yes im using this code in codeigniter and put ffmpeg.exe in that folder where your project is hosted. c:\wamp\www\yourProjectFolder\ffmpeg.exe
and then use above code.
Good Luck !
(@zeeshan) hi i msged u before but so far u didnt reply, please tell me where is ur code converting video to flv format. it only uploads file so far i ve corrected n run this code.. plz give me ur wise tip.
thanks.
Thank You For you post.
It is work properly. I was add following exec. Than it work properly.
exec(the/path/to/ffmpeg.exe.”ffmpeg -i “.$directory_path_full.” “.$directory_path.$file_name.”.flv”);
Thank you.
@Zaraq, hi You can get your answer in shahmy’s comment.
@Shahmy, You can also put this ffmpeg in same root folder where your project is hosted.
Cheers
please, give download link for ffmpeg.exe !!!!
hi, I use xampp version 5. I can not implement ffmpeg. Please, anybody!
If anybody has ffmpeg files, upload and guide how to implement it on my localhost ( xampp )
how can take the image from video using ffmpeg
Could u tell me ho can i used ffmpeg in wamp server i cant figure it out
for windows based server, you should place ffmpeg.exe file in project folder root. But on linux server the ffmpeg should be installed.
I put the code in the controller, copy the ffmpeg in root folder and make a uploader view, the video is loaded in the host, but still in .mov extension, I tried shahmy solutions but send error, which can be error ?
If I add 3gp|mp4 it doesn’t work do I need to change something in exec(“ffmpeg -i “.$directory_path_full.” “.$directory_path.$file_name.”.flv”);
The error is: the file extension is not allowed:
$config['allowed_types'] = ‘mov|mpeg|mp3|avi|3gp|mp4′; is my allowed hings!
What can it be?
a problem i can’t upload the flv the ffmpeg exe doesn’t work ! i install it in my web base application (work on easyphp) ! somedy help me please
hello…the flv conversion from mov file is not working..please help………..
hi,
i have this error
_____________________________
Severity: Notice
Message: Undefined property: Test::$upload
Filename: controllers/test.php
Line Number: 22
____________________________
…
$config['max_width'] = ”;
$config['max_height'] = ”;
Line 22 $this->upload->initialize($config);
$this->load->library(‘upload’, $config);
if(!$this->upload->do_upload($file))
…
Thanks for sharing! I never managed to make this work with Windows hosting and that’s why I have Linux with FFmpeg installed.
may be u should check mime file.
can you please make a tutorial wherein it allows to upload a csv file,,.match the csv fields to a fields in a certain table in db and if the fields match then it will insert whatever record the csv has,..,please thank you in advance
i am beginner in codeigniter.i don,t know how to upload video,will u say step by step procedure for upload a video?help me plz,