ffmpeg 截图太模糊了_时间过长产生的ffmpeg截图

I am generating a Screenshot by using ffmpeg. Its generating the thumbnail but its taking too long (more than 2 minutes).

I have referred this link

But I have to set in my nodejs code

ffmpeg(main_folder_path)

.on('filenames', function(filenames) {

console.log('Will generate ' + filenames.join(', '))

})

.on('end', function() {

console.log('Screenshots taken');

})

.screenshots({

pro_root_path+'public/uploads/inspection/'+req.body.clientID+'/images/'

timestamps: [30.5, '20%', '01:10.123'],

filename: 'thumbnail-at-%s-seconds.png',

folder: pro_root_path+'public/uploads/inspection/'+req.body.clientID+'/images/',

size: '320x240'

});

I used timestamp But even though its taking more than 2 minutes. How do I fix this Issue.

解决方案

I'm not a fan of the fluent-ffmpeg "screenshot" command. ffmpeg has a built-in screenshot capability, and it's much more flexible. Most notably, it allows you to take advantage of ffmpeg's ability to quickly seek on on the "input" rather than the "output". ("Seeking on output" basically means that it will process every single frame between the start of the video and the one that you want to screenshot.)

Fortunately, fluent-ffmpeg allows you to use any command line parameters, by way of outputOptions. The following command would take a screenshot at the 15-minute mark. It takes about 1 second on my machine.

ffmpeg('video.mp4')

.seekInput('15:00.000')

.output('output/screenshot.jpg')

.outputOptions(

'-frames', '1' // Capture just one frame of the video

)

.on('end', function() {

console.log('Screenshot taken');

})

.run()

Without the command '-frames 1', it would take a screenshot for every frame of the video.

As an illustration of just how powerful this can be, the following command makes consecutive sprited 5x5 images (25 images per file) of an entire video. Great for making thumbnails.

ffmpeg('video.mp4')

.on('end', function() {

console.log('Screenshots taken');

})

.output('output/screenshot-%04d.jpg')

.outputOptions(

'-q:v', '8',

'-vf', 'fps=1/10,scale=-1:120,tile=5x5',

)

.run()

// fps=1/10: 1 frame every 10 seconds

// scale=-1:120: resolution of 120p

// tile=5x5: 25 screenshots per jpg file

// -q:v 8: quality set to 8. 0=best, 69=worst?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值