Skip to content

Commit

Permalink
dont create blob URL
Browse files Browse the repository at this point in the history
  • Loading branch information
abhinavkgrd committed Mar 8, 2022
1 parent 115a7c8 commit 0ed6150
Showing 1 changed file with 25 additions and 21 deletions.
46 changes: 25 additions & 21 deletions src/browser/getCreateFFmpegCore.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit 0ed6150

Please sign in to comment.