how to generate video thumbnail in node.js?

前端 未结 6 985
不知归路
不知归路 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:58

    Instead I would recommend using thumbsupply. In addition to provide you with thumbnails, it caches them to improve performance significantly.

    npm install --save thumbsuppply
    

    After installing the module, you can use it in a following way.

    const thumbsupply = require('thumbsupply')("com.example.application");
    
    thumbsupply.generateThumbnail('some-video.mp4')
    .then(thumb => {
        // serve thumbnail
    })
    

提交回复
热议问题