• 카테고리

    질문 & 답변
  • 세부 분야

    풀스택

  • 해결 여부

    미해결

TypeError: Cannot read properties of undefined (reading 'format')

22.09.13 21:39 작성 조회수 830

0

 

 

video.js

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 하고

재부팅도 해봤는데 안돼요ㅠㅠ

 

답변 2

·

답변을 작성해보세요.

0

성민석님의 프로필

성민석

2022.11.07

혹시 해결하셨나요? 저도 동일에러로 검색하는데 해결방법을 모르겠네요

0

안녕하세요!!

500 에러는 서버에서 에러가 난 것입니다.

이럴 때는 서버에서 어떠한 에러가 났는지 서버 쪽 에러 로그를 체크해주셔서 처리해주시면 됩니다.

감사합니다.