问题描述
我正在尝试观看文件 Chokidar。文件夹中的 Mp4 文件。我正在尝试使用创建缩略图的监视文件夹。但我的代码挂了。它被卡住了。我等了十分钟,但我没有出错,而且我的代码工作得很少。再一次,我等了十分钟。但没有任何改变。
代码:
let fs = require('fs');
var chokidar = require('chokidar');
const ffmpegInstaller = require('@ffmpeg-installer/ffmpeg');
const ffmpeg = require('fluent-ffmpeg');
ffmpeg.setFfmpegPath(ffmpegInstaller.path)
var counter = 0
var Mywatcher = chokidar.watch('Z:\\WatchFolder',{ignored: /^\./,persistent: true,usePolling: true});
Mywatcher
.on('add',function(path) {
worder = '.mp4'
if(path.includes(worder)){
counter = counter + 1
console.log('added' + counter)
ffmpeg({ source: path })
.on('filenames',(filenames) => {
console.log('Created file names',filenames);
})
.on('end',() => {
console.log('Job done');
})
.on('error',(err) => {
console.log('Error',err);
})
.takeScreenshots({
filename: counter +'.jpg',timemarks: [ 2 ],},'public/images/thumbnail/');
}
})
.on('change',function(path) {console.log('File',path,'has been changed');})
.on('unlink',function(path) {
})
.on('error',function(error) {console.error('Error happened',error);})
第一个结果:1300 个缩略图完成。但尚未创建。缩略图的文件夹是空的。我的代码卡住了。
added13023
Created file names [ '13023.jpg' ]
added13024
Created file names [ '13024.jpg' ]
added13025
Created file names [ '13025.jpg' ]
added13026
Created file names [ '13026.jpg' ]
added13027
Created file names [ '13027.jpg' ]
added13028
Created file names [ '13028.jpg' ]
added13029
Created file names [ '13029.jpg' ]
added13030
Created file names [ '13030.jpg' ]
added13031
Created file names [ '13031.jpg' ]
added13032
Created file names [ '13032.jpg' ]
added13033
Created file names [ '13033.jpg' ]
added13034
Created file names [ '13034.jpg' ]
added13035
Created file names [ '13035.jpg' ]
added13036
Created file names [ '13036.jpg' ]
我再次尝试,我写了“nodemon start”和结果:
Created file names [ '13026.jpg' ]
added13027
Created file names [ '13027.jpg' ]
added13028
Created file names [ '13028.jpg' ]
added13029
Created file names [ '13029.jpg' ]
added13030
Created file names [ '13030.jpg' ]
added13031
Created file names [ '13031.jpg' ]
added13032
Created file names [ '13032.jpg' ]
added13033
Created file names [ '13033.jpg' ]
added13034
Created file names [ '13034.jpg' ]
added13035
Created file names [ '13035.jpg' ]
added13036
Created file names [ '13036.jpg' ]
added13037
Created file names [ '13037.jpg' ]
我该如何解决?谢谢大家。问候。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)