我正在开发一款Meteor应用程序,其中使用CollectionFS上传文件。
我已经能够上传并生成图像的缩略图。
但我的问题是:如何为视频创建缩略图?
我可以通过命令行看到它是可能的:https://superuser.com/questions/599348/can-imagemagick-make-thumbnails-from-video 但我该如何将其应用到我的Meteor代码中。
以下是我的做法:
视频被上传到"videos"文件夹中,同时在"videosthumbs"下创建一个0字节的PNG文件,但无法生成缩略图。我还阅读了这篇文章:https://github.com/aheckmann/gm#custom-arguments,其中提到可以使用gm().command()自定义命令,比如identify或者convert。请问有什么建议来解决这个问题吗?谢谢。
我已经能够上传并生成图像的缩略图。
但我的问题是:如何为视频创建缩略图?
我可以通过命令行看到它是可能的: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);
}
})
]
});
视频被上传到"videos"文件夹中,同时在"videosthumbs"下创建一个0字节的PNG文件,但无法生成缩略图。我还阅读了这篇文章:https://github.com/aheckmann/gm#custom-arguments,其中提到可以使用gm().command()自定义命令,比如identify或者convert。请问有什么建议来解决这个问题吗?谢谢。