-
Notifications
You must be signed in to change notification settings - Fork 373
Open
Labels
Description
Based on current code, there's no way to disable logging of error level messages. This is my hacky workaround:
/**
* Suppress or restore Mp4Box error logging
* @param mp4box Mp4Box module
* @param quiet Whether to suppress error logging or restore original behaviour
*/
export function makeMp4BoxQuiet(mp4box: typeof import('mp4box'), quiet: boolean | undefined) {
if (quiet) {
(mp4box.Log as any).originalError = mp4box.Log.error;
mp4box.Log.error = (module: string, msg?: string, isofile?: ISOFile) => {
// This implementation is copied from mp4box source code
if (isofile?.onError) {
isofile.onError(module, msg ?? '');
}
};
} else {
const originalError = (mp4box.Log as any).originalError;
if (originalError) {
mp4box.Log.error = originalError;
}
}
}
I hope there's a better way to achieve this.