작성
·
1.1K
0
router.post("/thumbnail", (req, res) => {
let filePath = ""
let fileDuration = ""
ffmpeg.ffprobe(req.body.url, function (err, metadata) {
console.dir(metadata);
console.log(metadata.format.duration);
fileDuration = metadata.format.duration
});
ffmpeg(req.body.url)
.on('filenames', function(filenames) {
console.log('Will generate ' + filenames.join(', '))
console.log(filenames)
filePath = "uploads/thumbnails/" + filenames[0]
})
.on('end', function () {
console.log('Screenshots taken');
return res.json({ success: true, url: filePath, fileDuration: fileDuration });
})
.on('error', function(err) {
console.error(err);
return res.json({ success: false, err });
})
.screenshots({
count: 3,
folder: 'uploads/thumbnails',
size: '320×240',
filename: 'thumbnail-%b.png'
})
});
videouploadpage.js
const onDrop =(files) => {
let formData = new FormData;
const config = {
header: {'content-type': 'multipart/form-data'}
}
formData.append("file", files[0])
Axios.post('/api/Video/uploadfiles', formData, config)
.then(response => {
if(response.data.success) {
console.log(response.data)
let variable = {
url: response.data.url,
fileName: response.data.fileName
}
Axios.post('/api/video/thumbnail', variable)
.then(response => {
if(response.data.success) {
console.log(response.data)
} else {
alert('썸네일 생성에 실패했습니다.')
}
})
} else{
alert('비디오 업로드에 실패했습니다.')
}
})
}
콘솔 에러
POST http://localhost:3000/api/video/thumbnail 500 (Internal Server Error)
터미널 에러
TypeError: Cannot read properties of undefined (reading 'format')
5강까지는 잘 작동했는데
6강 들어와서 영상은 저장이 되는데 썸네일 생성이 안돼요ㅠㅠ
ffmpeg 설치하고 환경변수 등록했고
fluent-ffmpeg도 install 하고
재부팅도 해봤는데 안돼요ㅠㅠ