php - FFMPEG 与 PHP 不执行?

标签 php ffmpeg thumbnails

在阅读了关于与 FFMPEG 和 PHP 相关的 SO 的大量问题后,我收集了一个小片段或其他什么,但它似乎没有做任何事情 - 甚至没有抛出错误。

我的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 文件生成缩略图。

最佳答案

cdn/thumbnails 是文件夹吗?如果是这样,您必须提供文件名。你只给了一个文件夹。因此它不起作用。由于您希望每秒一个 10 秒,因此您必须提供类似 cdn/thumbnails/images%03d.jpg 之类的内容作为输出。

所以你的命令看起来像这样:

ffmpeg -i inputfile -s widthxheight -f image2 文件夹/文件名%04d.jpg

转到命令行并首先键入命令。确保它在那里工作。然后它将在 php 中工作。

文件将被命名为 filename0000.jpg filename0001.jpg 等等。

关于php - FFMPEG 与 PHP 不执行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12435245/

相关文章:

php - 当有新数据可供显示时,如何在已打开的网页上显示对话框?

谷歌浏览器中的 JavaScript

pdf - GhostScript 命令从 PDF 文件创建缩略图

php - Wordpress 在选择自定义字段时应用特定的 css

php - CodeIgniter + jQuery UI 自动完成 = 500 内部服务器错误(带有代码)由于 CSRF 设置为 TRUE

ffmpeg - YouTube Live 不适用于 FFMPEG

php - 为 HLS 创建主播放列表

video - 使用ffmpeg从视频中提取多张图片并获取提取图片的时间戳

python - 如何使用 PIL 生成圆形缩略图?

node.js - 从 Node.js 中的流生成 ffmpeg 缩略图