Use IDBFS and NODEFS to process big file

This commit is contained in:
Jerome Wu
2019-12-03 22:06:44 +08:00
parent 72a2ff6e84
commit 3ab760b5bb
20 changed files with 215 additions and 162 deletions

View File

@@ -23,7 +23,7 @@
const { createWorker } = FFmpeg;
const worker = createWorker({
corePath: '../../node_modules/@ffmpeg/core/ffmpeg-core.js',
logger: ({ message }) => console.log(message),
progress: p => console.log(p),
});
const transcode = async ({ target: { files } }) => {
@@ -31,11 +31,12 @@
const { name } = files[0];
message.innerHTML = 'Loading ffmpeg-core.js';
await worker.load();
message.innerHTML = 'Start transcoding';
await worker.write(name, files[0]);
message.innerHTML = 'Start transcoding';
await worker.transcode(name, 'output.mp4');
message.innerHTML = 'Complete transcoding';
const { data } = await worker.read('output.mp4');
console.log(data);
const video = document.getElementById('output-video');
video.src = URL.createObjectURL(new Blob([data.buffer], { type: 'video/mp4' }));