【发布时间】:2011-08-24 05:49:03
【问题描述】:
我对安装 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!";
}
有什么方法可以测试 => 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
【问题讨论】:
-
天啊,我想知道为什么。不,不是真的,看起来您正在尝试在 Linux 中运行 Windows 可执行文件。这当然行不通(是的,Wine 存在,但是当您在 Linux 上获得本机支持时,谁会如此疯狂地在 Wine 中运行可执行文件)。所以:只需为你的 Linux 发行版安装 ffmpeg 包,它就可以工作了。
-
@wimvds,是的,我也知道操作系统问题有些问题,但我无法识别并且不知道如何解决它。你愿意指导我在 ubunto 上运行吗...这个脚本...
-
在 Ubuntu 上,发出
sudo apt-get install ffmpeg(在 cli 上),应该安装 ffmpeg(前提是您启用了 Universe 和 Multiverse 存储库)。然后你应该能够只使用exec('ffmpeg -i ... ');来转码文件。有关更多信息(即安装标准构建中缺少的额外编解码器),请参阅Ubuntu Wiki - ffmpeg 页面。 -
@wimvds,我按照您的步骤操作但仍然无法正常工作,而 ffmpeg 是从 cli 安装的...
-
那么ffmpeg不在webuser的路径中,所以要么将该路径添加到webuser的PATH var中,要么在调用
exec时指定完整路径。要定位 ffmpeg,只需从 cli 执行which ffmpeg。
标签: php file-upload ffmpeg video-processing