Search code examples
phpfile-uploadffmpegvideo-processing

Ffmpeg installation And Converting VIdeo's:


I am confused with instruction to install ffmpeg-php for video converting... There are some guide us to download and put files in particular folder and then convert files, but some instruct through another way, where you must download ffmpeg.exe and place it local and then call it from php to convert file.....

So which one is the best and how to install it....?????

Now i download ffmpeg and execute this script but not working, and give rights also...

$ffmpeg = "ffmpeg/ffmpeg.exe";
$desvfile = $_POST['file'];
$curr_dir = dirname(__FILE__);
$flvfile = $curr_dir."/converted/new1.flv";

if(file_exists($ffmpeg)){
    $cmd = "ffmpeg/ffmpeg.exe -i ".$desvfile." -ar 22050 -ab 32 -f flv -s 320×240 ".$flvfile; 
    exec($cmd, $output); 
    echo "executed command: [".$cmd."] with result: ".print_r($output, true)."<br>\n";
    echo "Successfully video Converted, to video.flv";
}
else{
    echo "There is some problem during converting!";
}

There is any way, to test => exec(ffmpeg) functionality....?????

UPDATED!

if(file_exists($desvfile)){
    echo "Destination file Exist. <br />";
    $cmd = "$ffmpeg -i '$desvfile' -ar 22050 -ab 32 -f flv -s 320×240 '$flvfile'"; 
    exec(escapeshellcmd($cmd), $output); 
    echo "executed command: => [".$cmd."] <br />with result: => ".print_r($output, true)."<br>\n";
    echo "Successfully video Converted, to video_converted.flv";
 }
else{
    echo "There is some problem during converting!";exit;
}

Which give me the output,,, but not execute the video to convert....

Output:

// Destination file Exist.

// executed command: => [/var/www/html/test_site/converter/ffmpeg/ffmpeg.exe -i '/var/www/html/test_site/converter/uploads/Gazzump.com - YouTube - Anders And.avi' -ar 22050 -ab 32 -f flv -s 320×240 '/var/www/html/test_site/converter/converted/new1.flv']

// with result: => Array ( )

// Successfully video Converted, to video_converted.flv

Solution

  • I've always found it easier to call FFMPEG with exec(). It is much easier to find exe builds of FFMPEG than the PHP extension. There is no install procedure for this method... just put the EXE somewhere on the server that is accessible by whatever account PHP is executing as.

    There is no "best way" really. Both methods of accessing FFMPEG will produce the same output.