Ffmpeg安装和转换VIdeo:

时间:2011-05-12 15:30:59

标签: php file-upload ffmpeg video-processing

我对安装ffmpeg-php进行视频转换的说明感到困惑...有一些guide us要下载并将文件放入特定文件夹然后转换文件,但有些人通过another way进行指导,你必须下载ffmpeg.exe并将其置于本地,然后从php调用它来转换文件.....

哪一个是最好的以及如何安装.... ?????

现在我下载ffmpeg并执行此脚本但不能正常工作,并给予权限......

$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!";
}

有任何方法,测试=&gt; exec(ffmpeg)功能.... ?????

已更新!

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;
}

哪个给我输出,,,但不执行视频转换....

输出:

// 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

1 个答案:

答案 0 :(得分:3)

我总是发现使用exec()调用FFMPEG更容易。找到FFMPEG的exe版本要比PHP扩展容易得多。这个方法没有安装过程......只需将EXE放在服务器上的某个地方即可由PHP执行的任何帐户访问。

真的没有“最佳方式”。两种访问FFMPEG的方法都会产生相同的输出。