gpt4 book ai didi

node.js - fluent-ffmpeg 缩略图创建错误

转载 作者:搜寻专家 更新时间:2023-10-31 22:35:48 25 4
gpt4 key购买 nike

我尝试使用 fluent-ffmpeg 创建视频缩略图这是我的代码

var ffmpeg = require('fluent-ffmpeg');

exports.thumbnail = function(){
var proc = new ffmpeg({ source: 'Video/express2.mp4',nolog: true })
.withSize('150x100')
.takeScreenshots({ count: 1, timemarks: [ '00:00:02.000' ] }, 'Video/', function(err, filenames) {
console.log(filenames);
console.log('screenshots were saved');
});
}

但我一直收到这个错误

  "mate data contains no duration, aborting screenshot creation"

知道为什么,

顺便说一句,我在windows上,我把ffmpeg文件夹放在c/ffmpeg,我把ffmpeg/bin添加到我的环境变量中,我不知道fluent-ffmpeg是否需要知道ffmpeg的路径,但是我可以使用下面的代码成功创建缩略图

   exec("C:/ffmpeg/bin/ffmpeg -i Video/" + Name  + " -ss 00:01:00.00 -r 1 -an -vframes 1 -s 300x200 -f mjpeg Video/" + Name  + ".jpg")

请帮帮我!!!

最佳答案

我认为问题可能是由 .withSize('...') 方法调用引起的。文档说:

It doesn't interract well with filters. In particular, don't use the size() method to resize thumbnails, use the size option instead.

而 size() 方法是 withSize() 的别名。

此外 - 但这不是您的问题 - 您不需要同时设置计数和时间标记。文档说:

count is ignored when timemarks or timestamps is specified.

那么你可能可以解决:

const ffmpeg = require('fluent-ffmpeg');

exports.thumbnail = function(){
const proc = new ffmpeg({ source: 'Video/express2.mp4',nolog: true })
.takeScreenshots({ timemarks: [ '00:00:02.000' ], size: '150x100' }, 'Video/', function(err, filenames) {
console.log(filenames);
console.log('screenshots were saved');
});
}

看看文档: https://github.com/fluent-ffmpeg/node-fluent-ffmpeg#screenshotsoptions-dirname-generate-thumbnails

关于node.js - fluent-ffmpeg 缩略图创建错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13115200/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com