3 lines
84 KiB
JavaScript
3 lines
84 KiB
JavaScript
|
/*! @name mux.js @version 7.1.0 @license Apache-2.0 */
|
||
|
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("global/window")):"function"==typeof define&&define.amd?define(["global/window"],e):(t="undefined"!=typeof globalThis?globalThis:t||self).muxjs=e(t.window)}(this,(function(t){"use strict";function e(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var i,n,a,r,s,o,d,h,u,p,c,l,f,g,m,y,b,v,S,_,w,T,U,C,k,A,D,P,x,L,O,E,I,R,M,B,N,z,W,V,G=e(t),F=Math.pow(2,32),j={getUint64:function(t){var e,i=new DataView(t.buffer,t.byteOffset,t.byteLength);return i.getBigUint64?(e=i.getBigUint64(0))<Number.MAX_SAFE_INTEGER?Number(e):e:i.getUint32(0)*F+i.getUint32(4)},MAX_UINT32:F},Y=j.MAX_UINT32;!function(){var t;if(T={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],mvex:[],mvhd:[],pasp:[],sdtp:[],smhd:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],styp:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[]},"undefined"!=typeof Uint8Array){for(t in T)T.hasOwnProperty(t)&&(T[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]);U=new Uint8Array(["i".charCodeAt(0),"s".charCodeAt(0),"o".charCodeAt(0),"m".charCodeAt(0)]),k=new Uint8Array(["a".charCodeAt(0),"v".charCodeAt(0),"c".charCodeAt(0),"1".charCodeAt(0)]),C=new Uint8Array([0,0,0,1]),A=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),D=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]),P={video:A,audio:D},O=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),L=new Uint8Array([0,0,0,0,0,0,0,0]),E=new Uint8Array([0,0,0,0,0,0,0,0]),I=E,R=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),M=E,x=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])}}(),i=function(t){var e,i,n=[],a=0;for(e=1;e<arguments.length;e++)n.push(arguments[e]);for(e=n.length;e--;)a+=n[e].byteLength;for(i=new Uint8Array(a+8),new DataView(i.buffer,i.byteOffset,i.byteLength).setUint32(0,i.byteLength),i.set(t,4),e=0,a=8;e<n.length;e++)i.set(n[e],a),a+=n[e].byteLength;return i},n=function(){return i(T.dinf,i(T.dref,O))},a=function(t){return i(T.esds,new Uint8Array([0,0,0,0,3,25,0,0,0,4,17,64,21,0,6,0,0,0,218,192,0,0,218,192,5,2,t.audioobjecttype<<3|t.samplingfrequencyindex>>>1,t.samplingfrequencyindex<<7|t.channelcount<<3,6,1,2]))},m=function(t){return i(T.hdlr,P[t])},g=function(t){var e=new Uint8Array([0,0,0,0,0,0,0,2,0,0,0,3,0,1,95,144,t.duration>>>24&255,t.duration>>>16&255,t.duration>>>8&255,255&t.duration,85,196,0,0]);return t.samplerate&&(e[12]=t.samplerate>>>24&255,e[13]=t.samplerate>>>16&255,e[14]=t.samplerate>>>8&255,e[15]=255&t.samplerate),i(T.mdhd,e)},f=function(t){return i(T.mdia,g(t),m(t.type),o(t))},s=function(t){return i(T.mfhd,new Uint8Array([0,0,0,0,(4278190080&t)>>24,(16711680&t)>>16,(65280&t)>>8,255&t]))},o=function(t){return i(T.minf,"video"===t.type?i(T.vmhd,x):i(T.smhd,L),n(),b(t))},d=function(t,e){for(var n=[],a=e.length;a--;)n[a]=S(e[a]);return i.apply(null,[T.moof,s(t)].concat(n))},h=function(t){for(var e=t.length,n=[];e--;)n[e]=c(t[e]);return i.apply(null,[T.moov,p(4294967295)].concat(n).concat(u(t)))},u=function(t){for(var e=t.length,n=[];e--;)n[e]=_(t[e]);return i.apply(null,[T.mvex].concat(n))},p=function(t){var e=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,2,0,1,95,144,(4278190080&t)>>24,(16711680&t)>>16,(65280&t)>>8,255&t,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return i(T.mvhd,e)},y=function(t){var e,n,a=t.samples||[],r=new Uint8Array(4+a.length);for(n=0;n<a.length;n++)e=a[n].flags,r[n+4]=e.dependsOn<<4|e.isDependedOn<<2|e.hasRedundancy;return i(T.sdtp,r)},b=function(t){return i(T.stbl,v(t),i(T.stts,M),i(T.stsc,I),i(T.stsz,R),i(T.stco,E))},v=function(t){return i(T.stsd,new Uint8Array([0,0,0,0,0,0,0,1]),"video"===t.type?B(t):N(t))},B=function(t){var e,n,a=t.sps||[],r=t.pps||[],s=[],o=[];for(e=0;e<a.length;e++)s.push((65280&a[e].by
|