Merge pull request #375 from astraldigital/more-path-options

add `wasmPath` & `workerPath` as browser options
This commit is contained in:
jeromewu 2022-08-14 18:38:00 +08:00 committed by GitHub
commit 733e3582a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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

@ -17,6 +17,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) */