@pexip/media-processor 17.1.0 → 17.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/README.md +3 -7
- package/dist/worklets/denoise.worklet.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `@pexip/media-processor`
|
|
2
2
|
|
|
3
3
|
An package for media data processing using Web API.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Install
|
|
6
6
|
|
|
7
|
-
-
|
|
7
|
+
`npm install @pexip/media-processor`
|
|
8
8
|
|
|
9
9
|
## Examples
|
|
10
10
|
|
|
@@ -144,10 +144,6 @@ await videoProcessor.open();
|
|
|
144
144
|
const processedStream = await videoProcessor.process(stream);
|
|
145
145
|
```
|
|
146
146
|
|
|
147
|
-
### More examples
|
|
148
|
-
|
|
149
|
-
Please check the [Media Processor Demo](../../examples/media-processor-demo)
|
|
150
|
-
|
|
151
147
|
## Profiling Web Audio
|
|
152
148
|
|
|
153
149
|
You can do it with chrome, [See here][profiling web audio].
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var N=!0,w=String.fromCharCode,W={}.toString,V=W(),_=Uint8Array,m=_||Array,B=_?ArrayBuffer:m,L=B.isView||function(e){return e&&"length"in e},q=W.call(B.prototype);var R=
|
|
1
|
+
var N=!0,w=String.fromCharCode,W={}.toString,V=W(),_=Uint8Array,m=_||Array,B=_?ArrayBuffer:m,L=B.isView||function(e){return e&&"length"in e},q=W.call(B.prototype);var R=E.prototype;var H=/[\x80-\uD7ff\uDC00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]?/g,f=new(_?Uint16Array:m)(32);function D(){}D.prototype.decode=function(e){var t=e,a;if(!L(t)){if(a=W.call(t),a!==q&&a!==V)throw TypeError("Failed to execute 'decode' on 'TextDecoder': The provided value is not of type '(ArrayBuffer or ArrayBufferView)'");t=_?new m(t):t||[]}for(var o="",n="",s=0,r=t.length|0,i=r-32|0,c=0,g=0,u=0,d=0,l=0,b=0,p=0,h=-1;s<r;){for(c=s<=i?32:r-s|0;p<c;s=s+1|0,p=p+1|0){switch(u=t[s]&255,u>>4){case 15:if(b=t[s=s+1|0]&255,b>>6!==2||247<u){s=s-1|0;break}d=(u&7)<<6|b&63,l=5,u=256;case 14:b=t[s=s+1|0]&255,d<<=6,d|=(u&15)<<6|b&63,l=b>>6===2?l+4|0:24,u=u+256&768;case 13:case 12:b=t[s=s+1|0]&255,d<<=6,d|=(u&31)<<6|b&63,l=l+7|0,s<r&&b>>6===2&&d>>l&&d<1114112?(u=d,d=d-65536|0,0<=d?(h=(d>>10)+55296|0,u=(d&1023)+56320|0,p<31?(f[p]=h,p=p+1|0,h=-1):(b=h,h=u,u=b)):c=c+1|0):(u>>=8,s=s-u-1|0,u=65533),l=0,d=0,c=s<=i?32:r-s|0;default:f[p]=u;continue;case 11:case 10:case 9:case 8:}f[p]=65533}if(n+=w(f[0],f[1],f[2],f[3],f[4],f[5],f[6],f[7],f[8],f[9],f[10],f[11],f[12],f[13],f[14],f[15],f[16],f[17],f[18],f[19],f[20],f[21],f[22],f[23],f[24],f[25],f[26],f[27],f[28],f[29],f[30],f[31]),p<32&&(n=n.slice(0,p-32|0)),s<r){if(f[0]=h,p=~h>>>31,h=-1,n.length<o.length)continue}else h!==-1&&(n+=w(h));o+=n,n=""}return o};function Z(e){var t=e.charCodeAt(0)|0;if(55296<=t)if(t<=56319){var a=e.charCodeAt(1)|0;if(56320<=a&&a<=57343){if(t=(t<<10)+a-56613888|0,t>65535)return w(240|t>>18,128|t>>12&63,128|t>>6&63,128|t&63)}else t=65533}else t<=57343&&(t=65533);return t<=2047?w(192|t>>6,128|t&63):w(224|t>>12,128|t>>6&63,128|t&63)}function E(){}R.encode=function(e){var t=e===void 0?"":""+e,a=t.length|0,o=new m((a<<1)+8|0),n,s=0,r=0,i=0,c=0,g=!_;for(s=0;s<a;s=s+1|0,r=r+1|0)if(i=t.charCodeAt(s)|0,i<=127)o[r]=i;else if(i<=2047)o[r]=192|i>>6,o[r=r+1|0]=128|i&63;else{e:{if(55296<=i)if(i<=56319){if(c=t.charCodeAt(s=s+1|0)|0,56320<=c&&c<=57343){if(i=(i<<10)+c-56613888|0,i>65535){o[r]=240|i>>18,o[r=r+1|0]=128|i>>12&63,o[r=r+1|0]=128|i>>6&63,o[r=r+1|0]=128|i&63;continue}break e}i=65533}else i<=57343&&(i=65533);!g&&s<<1<r&&s<<1<(r-7|0)&&(g=!0,n=new m(a*3),n.set(o),o=n)}o[r]=224|i>>12,o[r=r+1|0]=128|i>>6&63,o[r=r+1|0]=128|i&63}return _?o.subarray(0,r):o.slice(0,r)};function G(e,t){var a=e===void 0?"":(""+e).replace(H,Z),o=a.length|0,n=0,s=0,r=0,i=t.length|0,c=e.length|0;i<o&&(o=i);e:for(;n<o;n=n+1|0){switch(s=a.charCodeAt(n)|0,s>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:r=r+1|0;case 8:case 9:case 10:case 11:break;case 12:case 13:if((n+1|0)<i){r=r+1|0;break}case 14:if((n+2|0)<i){r=r+1|0;break}case 15:if((n+3|0)<i){r=r+1|0;break}default:break e}t[n]=s}return{written:n,read:c<r?c:r}}N&&(R.encodeInto=G);var x,y=new Array(32).fill(void 0);y.push(void 0,null,!0,!1);function P(e){return y[e]}var v=y.length;function J(e){e<36||(y[e]=v,v=e)}function K(e){let t=P(e);return J(e),t}var T=new D("utf-8",{ignoreBOM:!0,fatal:!0});T.decode();var A=null;function k(){return(A===null||A.buffer!==x.memory.buffer)&&(A=new Uint8Array(x.memory.buffer)),A}function C(e,t){return T.decode(k().subarray(e,e+t))}function Q(e){v===y.length&&y.push(y.length+1);let t=v;return v=y[t],y[t]=e,t}var S=0,O=new E("utf-8"),X=typeof O.encodeInto=="function"?function(e,t){return O.encodeInto(e,t)}:function(e,t){let a=O.encode(e);return t.set(a),{read:e.length,written:a.length}};function Y(e,t,a){if(a===void 0){let i=O.encode(e),c=t(i.length);return k().subarray(c,c+i.length).set(i),S=i.length,c}let o=e.length,n=t(o),s=k(),r=0;for(;r<o;r++){let i=e.charCodeAt(r);if(i>127)break;s[n+r]=i}if(r!==o){r!==0&&(e=e.slice(r)),n=a(n,o,o=r+e.length*3);let i=k().subarray(n+r,n+o),c=X(e,i);r+=c.written}return S=r,n}var F=null;function M(){return(F===null||F.buffer!==x.memory.buffer)&&(F=new Int32Array(x.memory.buffer)),F}async function $(e,t){if(typeof Response=="function"&&e instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(e,t)}catch(o){if(e.headers.get("Content-Type")!="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",o);else throw o}let a=await e.arrayBuffer();return await WebAssembly.instantiate(a,t)}else{let a=await WebAssembly.instantiate(e,t);return a instanceof WebAssembly.Instance?{instance:a,module:e}:a}}async function U(e){typeof e>"u"&&(e=new URL("denoise_bg.wasm",import.meta.url));let t={};t.wbg={},t.wbg.__wbg_new_693216e109162396=function(){var n=new Error;return Q(n)},t.wbg.__wbg_stack_0ddaca5d1abfb52f=function(n,s){var r=P(s).stack,i=Y(r,x.__wbindgen_malloc,x.__wbindgen_realloc),c=S;M()[n/4+1]=c,M()[n/4+0]=i},t.wbg.__wbg_error_09919627ac0992f5=function(n,s){try{console.error(C(n,s))}finally{x.__wbindgen_free(n,s)}},t.wbg.__wbindgen_object_drop_ref=function(n){K(n)},t.wbg.__wbindgen_throw=function(n,s){throw new Error(C(n,s))},(typeof e=="string"||typeof Request=="function"&&e instanceof Request||typeof URL=="function"&&e instanceof URL)&&(e=fetch(e));let{instance:a,module:o}=await $(await e,t);return x=a.exports,U.__wbindgen_wasm_module=o,x}var j=U;var z=128,I=(e,t)=>{e.forEach((a,o)=>a.forEach((n,s)=>{t(n,s,o)}))},ee=(e,t)=>{I(t,(a,o,n)=>{let s=e[n]?.[o];s&&a.set(s)})},te=(e,t,a)=>{let o=e.denoise_new(a,t),n=!1,s=()=>new Float32Array(e.memory.buffer,e.denoise_input(o),a*t),r=()=>new Float32Array(e.memory.buffer,e.denoise_output(o),a*t);return{vad:i=>e.denoise_vad(o,i),free:()=>{let i=o;o=0,e.__wbg_denoise_free(i),n=!0},pipe:(i,c)=>{if(n)return;let g=s();I(i,(d,l)=>{g.set(d,l*d.length)}),e.denoise_process_frames(o);let u=r();I(c,(d,l)=>{d.set(u.slice(l*d.length,(l+1)*d.length))})}}},re=()=>typeof AudioWorkletProcessor<"u"&&typeof registerProcessor=="function";if(re()){class e extends AudioWorkletProcessor{constructor(o){super(o);this.processing=!0;this.shouldSendVAD=!1;this.enabled=!0;let n=o?.processorOptions;if(!n?.data)throw new Error("No WebAssembly data provided!");if(!n?.sampleRate)throw new Error("No Sample Rate provided!");this.shouldSendVAD=!!n?.shouldSendVAD;let s=o?.outputChannelCount?.[0]??1;j(n.data).then(r=>{this.denoise=te(r,s,z)}),this.port.onmessage=r=>{switch(r.data.type){case"release":{this.denoise?.free(),this.processing=!1;break}case"enable":{this.enabled=r.data.value;break}default:break}}}process(o,n,s){return!this.denoise||!this.enabled||!this.processing?(ee(o,n),this.processing):(this.denoise.pipe(o,n),this.shouldSendVAD&&this.port.postMessage(Array.from({length:o[0]?.length??2}).map((r,i)=>this.denoise?.vad(i))),this.processing)}}registerProcessor("denoise-processor",e)}
|