inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

따라하며 배우는 노드, 리액트 시리즈 - 유튜브 사이트 만들기

ffmpeg로 비디오 썸네일 생성하기

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

1248

피아노

작성한 질문수 3

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

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

 

redux nodejs mongodb react

답변 2

0

성민석

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

0

John Ahn

안녕하세요!!

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

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

감사합니다.

npm i하면 바로, 라이브러리 오류없이 받아지고, 구동되는 소스는 없나요?

0

52

1

ERROR in ./node_modules/antd/es/version/index.js 2:15-22

0

223

1

자료 없음

0

325

1

이미지 깨짐

0

341

1

npm run dev 동작 에러

0

306

1

npm run dev 동작 에러

0

298

1

npm run dev 동작에러납니다...

0

664

1

npm run dev 실행 오류

0

654

1

비디오 업로드, 로그인, 회원가입 504 error

0

1058

1

시작부터 오류생기시는 분들 해결법입니다.

1

470

1

오류 해결 공유

0

462

1

npm install 에러 질문드립니다.

0

1128

2

아예 몽고DB에 연결한다고만 하고 연결이 안되고 있습니다.

0

553

1

해당 오류 해결 방법 좀 알려주세요 ㅠㅠ

0

521

1

로컬스토리지에 대한 질문입니다!!

0

516

0

video가 안 나타나는 문제

0

895

1

ffmpeg 설치 후 cannot read property 'format' of undefined 500 에러 해결

0

473

0

typeError or 콘솔 500 뜨는분..

0

339

0

npm run dev 관련 오류

0

579

1

답글이 달리지않고 디비에도 저장되지않으며 새로고침이 됩니다.

0

250

0

useState 자동 생성

0

349

1

userData undefined / state에 user.userData가 없습니다.

0

249

0

antd Input background color 변경

0

245

0

VideoDetailPage.js 비디오영상 렌더링할 때 썸네일도 안나오고 영상 재생도 안되시는 분들

0

294

0