我试图从一个视频(.mov)生成一个缩略图,但是它显示了这个错误
错误:错误4;详细信息: DEMUXER_ERROR_NO_SUPPORTED_STREAMS: FFmpegDemuxer:不支持流
、.mp4和其他格式运行良好。
铬版:版本101.0.4951.67 (正式构建)(64位)
代码:
async generateVideoThumbnail(file) {
console.log('generating thumbnail')
const binaryData = []
binaryData.push(file)
const canvas = document.createElement('canvas')
const context = canvas.getContext('2d')
const video = document.createElement('video')
video.setAttribute('src', URL.createObjectURL(new Blob(binaryData)))
video.onloadeddata = () => {
console.log('Yay! The readyState just increased to ' +
'HAVE_CURRENT_DATA or greater for the first time.');
};
video.loadstart = () => {
console.error(`load start`);
}
video.onwaiting = () => {
console.log('Video is waiting for more data.');
};
video.onprogress = () => {
console.log("Downloading video");
};
video.onerror = () => {
console.log('video error')
console.log("Error " + video.error.code + "; details: " + video.error.message);
}
console.log(video)
console.log('video load')
video.load()
let thumbnail = await new Promise((resolve) => {
video.onloadedmetadata = async () => {
console.log('on load')
canvas.width = video.videoWidth
canvas.height = video.videoHeight
video.currentTime = video.duration / 2
await video.play()
context.drawImage(video, 0, 0)
video.pause()
const blob = await new Promise((resolve) => {
return canvas.toBlob(function (blob) {
resolve(blob)
})
})
resolve(blob)
}
})
return thumbnail
},
发布于 2022-05-19 04:26:09
我不认为Chrome能够播放mov文件。您可以在控制台中检查这一点,方法是编写如下内容:
const video = document.createElement('video')
console.log(video.canPlayType('video/mp4')) //expect 'maybe'
console.log(video.canPlayType('video/ogg')) //expect 'maybe'
console.log(video.canPlayType('video/quicktime')) //expect ''
另一方面,火狐似乎能够播放它们,你可以在那里试用你的应用程序。
https://stackoverflow.com/questions/72301899
复制