how to generate video thumbnail in node.js?

前端 未结 6 974
不知归路
不知归路 2020-12-15 10:31

I am building an app with node.js, I successfully uploaded the video, but I need to generate a video thumbnail for it. Currently I use node exec to execute a system command

6条回答
  •  南方客
    南方客 (楼主)
    2020-12-15 10:54

    Using media-thumbnail, you can easily generate thumbnails from your videos. The module basically wraps the ffmpeg thumbnail functionality.

    const mt = require('media-thumbnail')
    
    mt.forVideo(
      './path/to/video.mp4',
      './path/to/thumbnail.png', {
        width: 200
      })
      .then(() => console.log('Success'), err => console.error(err)) 
    

    You can also create thumbnails from your images using this package.

提交回复
热议问题