2

我是 FFmpeg 的新手,但作为一个学习一些 mysql 数据库的项目,我正在尝试创建一个视频上传网站。

当我尝试使用此代码制作缩略图时:

shell_exec("/usr/local/bin/ffmpeg -i anim.flv -an -ss 00:00:03 -an -r 1 -vframes 1 -y test.jpg");

没有任何反应,没有图像出现在与 anim.flv 相同的目录中,代码是否有问题或可能是什么问题?

4

3 回答 3

1

这对我有用:ffmpeg -ss 00:00:10 -i $file -y -an -vframes 1 $dir/$name.png

于 2012-11-15T13:55:55.137 回答
0

试试这个命令:

$infile = 'anim.flv';
$outfile = 'test.jpg';
exec("/usr/local/bin/ffmpeg -i " . escapeshellarg($infile) . " -an -ss 00:00:03 -an -r 1 -vframes 1 -y " . escapeshellarg($outfile) . " 2>&1", $output, $returnValue);
if (!file_exists($outfile)) {
     die("Could not generate thumbnail. ffmpeg output: \n\n" . implode("\n", $output));
}

这样,当 ffmpeg 不起作用时,您将从 ffmpeg 获得一些详细的输出(“2>&1”将 ffmpeg 的错误输出重定向到标准输出;否则您将无法检索它)。

我有 2 条建议可以解决您的命令;首先,在指定输出文件之前添加参数“-vcodec mjpeg -f rawvideo”,其次,对输入和输出使用绝对路径,这样您就不必担心脚本的当前工作目录在哪里。

于 2012-11-15T14:02:19.913 回答
0

试试这个代码

$flvfile = 'clock.flv';
$imagefile = 'test.jpg';
exec('ffmpeg  -i ' . $flvfile . ' -f mjpeg -vframes 1 -s 150x150 -an ' . $imagefile . '');
于 2013-08-14T11:06:51.387 回答