inflearn logo
강의

Khóa học

Chia sẻ kiến thức

Chuỗi bài học về Node và React để học bằng cách theo dõi - Tạo một trang YouTube

Tạo hình thu nhỏ video bằng ffmpeg

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

1245

bagjinsu7072563

3 câu hỏi đã được viết

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

Câu trả lời 2

0

imuchgabis3999

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

0

John Ahn

안녕하세요!!

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

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

감사합니다.

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

0

52

1

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

0

221

1

자료 없음

0

321

1

이미지 깨짐

0

334

1

npm run dev 동작 에러

0

304

1

npm run dev 동작 에러

0

294

1

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

0

660

1

npm run dev 실행 오류

0

653

1

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

0

1056

1

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

1

466

1

오류 해결 공유

0

458

1

npm install 에러 질문드립니다.

0

1120

2

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

0

550

1

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

0

515

1

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

0

515

0

video가 안 나타나는 문제

0

893

1

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

0

470

0

typeError or 콘솔 500 뜨는분..

0

336

0

npm run dev 관련 오류

0

578

1

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

0

246

0

useState 자동 생성

0

345

1

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

0

246

0

antd Input background color 변경

0

238

0

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

0

290

0