Search code examples
apacheubuntuwebservervideo-encoding

Encoding Videos In cloud Using Linux scripts or some softwares installed on linux


I want to encode the videos, which user uploads, similar to youtube which transforms whatever video type you upload to flv, mp4,webm . Because i can only play webm,html5 video in my Webapp So i need to do this thing. I have tried www.zencoder.net But thats costly for me, because i have to encode too much videos most of the time.

Is there any solution, how this can be done, I have ubuntu 12.04 server ,I think this could be done by scripting or just parsing videos to already installed encoding software, But dont know how to pass the videos to encoder, And what encoder should i install on my linux.

I am using php as server side language in my cloud storage website


Solution

  • You can do this by encoding the videos with FFmpeg.

    On the command line you could use: ffmpeg -i file.mp4 file.mp4.avi

    You can use ffmpeg-php with PHP to get some ffmpeg features. But it looks like you will have to use the command line with the php exec function.

    $fileToFlv="/var/www/test/input.wmv";
    $fileFlv="/var/www/test/test.flv";
    
    exec("/usr/bin/ffmpeg -i ".$fileToFlv." -ar 22050 -ab 32 -f flv -s 320x256 ".$fileFlv);