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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | $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().'<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 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'); } |
Who I Am

Zeeshan Rasool
Software Engineer - PHP
Lahore - Pakistan
zeeshan(@)99points.info
Skype: zeeshan-rasool
gTalk: zishan.rasool85
Categories
- AJAX (37)
- Codeigniter (16)
- CSS (16)
- Facebook (11)
- Joomla (1)
- JQuery (53)
- Miscellaneous (4)
- Mootools (1)
- MySQL (6)
- PHP (60)
- SEO (2)
- Technology (6)
- Tutorials (15)
- Twitter (2)
- Web Design (23)
- Web Development (57)
- WordPress (2)
Tags
Comments
- ZeeShaN on Facebook Wall Script Clone with JQuery and PHP: Personal Project BETA Version 2.0
- 20 + Fresh jQuery Image Gallery/Slider Plugins and Tutorials Worth a Look | free on JQuery Based Flipped Image Gallery with Bounce Effects
- 20 + Fresh jQuery Image Gallery/Slider Plugins and Tutorials Worth a Look | free on Fresh JQuery Image Gallery with Captions and Auto Play/Pause Rotation
- 25 Cool and Helpful jQuery Plugins/Tutorials For Your Next Project | free on jQuery Tutorial: Create jQuery and CSS based Awesome navigation.
- 25 Cool and Helpful jQuery Plugins/Tutorials For Your Next Project | free on Ajax Tutorial: How to Create Ajax Search Using PHP jQuery and MYSQL
ZeeShaN







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
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?
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 ?
for windows based server, you should place ffmpeg.exe file in project folder root. But on linux server the ffmpeg should be installed.
Could u tell me ho can i used ffmpeg in wamp server i cant figure it out
how can take the image from video using ffmpeg
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 )
please, give download link for ffmpeg.exe !!!!
@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
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.