You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3 lines
66 KiB

4 years ago
/*! @name mux.js @version 5.10.0 @license Apache-2.0 */
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).muxjs=e()}(this,(function(){"use strict";var t,e,i,n,a,r,s,o,h,d,p,u,l,c,f,m,g,y,S,v,_,b,w,T,k,C,P,A,D,U,L,E,O,x,R,M,I,B,N,G,W=Math.pow(2,32)-1;!function(){var t;if(b={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 b)b.hasOwnProperty(t)&&(b[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]);w=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)]),T=new Uint8Array([0,0,0,1]),C=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]),P=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]),A={video:C,audio:P},L=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),U=new Uint8Array([0,0,0,0,0,0,0,0]),E=new Uint8Array([0,0,0,0,0,0,0,0]),O=E,x=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),R=E,D=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])}}(),t=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},e=function(){return t(b.dinf,t(b.dref,L))},i=function(e){return t(b.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,e.audioobjecttype<<3|e.samplingfrequencyindex>>>1,e.samplingfrequencyindex<<7|e.channelcount<<3,6,1,2]))},f=function(e){return t(b.hdlr,A[e])},c=function(e){var i=new Uint8Array([0,0,0,0,0,0,0,2,0,0,0,3,0,1,95,144,e.duration>>>24&255,e.duration>>>16&255,e.duration>>>8&255,255&e.duration,85,196,0,0]);return e.samplerate&&(i[12]=e.samplerate>>>24&255,i[13]=e.samplerate>>>16&255,i[14]=e.samplerate>>>8&255,i[15]=255&e.samplerate),t(b.mdhd,i)},l=function(e){return t(b.mdia,c(e),f(e.type),r(e))},a=function(e){return t(b.mfhd,new Uint8Array([0,0,0,0,(4278190080&e)>>24,(16711680&e)>>16,(65280&e)>>8,255&e]))},r=function(i){return t(b.minf,"video"===i.type?t(b.vmhd,D):t(b.smhd,U),e(),g(i))},s=function(e,i){for(var n=[],r=i.length;r--;)n[r]=S(i[r]);return t.apply(null,[b.moof,a(e)].concat(n))},o=function(e){for(var i=e.length,n=[];i--;)n[i]=p(e[i]);return t.apply(null,[b.moov,d(4294967295)].concat(n).concat(h(e)))},h=function(e){for(var i=e.length,n=[];i--;)n[i]=v(e[i]);return t.apply(null,[b.mvex].concat(n))},d=function(e){var i=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,2,0,1,95,144,(4278190080&e)>>24,(16711680&e)>>16,(65280&e)>>8,255&e,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 t(b.mvhd,i)},m=function(e){var i,n,a=e.samples||[],r=new Uint8Array(4+a.length);for(n=0;n<a.length;n++)i=a[n].flags,r[n+4]=i.dependsOn<<4|i.isDependedOn<<2|i.hasRedundancy;return t(b.sdtp,r)},g=function(e){return t(b.stbl,y(e),t(b.stts,R),t(b.stsc,O),t(b.stsz,x),t(b.stco,E))},y=function(e){return t(b.stsd,new Uint8Array([0,0,0,0,0,0,0,1]),"video"===e.type?M(e):I(e))},M=function(e){var i,n,a=e.sps||[],r=e.pps||[],s=[],o=[];for(i=0;i<a.length;i++)s.push((65280&a[i].byteLength)>>>8),s.push(255&a[i].byteLength),s=s.concat(Array.prototype.slice.call(a[i]));for(i=0;i<r.length;i++)o.push((65280&r[i].byteLength)>>>8),o.push(255&r[i].byteLength),o=o.concat(Array.prototype.slice.call(r[i]));if(n=[b.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,(65280&e.width)>>8,255&e.width,(65280&e.height)>>8,255&