add wasmPath & workerPath as browser options

This commit is contained in:
Jack Anderson 2022-08-08 15:50:40 -07:00
parent fcc312abd3
commit 8c693decb4
2 changed files with 7 additions and 3 deletions

View File

@ -19,7 +19,7 @@ const toBlobURL = async (url, mimeType) => {
return blobURL;
};
module.exports = async ({ corePath: _corePath }) => {
module.exports = async ({ corePath: _corePath, workerPath: _workerPath, wasmPath: _wasmPath }) => {
if (typeof _corePath !== 'string') {
throw Error('corePath should be a string!');
}
@ -29,11 +29,11 @@ module.exports = async ({ corePath: _corePath }) => {
'application/javascript',
);
const wasmPath = await toBlobURL(
coreRemotePath.replace('ffmpeg-core.js', 'ffmpeg-core.wasm'),
_wasmPath !== undefined ? _wasmPath : coreRemotePath.replace('ffmpeg-core.js', 'ffmpeg-core.wasm'),
'application/wasm',
);
const workerPath = await toBlobURL(
coreRemotePath.replace('ffmpeg-core.js', 'ffmpeg-core.worker.js'),
_workerPath !== undefined ? _workerPath : coreRemotePath.replace('ffmpeg-core.js', 'ffmpeg-core.worker.js'),
'application/javascript',
);
if (typeof createFFmpegCore === 'undefined') {

4
src/index.d.ts vendored
View File

@ -14,6 +14,10 @@ type ProgressCallback = (progressParams: { ratio: number }) => any;
export interface CreateFFmpegOptions {
/** path for ffmpeg-core.js script */
corePath?: string;
/** path for ffmpeg-worker.js script */
workerPath?: string;
/** path for ffmpeg-core.wasm script */
wasmPath?: string;
/** a boolean to turn on all logs, default is false */
log?: boolean;
/** a function to get log messages, a quick example is ({ message }) => console.log(message) */