ffmpeg.wasm
ffmpeg.wasm copied to clipboard
"str.charCodeAt is not a function",anybody can help me?
code is here:
<script src="https://unpkg.com/@ffmpeg/[email protected]/dist/umd/ffmpeg-core.js"></script> <video src="" id="video"></video>
if (typeof file === "string") {
/* From base64 format */
if (/data:_data\/([a-zA-Z]*);base64,([^"]*)/.test(file)) {
data = atob(file.split(",")[1])
.split("")
.map((c) => c.charCodeAt(0));
/* From remote server/URL */
} else {
data = await (await fetch(file)).arrayBuffer();
}
} else if (file instanceof URL) {
data = await (await fetch(file)).arrayBuffer();
} else if (file instanceof File || file instanceof Blob) {
data = await readFromBlobOrFile(file);
} else {
return new Uint8Array();
}
return new Uint8Array(data);
};
createFFmpegCore().then(ffmpeg => {
const { FS } = ffmpeg;
console.log(ffmpeg);
const transcode = async () => {
await FS.writeFile('input.webm', await fetchFile('https://raw.githubusercontent.com/ffmpegwasm/testdata/master/Big_Buck_Bunny_180_10s.webm'));
await ffmpeg.exec(['-i', 'input.webm', 'output.mp4']);
const data = await FS.readFile('output.mp4');
document.getElementById('video').src = URL.createObjectURL(new Blob([data.buffer], { type: 'video/mp4' }));
}
transcode();
})
</script>`
when I use:
await ffmpeg.exec('-i input.webm output.mp4');
This error is gone, there will be other error