【发布时间】:2012-09-08 06:02:37
【问题描述】:
在阅读了有关 FFMPEG 和 PHP 的 SO 上的大量问题后,我收集了一个小的 sn-p 或其他类似的东西,但它似乎没有做任何事情 - 甚至没有抛出错误。
我的PHP如下:
function get_video_thumbnail($file) {
define('ALL_PLACE_WIDTH', 250);
define('ALL_PLACE_HEIGHT', 200);
$ffmpeg = "ffmpeg"; // where ffmpeg is
$image_source_path = $file; // where the video is
$image_cmd = " -r 1 -ss 00:00:10 -t 00:00:01 -s ".ALL_PLACE_WIDTH."x".ALL_PLACE_HEIGHT." -f image2 "; // command
$dest_image_path = "cdn/thumbnails"; // destination of thumbnail
$str_command = $ffmpeg ." -i " . $image_source_path . $image_cmd .$dest_image_path;
shell_exec($str_command);
}
在根文件夹中有一个文件夹“ffmpeg”,里面有“ffmpeg.exe”、“ffplay.exe”和“pthreadGC2.dll”。所以我想知道,我有什么遗漏吗?我正在尝试从视频/mp4 文件生成缩略图。
【问题讨论】:
-
如果您从命令行运行相同的参数,您会生成缩略图吗?如果您运行
exec(escapeshellcmd($cmd), $out, $val),您会在输出 $out 和 $val 中看到什么?分解它 - 首先尝试先执行一个简化版本,以了解通过 PHP shell 调用时 ffmpeg 是否正常工作。例如'ffmpeg -h' -
我就是这样做的: $exec_string = "ffmpeg -y -ss ".($position)." -i $filebase.mpg -vf scale='iw:ow/dar', setsar=1:1 -deinterlace -t 1 $output_base";你在-ss之前设置-t很奇怪,应该是-t 11
标签: php ffmpeg thumbnails