ffmpegwasm / ffmpegwasm/ffmpeg.wasm
"str.charCodeAt is not a function",anybody can help me?
- Dominant language
- C
- Stars
- 17.8k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description

code is here:
`
`
`
`
const fetchFile = async (file) => {
let data;
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();
})
`
Contributor guide
Assessment
This issue has not been assessed yet.