CodeIgniter Tutorial: Upload and Convert video to FLV using FFmpeg.

Author: Zeeshan Rasool  |  Last updated on Codeigniter, Web Development

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.

Recommended WordPress Themes Store

If you enjoyed this post, please consider leaving a comment below or subscribing to the RSS feed to have future articles delivered to your feed reader. You can also follow us on Facebook or Twitter @99Points

This awesome post has been created by 99Points editor's team. You can follow our updates on Twitter and facebook, OR drop an email at

2 to “CodeIgniter Tutorial: Upload and Convert video to FLV using FFmpeg.”

  • ruks November 15, 2013 at 6:07 am

    Hi i put this code in controller but i am unable to upload plz tell me how i do this. plz tell me step by step i am new………


    public function index()

    public function upload_file()
    $status = “”;
    $msg = “”;
    $file_element_name = ‘userfile’;

    $filename = $_FILES[‘userfile’][‘name’];

    if ($status != “error”)
    $config[‘upload_path’] = ‘./uploads/’;
    $config[‘allowed_types’] = ‘*’;
    $config[‘max_size’] = 1024 * 8;
    $config[‘encrypt_name’] = TRUE;

    $this->load->library(‘upload’, $config);

    if (!$this->upload->do_upload($file_element_name))
    $status = ‘error’;
    $msg = $this->upload->display_errors(”, ”);
    $data = $this->upload->data();
    // echo “

    "; print_r($data); die;
                $file_id = $this->files_model->insert_file($data['file_name']);
                $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'];
                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->where('id',$id); // Table where you put video name
    $query = $this->db->update('files_upload'); 
                    $status = "success";
                    $msg = "File successfully uploaded";
                    $status = "error";
                    $msg = "Something went wrong when saving the file, please try again.";
        echo json_encode(array( $status,  $msg));
  • Suresh Gupta February 18, 2015 at 10:56 am

    I used this code but the converter is not worked what to do now…. Please help me…

Email Subscriber!

Be the first to know about new updates



Popular post