I'm using Meteor with CollectionFS to store videos. I need a transform to create thumbnails of my videos.
Videos = new FS.Collection("videos", {
stores: [
new FS.Store.FileSystem("thumbs", {
transformWrite: function(fileObj, readStream, writeStream) {
// What goes here?
}
}),
new FS.Store.FileSystem("videos"),
],
});
I've worked out how to do this with ffmpeg:
ffmpeg -i video.mp4 -vf "thumbnail,scale=640:360" -frames:v 1 thumb.png
But I'm not sure how to do this with the readStream I'm given and output the writeStream.
Here's an example of how it is done with images using GraphicsMagick:
Images = new FS.Collection("images", {
stores: [
new FS.Store.FileSystem("thumbs", {
transformWrite: function(fileObj, readStream, writeStream) {
// Transform the image into a 10x10px thumbnail
gm(readStream, fileObj.name()).resize('10', '10').stream().pipe(writeStream);
}
}),
new FS.Store.FileSystem("images"),
],
});
Although the samples use the local filesystem, Ill be using cvs:dropbox, so you can't rely on the file being there locally.