UNPKG

@jxstjh/jhvideo

Version:

HTML5 jhvideo base on MPEG2-TS Stream Player

34 lines (27 loc) 1 kB
/** * ResampleProcessor */ import PCMProcessor from './pcm-processor.js' class AudioEncodeProcessor extends AudioWorkletProcessor { constructor(options) { super() // console.log(...arguments) let { processorOptions } = options this._processor = new PCMProcessor(processorOptions, (samples) => { this.port.postMessage(samples) }) } process(inputs, outputs, parameters) { let input = inputs[0] if (input.length === 0) return true let chunk = input[0] if (chunk[0] === 0) return true // console.log(inputs, outputs, parameters) // 可在此将PCM原始音频数据传递给主线程进行其他操作,如写文件等。 // this.port.postMessage({ type: 'origin', inputs }) // 加工处理PCM音频数据 this._processor.input(chunk) return true } } registerProcessor('AudioEncodeProcessor', AudioEncodeProcessor)