From 0ed615017192b90bd3a80d7246197ef4d5358446 Mon Sep 17 00:00:00 2001 From: Abhinav Date: Sat, 5 Mar 2022 16:22:42 +0530 Subject: [PATCH] dont create blob URL --- src/browser/getCreateFFmpegCore.js | 46 ++++++++++++++++-------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/src/browser/getCreateFFmpegCore.js b/src/browser/getCreateFFmpegCore.js index f31167e04c0..24c2e9ba82e 100644 --- a/src/browser/getCreateFFmpegCore.js +++ b/src/browser/getCreateFFmpegCore.js @@ -9,33 +9,37 @@ const { * Fetch data from remote URL and convert to blob URL * to avoid CORS issue */ -const toBlobURL = async (url, mimeType) => { - log('info', `fetch ${url}`); - const buf = await (await fetch(url)).arrayBuffer(); - log('info', `${url} file size = ${buf.byteLength} bytes`); - const blob = new Blob([buf], { type: mimeType }); - const blobURL = URL.createObjectURL(blob); - log('info', `${url} blob URL = ${blobURL}`); - return blobURL; -}; +// const toBlobURL = async (url, mimeType) => { +// log('info', `fetch ${url}`); +// const buf = await (await fetch(url)).arrayBuffer(); +// log('info', `${url} file size = ${buf.byteLength} bytes`); +// const blob = new Blob([buf], { type: mimeType }); +// const blobURL = URL.createObjectURL(blob); +// log('info', `${url} blob URL = ${blobURL}`); +// return blobURL; +// }; module.exports = async ({ corePath: _corePath }) => { if (typeof _corePath !== 'string') { throw Error('corePath should be a string!'); } + // const corePath = await toBlobURL( + // coreRemotePath, + // 'application/javascript', + // ); + // const wasmPath = await toBlobURL( + // coreRemotePath.replace('ffmpeg-core.js', 'ffmpeg-core.wasm'), + // 'application/wasm', + // ); + // const workerPath = await toBlobURL( + // coreRemotePath.replace('ffmpeg-core.js', 'ffmpeg-core.worker.js'), + // 'application/javascript', + // ); const coreRemotePath = resolveURL(_corePath); - const corePath = await toBlobURL( - coreRemotePath, - 'application/javascript', - ); - const wasmPath = await toBlobURL( - coreRemotePath.replace('ffmpeg-core.js', 'ffmpeg-core.wasm'), - 'application/wasm', - ); - const workerPath = await toBlobURL( - coreRemotePath.replace('ffmpeg-core.js', 'ffmpeg-core.worker.js'), - 'application/javascript', - ); + const corePath = coreRemotePath; + const wasmPath = coreRemotePath.replace('ffmpeg-core.js', 'ffmpeg-core.wasm'); + const workerPath = coreRemotePath.replace('ffmpeg-core.js', 'ffmpeg-core.worker.js'); + if (typeof createFFmpegCore === 'undefined') { return new Promise((resolve) => { const script = document.createElement('script');