【问题标题】:Meteor.JS CollectionFS Video to Image Thumbnails (Graphics Magick)Meteor.JS CollectionFS 视频到图像缩略图 (Graphics Magick)
【发布时间】:2015-11-21 14:01:50
【问题描述】:

我正在开发一个使用 CollectionFS 上传文件的 Meteor 应用程序。

我可以上传和生成图片的缩略图。

但我的问题是:我应该如何为视频创建缩略图?

我可以看到可以通过命令行: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() - 自定义命令,例如识别或转换

谁能告诉我如何处理这种情况?

感谢和问候

【问题讨论】:

    标签: node.js meteor graphicsmagick collectionfs node-gm


    【解决方案1】:

    检查了您添加的链接,这是一个可能对您有所帮助的粗略解决方案

    ffmpeg -ss 600 -i input.mp4 -vframes 1 -s 420x270 -filter:v 'yadif' output.png
    

    这是我做的一个函数。

    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;
    });
    

    【讨论】:

    • 谢谢,我试过了,还是无法解决这个问题
    猜你喜欢
    • 2011-06-14
    • 2010-12-01
    • 1970-01-01
    • 2023-03-10
    • 1970-01-01
    • 2013-06-15
    • 2023-04-05
    • 2010-12-13
    • 2012-02-23
    相关资源
    最近更新 更多