Man*_*anu 7 node.js graphicsmagick meteor node-gm collectionfs
我正在使用一个Meteor应用程序,我正在使用CollectionFS上传文件.
我可以上传和生成图像的缩略图.
但我的问题是:我应该如何为视频创建缩略图?
我可以看到它可以通过命令行:https://superuser.com/questions/599348/can-imagemagick-make-thumbnails-from-video
但是我如何将其应用于我的Meteor代码.
这是我在做的事情:
VideoFileCollection = new FS.Collection("VideoFileCollection", {
stores: [
new FS.Store.FileSystem("videos", {path: "/uploads/videos"}),
new FS.Store.FileSystem("videosthumbs", {path: "/uploads/videosthumbs",
beforeWrite: function(fileObj) {
// We return an object, which will change the
// filename extension and type for this store only.
return {
extension: 'png',
type: 'image/png'
};
},
transformWrite: function(fileObj, readStream, writeStream) {
gm(readStream, fileObj.name()).stream('PNG').pipe(writeStream);
}
})
]
});
Run Code Online (Sandbox Code Playgroud)
这里发生了什么,视频上传到"视频"文件夹,一个PNG在"videosthumbs"下创建,0字节,缩略图没有生成.
我也读过:https://github.com/aheckmann/gm#custom-arguments
我们可以使用:gm().command() - 自定义命令,如识别或转换
任何人都可以告诉我如何处理这种情况?
感谢致敬
检查您添加的链接,这是一个可能对您有帮助的粗略解决方案
ffmpeg -ss 600 -i input.mp4 -vframes 1 -s 420x270 -filter:v 'yadif' output.png
Run Code Online (Sandbox Code Playgroud)
这是我制作的一个功能。
var im = require('imagemagick');
var args = [
"ffmpeg", "-ss", "600", "-i", "input.mp4", "-vframes", " 1", "-s", "420x270", "-filter:v", "'yadif'", "output.png"
];
// Function to convert and
im.convert(args, function(err)
if (err) throw err;
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
580 次 |
| 最近记录: |