yanchengPowerSupply/node_modules/mux.js/dist/mux-mp4.min.js

2 lines
46 KiB
JavaScript

!function t(e,i,a){function n(s,o){if(!i[s]){if(!e[s]){var d="function"==typeof require&&require;if(!o&&d)return d(s,!0);if(r)return r(s,!0);var h=new Error("Cannot find module '"+s+"'");throw h.code="MODULE_NOT_FOUND",h}var p=i[s]={exports:{}};e[s][0].call(p.exports,function(t){var i=e[s][1][t];return n(i||t)},p,p.exports,t,e,i,a)}return i[s].exports}for(var r="function"==typeof require&&require,s=0;s<a.length;s++)n(a[s]);return n}({1:[function(t,e,i){"use strict";var a,n=t(15);a=function(){var t=new Uint8Array,e=0;a.prototype.init.call(this),this.setTimestamp=function(t){e=t},this.parseId3TagSize=function(t,e){var i=t[e+6]<<21|t[e+7]<<14|t[e+8]<<7|t[e+9];return(16&t[e+5])>>4?i+20:i+10},this.parseAdtsSize=function(t,e){var i=(224&t[e+5])>>5,a=t[e+4]<<3;return 6144&t[e+3]|a|i},this.push=function(i){var a,n,r,s,o=0,d=0;for(t.length?(s=t.length,t=new Uint8Array(i.byteLength+s),t.set(t.subarray(0,s)),t.set(i,s)):t=i;t.length-d>=3;)if(t[d]!=="I".charCodeAt(0)||t[d+1]!=="D".charCodeAt(0)||t[d+2]!=="3".charCodeAt(0))if(!0&t[d]&&240==(240&t[d+1])){if(t.length-d<7)break;if((o=this.parseAdtsSize(t,d))>t.length)break;r={type:"audio",data:t.subarray(d,d+o),pts:e,dts:e},this.trigger("data",r),d+=o}else d++;else{if(t.length-d<10)break;if((o=this.parseId3TagSize(t,d))>t.length)break;n={type:"timed-metadata",data:t.subarray(d,d+o)},this.trigger("data",n),d+=o}a=t.length-d,t=a>0?t.subarray(d):new Uint8Array}},a.prototype=new n,e.exports=a},{}],2:[function(t,e,i){"use strict";var a,n=t(15),r=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];a=function(){var t;a.prototype.init.call(this),this.push=function(e){var i,a,n,s,o,d,h=0,p=0;if("audio"===e.type)for(t?(s=t,t=new Uint8Array(s.byteLength+e.data.byteLength),t.set(s),t.set(e.data,s.byteLength)):t=e.data;h+5<t.length;)if(255===t[h]&&240==(246&t[h+1])){if(a=2*(1&~t[h+1]),i=(3&t[h+3])<<11|t[h+4]<<3|(224&t[h+5])>>5,o=1024*(1+(3&t[h+6])),d=9e4*o/r[(60&t[h+2])>>>2],n=h+i,t.byteLength<n)return;if(this.trigger("data",{pts:e.pts+p*d,dts:e.dts+p*d,sampleCount:o,audioobjecttype:1+(t[h+2]>>>6&3),channelcount:(1&t[h+2])<<2|(192&t[h+3])>>>6,samplerate:r[(60&t[h+2])>>>2],samplingfrequencyindex:(60&t[h+2])>>>2,samplesize:16,data:t.subarray(h+7+a,n)}),t.byteLength===n)return void(t=void 0);p++,t=t.subarray(n)}else h++},this.flush=function(){this.trigger("done")}},a.prototype=new n,e.exports=a},{}],3:[function(t,e,i){"use strict";var a,n,r,s=t(15),o=t(14);n=function(){var t,e,i=0;n.prototype.init.call(this),this.push=function(a){var n;for(e?(n=new Uint8Array(e.byteLength+a.data.byteLength),n.set(e),n.set(a.data,e.byteLength),e=n):e=a.data;i<e.byteLength-3;i++)if(1===e[i+2]){t=i+5;break}for(;t<e.byteLength;)switch(e[t]){case 0:if(0!==e[t-1]){t+=2;break}if(0!==e[t-2]){t++;break}i+3!==t-2&&this.trigger("data",e.subarray(i+3,t-2));do{t++}while(1!==e[t]&&t<e.length);i=t-2,t+=3;break;case 1:if(0!==e[t-1]||0!==e[t-2]){t+=3;break}this.trigger("data",e.subarray(i+3,t-2)),i=t-2,t+=3;break;default:t+=3}e=e.subarray(i),t-=i,i=0},this.flush=function(){e&&e.byteLength>3&&this.trigger("data",e.subarray(i+3)),e=null,i=0,this.trigger("done")}},n.prototype=new s,r={100:!0,110:!0,122:!0,244:!0,44:!0,83:!0,86:!0,118:!0,128:!0,138:!0,139:!0,134:!0},a=function(){var t,e,i,s,d,h,p,u=new n;a.prototype.init.call(this),t=this,this.push=function(t){"video"===t.type&&(e=t.trackId,i=t.pts,s=t.dts,u.push(t))},u.on("data",function(a){var n={trackId:e,pts:i,dts:s,data:a};switch(31&a[0]){case 5:n.nalUnitType="slice_layer_without_partitioning_rbsp_idr";break;case 6:n.nalUnitType="sei_rbsp",n.escapedRBSP=d(a.subarray(1));break;case 7:n.nalUnitType="seq_parameter_set_rbsp",n.escapedRBSP=d(a.subarray(1)),n.config=h(n.escapedRBSP);break;case 8:n.nalUnitType="pic_parameter_set_rbsp";break;case 9:n.nalUnitType="access_unit_delimiter_rbsp"}t.trigger("data",n)}),u.on("done",function(){t.trigger("done")}),this.flush=function(){u.flush()},p=function(t,e){var i,a,n=8,r=8;for(i=0;i<t;i++)0!==r&&(a=e.readExpGolomb(),r=(n+a+256)%256),n=0===r?n:r},d=function(t){for(var e,i,a=t.byteLength,n=[],r=1;r<a-2;)0===t[r]&&0===t[r+1]&&3===t[r+2]?(n.push(r+2),r+=2):r++;if(0===n.length)return t;e=a-n.length,i=new Uint8Array(e);var s=0;for(r=0;r<e;s++,r++)s===n[0]&&(s++,n.shift()),i[r]=t[s];return i},h=function(t){var e,i,a,n,s,d,h,u,l,c,m,f,g,y=0,_=0,S=0,b=0,v=1;if(e=new o(t),i=e.readUnsignedByte(),n=e.readUnsignedByte(),a=e.readUnsignedByte(),e.skipUnsignedExpGolomb(),r[i]&&(s=e.readUnsignedExpGolomb(),3===s&&e.skipBits(1),e.skipUnsignedExpGolomb(),e.skipUnsignedExpGolomb(),e.skipBits(1),e.readBoolean()))for(m=3!==s?8:12,g=0;g<m;g++)e.readBoolean()&&(g<6?p(16,e):p(64,e));if(e.skipUnsignedExpGolomb(),0===(d=e.readUnsignedExpGolomb()))e.readUnsignedExpGolomb();else if(1===d)for(e.skipBits(1),e.skipExpGolomb(),e.skipExpGolomb(),h=e.readUnsignedExpGolomb(),g=0;g<h;g++)e.skipExpGolomb();if(e.skipUnsignedExpGolomb(),e.skipBits(1),u=e.readUnsignedExpGolomb(),l=e.readUnsignedExpGolomb(),c=e.readBits(1),0===c&&e.skipBits(1),e.skipBits(1),e.readBoolean()&&(y=e.readUnsignedExpGolomb(),_=e.readUnsignedExpGolomb(),S=e.readUnsignedExpGolomb(),b=e.readUnsignedExpGolomb()),e.readBoolean()&&e.readBoolean()){switch(e.readUnsignedByte()){case 1:f=[1,1];break;case 2:f=[12,11];break;case 3:f=[10,11];break;case 4:f=[16,11];break;case 5:f=[40,33];break;case 6:f=[24,11];break;case 7:f=[20,11];break;case 8:f=[32,11];break;case 9:f=[80,33];break;case 10:f=[18,11];break;case 11:f=[15,11];break;case 12:f=[64,33];break;case 13:f=[160,99];break;case 14:f=[4,3];break;case 15:f=[3,2];break;case 16:f=[2,1];break;case 255:f=[e.readUnsignedByte()<<8|e.readUnsignedByte(),e.readUnsignedByte()<<8|e.readUnsignedByte()]}f&&(v=f[0]/f[1])}return{profileIdc:i,levelIdc:a,profileCompatibility:n,width:Math.ceil((16*(u+1)-2*y-2*_)*v),height:(2-c)*(l+1)*16-2*S-2*b}}},a.prototype=new s,e.exports={H264Stream:a,NalByteStream:n}},{}],4:[function(t,e,i){var a=[33,16,5,32,164,27],n=[33,65,108,84,1,2,4,8,168,2,4,8,17,191,252],r=function(t){for(var e=[];t--;)e.push(0);return e},s={96e3:[a,[227,64],r(154),[56]],88200:[a,[231],r(170),[56]],64e3:[a,[248,192],r(240),[56]],48e3:[a,[255,192],r(268),[55,148,128],r(54),[112]],44100:[a,[255,192],r(268),[55,163,128],r(84),[112]],32e3:[a,[255,192],r(268),[55,234],r(226),[112]],24e3:[a,[255,192],r(268),[55,255,128],r(268),[111,112],r(126),[224]],16e3:[a,[255,192],r(268),[55,255,128],r(268),[111,255],r(269),[223,108],r(195),[1,192]],12e3:[n,r(268),[3,127,248],r(268),[6,255,240],r(268),[13,255,224],r(268),[27,253,128],r(259),[56]],11025:[n,r(268),[3,127,248],r(268),[6,255,240],r(268),[13,255,224],r(268),[27,255,192],r(268),[55,175,128],r(108),[112]],8e3:[n,r(268),[3,121,16],r(47),[7]]};e.exports=function(t){return Object.keys(t).reduce(function(e,i){return e[i]=new Uint8Array(t[i].reduce(function(t,e){return t.concat(e)},[])),e},{})}(s)},{}],5:[function(t,e,i){"use strict";var a=t(15),n=function(t){for(var e=0,i={payloadType:-1,payloadSize:0},a=0,n=0;e<t.byteLength&&128!==t[e];){for(;255===t[e];)a+=255,e++;for(a+=t[e++];255===t[e];)n+=255,e++;if(n+=t[e++],!i.payload&&4===a){i.payloadType=a,i.payloadSize=n,i.payload=t.subarray(e,e+n);break}e+=n,a=0,n=0}return i},r=function(t){return 181!==t.payload[0]?null:49!=(t.payload[1]<<8|t.payload[2])?null:"GA94"!==String.fromCharCode(t.payload[3],t.payload[4],t.payload[5],t.payload[6])?null:3!==t.payload[7]?null:t.payload.subarray(8,t.payload.length-1)},s=function(t,e){var i,a,n,r,s=[];if(!(64&e[0]))return s;for(a=31&e[0],i=0;i<a;i++)n=3*i,r={type:3&e[n+2],pts:t},4&e[n+2]&&(r.ccData=e[n+3]<<8|e[n+4],s.push(r));return s},o=function(){o.prototype.init.call(this),this.captionPackets_=[],this.ccStreams_=[new l(0,0),new l(0,1),new l(1,0),new l(1,1)],this.reset(),this.ccStreams_.forEach(function(t){t.on("data",this.trigger.bind(this,"data")),t.on("done",this.trigger.bind(this,"done"))},this)};o.prototype=new a,o.prototype.push=function(t){var e,i;if("sei_rbsp"===t.nalUnitType&&(e=n(t.escapedRBSP),4===e.payloadType&&(i=r(e)))){if(t.dts<this.latestDts_)return void(this.ignoreNextEqualDts_=!0);if(t.dts===this.latestDts_&&this.ignoreNextEqualDts_)return void(this.ignoreNextEqualDts_=!1);this.captionPackets_=this.captionPackets_.concat(s(t.pts,i)),this.latestDts_=t.dts}},o.prototype.flush=function(){if(!this.captionPackets_.length)return void this.ccStreams_.forEach(function(t){t.flush()},this);this.captionPackets_.forEach(function(t,e){t.presortIndex=e}),this.captionPackets_.sort(function(t,e){return t.pts===e.pts?t.presortIndex-e.presortIndex:t.pts-e.pts}),this.captionPackets_.forEach(function(t){t.type<2&&this.dispatchCea608Packet(t)},this),this.captionPackets_.length=0,this.ccStreams_.forEach(function(t){t.flush()},this)},o.prototype.reset=function(){this.latestDts_=null,this.ignoreNextEqualDts_=!1,this.activeCea608Channel_=[null,null],this.ccStreams_.forEach(function(t){t.reset()})},o.prototype.dispatchCea608Packet=function(t){this.setsChannel1Active(t)?this.activeCea608Channel_[t.type]=0:this.setsChannel2Active(t)&&(this.activeCea608Channel_[t.type]=1),null!==this.activeCea608Channel_[t.type]&&this.ccStreams_[(t.type<<1)+this.activeCea608Channel_[t.type]].push(t)},o.prototype.setsChannel1Active=function(t){return 4096==(30720&t.ccData)},o.prototype.setsChannel2Active=function(t){return 6144==(30720&t.ccData)};var d={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,304:174,305:176,306:189,307:191,308:8482,309:162,310:163,311:9834,312:224,313:160,314:232,315:226,316:234,317:238,318:244,319:251,544:193,545:201,546:211,547:218,548:220,549:252,550:8216,551:161,552:42,553:39,554:8212,555:169,556:8480,557:8226,558:8220,559:8221,560:192,561:194,562:199,563:200,564:202,565:203,566:235,567:206,568:207,569:239,570:212,571:217,572:249,573:219,574:171,575:187,800:195,801:227,802:205,803:204,804:236,805:210,806:242,807:213,808:245,809:123,810:125,811:92,812:94,813:95,814:124,815:126,816:196,817:228,818:214,819:246,820:223,821:165,822:164,823:9474,824:197,825:229,826:216,827:248,828:9484,829:9488,830:9492,831:9496},h=function(t){return null===t?"":(t=d[t]||t,String.fromCharCode(t))},p=[4352,4384,4608,4640,5376,5408,5632,5664,5888,5920,4096,4864,4896,5120,5152],u=function(){for(var t=[],e=15;e--;)t.push("");return t},l=function(t,e){l.prototype.init.call(this),this.field_=t||0,this.dataChannel_=e||0,this.name_="CC"+(1+(this.field_<<1|this.dataChannel_)),this.setConstants(),this.reset(),this.push=function(t){var e,i,a,n,r;if((e=32639&t.ccData)===this.lastControlCode_)return void(this.lastControlCode_=null);if(4096==(61440&e)?this.lastControlCode_=e:e!==this.PADDING_&&(this.lastControlCode_=null),a=e>>>8,n=255&e,e!==this.PADDING_)if(e===this.RESUME_CAPTION_LOADING_)this.mode_="popOn";else if(e===this.END_OF_CAPTION_)this.clearFormatting(t.pts),this.flushDisplayed(t.pts),i=this.displayed_,this.displayed_=this.nonDisplayed_,this.nonDisplayed_=i,this.startPts_=t.pts;else if(e===this.ROLL_UP_2_ROWS_)this.topRow_=13,this.mode_="rollUp";else if(e===this.ROLL_UP_3_ROWS_)this.topRow_=12,this.mode_="rollUp";else if(e===this.ROLL_UP_4_ROWS_)this.topRow_=11,this.mode_="rollUp";else if(e===this.CARRIAGE_RETURN_)this.clearFormatting(t.pts),this.flushDisplayed(t.pts),this.shiftRowsUp_(),this.startPts_=t.pts;else if(e===this.BACKSPACE_)"popOn"===this.mode_?this.nonDisplayed_[14]=this.nonDisplayed_[14].slice(0,-1):this.displayed_[14]=this.displayed_[14].slice(0,-1);else if(e===this.ERASE_DISPLAYED_MEMORY_)this.flushDisplayed(t.pts),this.displayed_=u();else if(e===this.ERASE_NON_DISPLAYED_MEMORY_)this.nonDisplayed_=u();else if(e===this.RESUME_DIRECT_CAPTIONING_)this.mode_="paintOn";else if(this.isSpecialCharacter(a,n))a=(3&a)<<8,r=h(a|n),this[this.mode_](t.pts,r),this.column_++;else if(this.isExtCharacter(a,n))"popOn"===this.mode_?this.nonDisplayed_[this.row_]=this.nonDisplayed_[this.row_].slice(0,-1):this.displayed_[14]=this.displayed_[14].slice(0,-1),a=(3&a)<<8,r=h(a|n),this[this.mode_](t.pts,r),this.column_++;else if(this.isMidRowCode(a,n))this.clearFormatting(t.pts),this[this.mode_](t.pts," "),this.column_++,14==(14&n)&&this.addFormatting(t.pts,["i"]),1==(1&n)&&this.addFormatting(t.pts,["u"]);else if(this.isOffsetControlCode(a,n))this.column_+=3&n;else if(this.isPAC(a,n)){var s=p.indexOf(7968&e);s!==this.row_&&(this.clearFormatting(t.pts),this.row_=s),1&n&&-1===this.formatting_.indexOf("u")&&this.addFormatting(t.pts,["u"]),16==(16&e)&&(this.column_=4*((14&e)>>1)),this.isColorPAC(n)&&14==(14&n)&&this.addFormatting(t.pts,["i"])}else this.isNormalChar(a)&&(0===n&&(n=null),r=h(a),r+=h(n),this[this.mode_](t.pts,r),this.column_+=r.length)}};l.prototype=new a,l.prototype.flushDisplayed=function(t){var e=this.displayed_.map(function(t){return t.trim()}).join("\n").replace(/^\n+|\n+$/g,"");e.length&&this.trigger("data",{startPts:this.startPts_,endPts:t,text:e,stream:this.name_})},l.prototype.reset=function(){this.mode_="popOn",this.topRow_=0,this.startPts_=0,this.displayed_=u(),this.nonDisplayed_=u(),this.lastControlCode_=null,this.column_=0,this.row_=14,this.formatting_=[]},l.prototype.setConstants=function(){0===this.dataChannel_?(this.BASE_=16,this.EXT_=17,this.CONTROL_=(20|this.field_)<<8,this.OFFSET_=23):1===this.dataChannel_&&(this.BASE_=24,this.EXT_=25,this.CONTROL_=(28|this.field_)<<8,this.OFFSET_=31),this.PADDING_=0,this.RESUME_CAPTION_LOADING_=32|this.CONTROL_,this.END_OF_CAPTION_=47|this.CONTROL_,this.ROLL_UP_2_ROWS_=37|this.CONTROL_,this.ROLL_UP_3_ROWS_=38|this.CONTROL_,this.ROLL_UP_4_ROWS_=39|this.CONTROL_,this.CARRIAGE_RETURN_=45|this.CONTROL_,this.RESUME_DIRECT_CAPTIONING_=41|this.CONTROL_,this.BACKSPACE_=33|this.CONTROL_,this.ERASE_DISPLAYED_MEMORY_=44|this.CONTROL_,this.ERASE_NON_DISPLAYED_MEMORY_=46|this.CONTROL_},l.prototype.isSpecialCharacter=function(t,e){return t===this.EXT_&&e>=48&&e<=63},l.prototype.isExtCharacter=function(t,e){return(t===this.EXT_+1||t===this.EXT_+2)&&e>=32&&e<=63},l.prototype.isMidRowCode=function(t,e){return t===this.EXT_&&e>=32&&e<=47},l.prototype.isOffsetControlCode=function(t,e){return t===this.OFFSET_&&e>=33&&e<=35},l.prototype.isPAC=function(t,e){return t>=this.BASE_&&t<this.BASE_+8&&e>=64&&e<=127},l.prototype.isColorPAC=function(t){return t>=64&&t<=79||t>=96&&t<=127},l.prototype.isNormalChar=function(t){return t>=32&&t<=127},l.prototype.addFormatting=function(t,e){this.formatting_=this.formatting_.concat(e);var i=e.reduce(function(t,e){return t+"<"+e+">"},"");this[this.mode_](t,i)},l.prototype.clearFormatting=function(t){if(this.formatting_.length){var e=this.formatting_.reverse().reduce(function(t,e){return t+"</"+e+">"},"");this.formatting_=[],this[this.mode_](t,e)}},l.prototype.popOn=function(t,e){var i=this.nonDisplayed_[this.row_];i+=e,this.nonDisplayed_[this.row_]=i},l.prototype.rollUp=function(t,e){var i=this.displayed_[14];i+=e,this.displayed_[14]=i},l.prototype.shiftRowsUp_=function(){var t;for(t=0;t<this.topRow_;t++)this.displayed_[t]="";for(t=this.topRow_;t<14;t++)this.displayed_[t]=this.displayed_[t+1];this.displayed_[14]=""},l.prototype.paintOn=function(){},e.exports={CaptionStream:o,Cea608Stream:l}},{}],6:[function(t,e,i){"use strict";var a,n,r,s=t(15),o=t(5),d=t(8),h=t(9).TimestampRolloverStream,p=t(8);a=function(){var t=new Uint8Array(188),e=0;a.prototype.init.call(this),this.push=function(i){var a,n=0,r=188;for(e?(a=new Uint8Array(i.byteLength+e),a.set(t.subarray(0,e)),a.set(i,e),e=0):a=i;r<a.byteLength;)71!==a[n]||71!==a[r]?(n++,r++):(this.trigger("data",a.subarray(n,r)),n+=188,r+=188);n<a.byteLength&&(t.set(a.subarray(n),0),e=a.byteLength-n)},this.flush=function(){188===e&&71===t[0]&&(this.trigger("data",t),e=0),this.trigger("done")}},a.prototype=new s,n=function(){var t,e,i,a;n.prototype.init.call(this),a=this,this.packetsWaitingForPmt=[],this.programMapTable=void 0,t=function(t,a){var n=0;a.payloadUnitStartIndicator&&(n+=t[n]+1),"pat"===a.type?e(t.subarray(n),a):i(t.subarray(n),a)},e=function(t,e){e.section_number=t[7],e.last_section_number=t[8],a.pmtPid=(31&t[10])<<8|t[11],e.pmtPid=a.pmtPid},i=function(t,e){var i,n,r,s;if(1&t[5]){for(a.programMapTable={video:null,audio:null,"timed-metadata":{}},i=(15&t[1])<<8|t[2],n=3+i-4,r=(15&t[10])<<8|t[11],s=12+r;s<n;){var o=t[s],h=(31&t[s+1])<<8|t[s+2];o===d.H264_STREAM_TYPE&&null===a.programMapTable.video?a.programMapTable.video=h:o===d.ADTS_STREAM_TYPE&&null===a.programMapTable.audio?a.programMapTable.audio=h:o===d.METADATA_STREAM_TYPE&&(a.programMapTable["timed-metadata"][h]=o),s+=5+((15&t[s+3])<<8|t[s+4])}e.programMapTable=a.programMapTable}},this.push=function(e){var i={},a=4;if(i.payloadUnitStartIndicator=!!(64&e[1]),i.pid=31&e[1],i.pid<<=8,i.pid|=e[2],(48&e[3])>>>4>1&&(a+=e[a]+1),0===i.pid)i.type="pat",t(e.subarray(a),i),this.trigger("data",i);else if(i.pid===this.pmtPid)for(i.type="pmt",t(e.subarray(a),i),this.trigger("data",i);this.packetsWaitingForPmt.length;)this.processPes_.apply(this,this.packetsWaitingForPmt.shift());else void 0===this.programMapTable?this.packetsWaitingForPmt.push([e,a,i]):this.processPes_(e,a,i)},this.processPes_=function(t,e,i){i.pid===this.programMapTable.video?i.streamType=d.H264_STREAM_TYPE:i.pid===this.programMapTable.audio?i.streamType=d.ADTS_STREAM_TYPE:i.streamType=this.programMapTable["timed-metadata"][i.pid],i.type="pes",i.data=t.subarray(e),this.trigger("data",i)}},n.prototype=new s,n.STREAM_TYPES={h264:27,adts:15},r=function(){var t=this,e={data:[],size:0},i={data:[],size:0},a={data:[],size:0},n=function(t,e){var i;e.packetLength=6+(t[4]<<8|t[5]),e.dataAlignmentIndicator=0!=(4&t[6]),i=t[7],192&i&&(e.pts=(14&t[9])<<27|(255&t[10])<<20|(254&t[11])<<12|(255&t[12])<<5|(254&t[13])>>>3,e.pts*=4,e.pts+=(6&t[13])>>>1,e.dts=e.pts,64&i&&(e.dts=(14&t[14])<<27|(255&t[15])<<20|(254&t[16])<<12|(255&t[17])<<5|(254&t[18])>>>3,e.dts*=4,e.dts+=(6&t[18])>>>1)),e.data=t.subarray(9+t[8])},s=function(e,i,a){var r,s=new Uint8Array(e.size),o={type:i},d=0,h=0,p=!1;if(e.data.length&&!(e.size<9)){for(o.trackId=e.data[0].pid,d=0;d<e.data.length;d++)r=e.data[d],s.set(r.data,h),h+=r.data.byteLength;n(s,o),p="video"===i||o.packetLength<=e.size,(a||p)&&(e.size=0,e.data.length=0),p&&t.trigger("data",o)}};r.prototype.init.call(this),this.push=function(n){({pat:function(){},pes:function(){var t,r;switch(n.streamType){case d.H264_STREAM_TYPE:case p.H264_STREAM_TYPE:t=e,r="video";break;case d.ADTS_STREAM_TYPE:t=i,r="audio";break;case d.METADATA_STREAM_TYPE:t=a,r="timed-metadata";break;default:return}n.payloadUnitStartIndicator&&s(t,r,!0),t.data.push(n),t.size+=n.data.byteLength},pmt:function(){var e={type:"metadata",tracks:[]},i=n.programMapTable;null!==i.video&&e.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+i.video,codec:"avc",type:"video"}),null!==i.audio&&e.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+i.audio,codec:"adts",type:"audio"}),t.trigger("data",e)}})[n.type]()},this.flush=function(){s(e,"video"),s(i,"audio"),s(a,"timed-metadata"),this.trigger("done")}},r.prototype=new s;var u={PAT_PID:0,MP2T_PACKET_LENGTH:188,TransportPacketStream:a,TransportParseStream:n,ElementaryStream:r,TimestampRolloverStream:h,CaptionStream:o.CaptionStream,Cea608Stream:o.Cea608Stream,MetadataStream:t(7)};for(var l in d)d.hasOwnProperty(l)&&(u[l]=d[l]);e.exports=u},{}],7:[function(t,e,i){"use strict";var a,n=t(15),r=t(8),s=function(t,e,i){var a,n="";for(a=e;a<i;a++)n+="%"+("00"+t[a].toString(16)).slice(-2);return n},o=function(t,e,i){return decodeURIComponent(s(t,e,i))},d=function(t,e,i){return unescape(s(t,e,i))},h=function(t){return t[0]<<21|t[1]<<14|t[2]<<7|t[3]},p={TXXX:function(t){var e;if(3===t.data[0]){for(e=1;e<t.data.length;e++)if(0===t.data[e]){t.description=o(t.data,1,e),t.value=o(t.data,e+1,t.data.length).replace(/\0*$/,"");break}t.data=t.value}},WXXX:function(t){var e;if(3===t.data[0])for(e=1;e<t.data.length;e++)if(0===t.data[e]){t.description=o(t.data,1,e),t.url=o(t.data,e+1,t.data.length);break}},PRIV:function(t){var e;for(e=0;e<t.data.length;e++)if(0===t.data[e]){t.owner=d(t.data,0,e);break}t.privateData=t.data.subarray(e+1),t.data=t.privateData}};a=function(t){var e,i={debug:!(!t||!t.debug),descriptor:t&&t.descriptor},n=0,s=[],o=0;if(a.prototype.init.call(this),this.dispatchType=r.METADATA_STREAM_TYPE.toString(16),i.descriptor)for(e=0;e<i.descriptor.length;e++)this.dispatchType+=("00"+i.descriptor[e].toString(16)).slice(-2);this.push=function(t){var e,a,r,d,u,l;if("timed-metadata"===t.type){if(t.dataAlignmentIndicator&&(o=0,s.length=0),0===s.length&&(t.data.length<10||t.data[0]!=="I".charCodeAt(0)||t.data[1]!=="D".charCodeAt(0)||t.data[2]!=="3".charCodeAt(0)))return void(i.debug&&console.log("Skipping unrecognized metadata packet"));if(s.push(t),o+=t.data.byteLength,1===s.length&&(n=h(t.data.subarray(6,10)),n+=10),!(o<n)){for(e={data:new Uint8Array(n),frames:[],pts:s[0].pts,dts:s[0].dts},u=0;u<n;)e.data.set(s[0].data.subarray(0,n-u),u),u+=s[0].data.byteLength,o-=s[0].data.byteLength,s.shift();a=10,64&e.data[5]&&(a+=4,a+=h(e.data.subarray(10,14)),n-=h(e.data.subarray(16,20)));do{if((r=h(e.data.subarray(a+4,a+8)))<1)return console.log("Malformed ID3 frame encountered. Skipping metadata parsing.");if(l=String.fromCharCode(e.data[a],e.data[a+1],e.data[a+2],e.data[a+3]),d={id:l,data:e.data.subarray(a+10,a+r+10)},d.key=d.id,p[d.id]&&(p[d.id](d),"com.apple.streaming.transportStreamTimestamp"===d.owner)){var c=d.data,m=(1&c[3])<<30|c[4]<<22|c[5]<<14|c[6]<<6|c[7]>>>2;m*=4,m+=3&c[7],d.timeStamp=m,void 0===e.pts&&void 0===e.dts&&(e.pts=d.timeStamp,e.dts=d.timeStamp),this.trigger("timestamp",d)}e.frames.push(d),a+=10,a+=r}while(a<n);this.trigger("data",e)}}}},a.prototype=new n,e.exports=a},{}],8:[function(t,e,i){"use strict";e.exports={H264_STREAM_TYPE:27,ADTS_STREAM_TYPE:15,METADATA_STREAM_TYPE:21}},{}],9:[function(t,e,i){"use strict";var a=t(15),n=function(t,e){var i=1;for(t>e&&(i=-1);Math.abs(e-t)>4294967296;)t+=8589934592*i;return t},r=function(t){var e,i;r.prototype.init.call(this),this.type_=t,this.push=function(t){t.type===this.type_&&(void 0===i&&(i=t.dts),t.dts=n(t.dts,i),t.pts=n(t.pts,i),e=t.dts,this.trigger("data",t))},this.flush=function(){i=e,this.trigger("done")},this.discontinuity=function(){i=void 0,e=void 0}};r.prototype=new a,e.exports={TimestampRolloverStream:r,handleRollover:n}},{}],10:[function(t,e,i){e.exports={generator:t(11),Transmuxer:t(12).Transmuxer,AudioSegmentStream:t(12).AudioSegmentStream,VideoSegmentStream:t(12).VideoSegmentStream}},{}],11:[function(t,e,i){"use strict";var a,n,r,s,o,d,h,p,u,l,c,m,f,g,y,_,S,b,v,T,A,C,k,E,w,P,D,L,x,U,M,R,O,I,B,G,N=Math.pow(2,32)-1;!function(){var t;if(k={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],mvex:[],mvhd:[],sdtp:[],smhd:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],styp:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[]},"undefined"!=typeof Uint8Array){for(t in k)k.hasOwnProperty(t)&&(k[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]);E=new Uint8Array(["i".charCodeAt(0),"s".charCodeAt(0),"o".charCodeAt(0),"m".charCodeAt(0)]),P=new Uint8Array(["a".charCodeAt(0),"v".charCodeAt(0),"c".charCodeAt(0),"1".charCodeAt(0)]),w=new Uint8Array([0,0,0,1]),D=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]),L=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]),x={video:D,audio:L},R=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),M=new Uint8Array([0,0,0,0,0,0,0,0]),O=new Uint8Array([0,0,0,0,0,0,0,0]),I=O,B=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),G=O,U=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])}}(),a=function(t){var e,i,a,n=[],r=0;for(e=1;e<arguments.length;e++)n.push(arguments[e]);for(e=n.length;e--;)r+=n[e].byteLength;for(i=new Uint8Array(r+8),a=new DataView(i.buffer,i.byteOffset,i.byteLength),a.setUint32(0,i.byteLength),i.set(t,4),e=0,r=8;e<n.length;e++)i.set(n[e],r),r+=n[e].byteLength;return i},n=function(){return a(k.dinf,a(k.dref,R))},r=function(t){return a(k.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]))},s=function(){return a(k.ftyp,E,w,E,P)},_=function(t){return a(k.hdlr,x[t])},o=function(t){return a(k.mdat,t)},y=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),a(k.mdhd,e)},g=function(t){return a(k.mdia,y(t),_(t.type),h(t))},d=function(t){return a(k.mfhd,new Uint8Array([0,0,0,0,(4278190080&t)>>24,(16711680&t)>>16,(65280&t)>>8,255&t]))},h=function(t){return a(k.minf,"video"===t.type?a(k.vmhd,U):a(k.smhd,M),n(),b(t))},p=function(t,e){for(var i=[],n=e.length;n--;)i[n]=T(e[n]);return a.apply(null,[k.moof,d(t)].concat(i))},u=function(t){for(var e=t.length,i=[];e--;)i[e]=m(t[e]);return a.apply(null,[k.moov,c(4294967295)].concat(i).concat(l(t)))},l=function(t){for(var e=t.length,i=[];e--;)i[e]=A(t[e]);return a.apply(null,[k.mvex].concat(i))},c=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 a(k.mvhd,e)},S=function(t){var e,i,n=t.samples||[],r=new Uint8Array(4+n.length);for(i=0;i<n.length;i++)e=n[i].flags,r[i+4]=e.dependsOn<<4|e.isDependedOn<<2|e.hasRedundancy;return a(k.sdtp,r)},b=function(t){return a(k.stbl,v(t),a(k.stts,G),a(k.stsc,I),a(k.stsz,B),a(k.stco,O))},function(){var t,e;v=function(i){return a(k.stsd,new Uint8Array([0,0,0,0,0,0,0,1]),"video"===i.type?t(i):e(i))},t=function(t){var e,i=t.sps||[],n=t.pps||[],r=[],s=[];for(e=0;e<i.length;e++)r.push((65280&i[e].byteLength)>>>8),r.push(255&i[e].byteLength),r=r.concat(Array.prototype.slice.call(i[e]));for(e=0;e<n.length;e++)s.push((65280&n[e].byteLength)>>>8),s.push(255&n[e].byteLength),s=s.concat(Array.prototype.slice.call(n[e]));return a(k.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&t.width)>>8,255&t.width,(65280&t.height)>>8,255&t.height,0,72,0,0,0,72,0,0,0,0,0,0,0,1,19,118,105,100,101,111,106,115,45,99,111,110,116,114,105,98,45,104,108,115,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),a(k.avcC,new Uint8Array([1,t.profileIdc,t.profileCompatibility,t.levelIdc,255].concat([i.length]).concat(r).concat([n.length]).concat(s))),a(k.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])))},e=function(t){return a(k.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,(65280&t.channelcount)>>8,255&t.channelcount,(65280&t.samplesize)>>8,255&t.samplesize,0,0,0,0,(65280&t.samplerate)>>8,255&t.samplerate,0,0]),r(t))}}(),f=function(t){var e=new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,(4278190080&t.id)>>24,(16711680&t.id)>>16,(65280&t.id)>>8,255&t.id,0,0,0,0,(4278190080&t.duration)>>24,(16711680&t.duration)>>16,(65280&t.duration)>>8,255&t.duration,0,0,0,0,0,0,0,0,0,0,0,0,1,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,(65280&t.width)>>8,255&t.width,0,0,(65280&t.height)>>8,255&t.height,0,0]);return a(k.tkhd,e)},T=function(t){var e,i,n,r,s,o,d;return e=a(k.tfhd,new Uint8Array([0,0,0,58,(4278190080&t.id)>>24,(16711680&t.id)>>16,(65280&t.id)>>8,255&t.id,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0])),o=Math.floor(t.baseMediaDecodeTime/(N+1)),d=Math.floor(t.baseMediaDecodeTime%(N+1)),i=a(k.tfdt,new Uint8Array([1,0,0,0,o>>>24&255,o>>>16&255,o>>>8&255,255&o,d>>>24&255,d>>>16&255,d>>>8&255,255&d])),s=92,"audio"===t.type?(n=C(t,s),a(k.traf,e,i,n)):(r=S(t),n=C(t,r.length+s),a(k.traf,e,i,n,r))},m=function(t){return t.duration=t.duration||4294967295,a(k.trak,f(t),g(t))},A=function(t){var e=new Uint8Array([0,0,0,0,(4278190080&t.id)>>24,(16711680&t.id)>>16,(65280&t.id)>>8,255&t.id,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return"video"!==t.type&&(e[e.length-1]=0),a(k.trex,e)},function(){var t,e,i;i=function(t,e){var i=0,a=0,n=0,r=0;return t.length&&(void 0!==t[0].duration&&(i=1),void 0!==t[0].size&&(a=2),void 0!==t[0].flags&&(n=4),void 0!==t[0].compositionTimeOffset&&(r=8)),[0,0,i|a|n|r,1,(4278190080&t.length)>>>24,(16711680&t.length)>>>16,(65280&t.length)>>>8,255&t.length,(4278190080&e)>>>24,(16711680&e)>>>16,(65280&e)>>>8,255&e]},e=function(t,e){var n,r,s,o;for(r=t.samples||[],e+=20+16*r.length,n=i(r,e),o=0;o<r.length;o++)s=r[o],n=n.concat([(4278190080&s.duration)>>>24,(16711680&s.duration)>>>16,(65280&s.duration)>>>8,255&s.duration,(4278190080&s.size)>>>24,(16711680&s.size)>>>16,(65280&s.size)>>>8,255&s.size,s.flags.isLeading<<2|s.flags.dependsOn,s.flags.isDependedOn<<6|s.flags.hasRedundancy<<4|s.flags.paddingValue<<1|s.flags.isNonSyncSample,61440&s.flags.degradationPriority,15&s.flags.degradationPriority,(4278190080&s.compositionTimeOffset)>>>24,(16711680&s.compositionTimeOffset)>>>16,(65280&s.compositionTimeOffset)>>>8,255&s.compositionTimeOffset]);return a(k.trun,new Uint8Array(n))},t=function(t,e){var n,r,s,o;for(r=t.samples||[],e+=20+8*r.length,n=i(r,e),o=0;o<r.length;o++)s=r[o],n=n.concat([(4278190080&s.duration)>>>24,(16711680&s.duration)>>>16,(65280&s.duration)>>>8,255&s.duration,(4278190080&s.size)>>>24,(16711680&s.size)>>>16,(65280&s.size)>>>8,255&s.size]);return a(k.trun,new Uint8Array(n))},C=function(i,a){return"audio"===i.type?t(i,a):e(i,a)}}(),e.exports={ftyp:s,mdat:o,moof:p,moov:u,initSegment:function(t){var e,i=s(),a=u(t);return e=new Uint8Array(i.byteLength+a.byteLength),e.set(i),e.set(a,i.byteLength),e}}},{}],12:[function(t,e,i){"use strict";var a,n,r,s,o,d,h,p,u,l,c,m=t(15),f=t(11),g=t(6),y=t(2),_=t(3).H264Stream,S=t(1),b=t(4),v=t(13),T=["audioobjecttype","channelcount","samplerate","samplingfrequencyindex","samplesize"],A=["width","height","profileIdc","levelIdc","profileCompatibility"];o=function(){return{size:0,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0,degradationPriority:0}}},d=function(t){return t[0]==="I".charCodeAt(0)&&t[1]==="D".charCodeAt(0)&&t[2]==="3".charCodeAt(0)},l=function(t,e){var i;if(t.length!==e.length)return!1;for(i=0;i<t.length;i++)if(t[i]!==e[i])return!1;return!0},c=function(t){var e,i,a=0;for(e=0;e<t.length;e++)i=t[e],a+=i.data.byteLength;return a},n=function(t){var e=[],i=0,a=0,r=0,s=1/0;n.prototype.init.call(this),this.push=function(i){h(t,i),t&&T.forEach(function(e){t[e]=i[e]}),e.push(i)},this.setEarliestDts=function(e){a=e-t.timelineStartInfo.baseMediaDecodeTime},this.setVideoBaseMediaDecodeTime=function(t){s=t},this.setAudioAppendStart=function(t){r=t},this.flush=function(){var a,n,r,s;if(0===e.length)return void this.trigger("done","AudioSegmentStream");a=this.trimAdtsFramesByEarliestDts_(e),t.baseMediaDecodeTime=u(t),this.prefixWithSilence_(t,a),t.samples=this.generateSampleTable_(a),r=f.mdat(this.concatenateFrameData_(a)),e=[],n=f.moof(i,[t]),s=new Uint8Array(n.byteLength+r.byteLength),i++,s.set(n),s.set(r,n.byteLength),p(t),this.trigger("data",{track:t,boxes:s}),this.trigger("done","AudioSegmentStream")},this.prefixWithSilence_=function(t,e){var i,a,n,o=0,d=0,h=0,p=0;if(e.length&&(i=v.audioTsToVideoTs(t.baseMediaDecodeTime,t.samplerate),o=Math.ceil(9e4/(t.samplerate/1024)),r&&s&&(d=i-Math.max(r,s),h=Math.floor(d/o),p=h*o),!(h<1||p>45e3))){for(a=b[t.samplerate],a||(a=e[0].data),n=0;n<h;n++)e.splice(n,0,{data:a});t.baseMediaDecodeTime-=Math.floor(v.videoTsToAudioTs(p,t.samplerate))}},this.trimAdtsFramesByEarliestDts_=function(e){return t.minSegmentDts>=a?e:(t.minSegmentDts=1/0,e.filter(function(e){return e.dts>=a&&(t.minSegmentDts=Math.min(t.minSegmentDts,e.dts),t.minSegmentPts=t.minSegmentDts,!0)}))},this.generateSampleTable_=function(t){var e,i,a=[];for(e=0;e<t.length;e++)i=t[e],a.push({size:i.data.byteLength,duration:1024});return a},this.concatenateFrameData_=function(t){var e,i,a=0,n=new Uint8Array(c(t));for(e=0;e<t.length;e++)i=t[e],n.set(i.data,a),a+=i.data.byteLength
;return n}},n.prototype=new m,a=function(t,e){var i,n,r=0,s=[],d=[];e=e||{},a.prototype.init.call(this),delete t.minPTS,this.gopCache_=[],this.push=function(e){h(t,e),"seq_parameter_set_rbsp"!==e.nalUnitType||i||(i=e.config,t.sps=[e.data],A.forEach(function(e){t[e]=i[e]},this)),"pic_parameter_set_rbsp"!==e.nalUnitType||n||(n=e.data,t.pps=[e.data]),s.push(e)},this.flush=function(){for(var i,a,n,o,l,c;s.length&&"access_unit_delimiter_rbsp"!==s[0].nalUnitType;)s.shift();if(0===s.length)return this.resetStream_(),void this.trigger("done","VideoSegmentStream");if(i=this.groupNalsIntoFrames_(s),n=this.groupFramesIntoGops_(i),n[0][0].keyFrame||(a=this.getGopForFusion_(s[0],t),a?(n.unshift(a),n.byteLength+=a.byteLength,n.nalCount+=a.nalCount,n.pts=a.pts,n.dts=a.dts,n.duration+=a.duration):n=this.extendFirstKeyFrame_(n)),d.length){var m;if(!(m=e.alignGopsAtEnd?this.alignGopsAtEnd_(n):this.alignGopsAtStart_(n)))return this.gopCache_.unshift({gop:n.pop(),pps:t.pps,sps:t.sps}),this.gopCache_.length=Math.min(6,this.gopCache_.length),s=[],this.resetStream_(),void this.trigger("done","VideoSegmentStream");p(t),n=m}h(t,n),t.samples=this.generateSampleTable_(n),l=f.mdat(this.concatenateNalData_(n)),t.baseMediaDecodeTime=u(t),this.trigger("processedGopsInfo",n.map(function(t){return{pts:t.pts,dts:t.dts,byteLength:t.byteLength}})),this.gopCache_.unshift({gop:n.pop(),pps:t.pps,sps:t.sps}),this.gopCache_.length=Math.min(6,this.gopCache_.length),s=[],this.trigger("baseMediaDecodeTime",t.baseMediaDecodeTime),this.trigger("timelineStartInfo",t.timelineStartInfo),o=f.moof(r,[t]),c=new Uint8Array(o.byteLength+l.byteLength),r++,c.set(o),c.set(l,o.byteLength),this.trigger("data",{track:t,boxes:c}),this.resetStream_(),this.trigger("done","VideoSegmentStream")},this.resetStream_=function(){p(t),i=void 0,n=void 0},this.getGopForFusion_=function(e){var i,a,n,r,s,o=1/0;for(s=0;s<this.gopCache_.length;s++)r=this.gopCache_[s],n=r.gop,t.pps&&l(t.pps[0],r.pps[0])&&t.sps&&l(t.sps[0],r.sps[0])&&(n.dts<t.timelineStartInfo.dts||(i=e.dts-n.dts-n.duration)>=-1e4&&i<=45e3&&(!a||o>i)&&(a=r,o=i));return a?a.gop:null},this.extendFirstKeyFrame_=function(t){var e;return!t[0][0].keyFrame&&t.length>1&&(e=t.shift(),t.byteLength-=e.byteLength,t.nalCount-=e.nalCount,t[0][0].dts=e.dts,t[0][0].pts=e.pts,t[0][0].duration+=e.duration),t},this.groupNalsIntoFrames_=function(t){var e,i,a=[],n=[];for(a.byteLength=0,e=0;e<t.length;e++)i=t[e],"access_unit_delimiter_rbsp"===i.nalUnitType?(a.length&&(a.duration=i.dts-a.dts,n.push(a)),a=[i],a.byteLength=i.data.byteLength,a.pts=i.pts,a.dts=i.dts):("slice_layer_without_partitioning_rbsp_idr"===i.nalUnitType&&(a.keyFrame=!0),a.duration=i.dts-a.dts,a.byteLength+=i.data.byteLength,a.push(i));return n.length&&(!a.duration||a.duration<=0)&&(a.duration=n[n.length-1].duration),n.push(a),n},this.groupFramesIntoGops_=function(t){var e,i,a=[],n=[];for(a.byteLength=0,a.nalCount=0,a.duration=0,a.pts=t[0].pts,a.dts=t[0].dts,n.byteLength=0,n.nalCount=0,n.duration=0,n.pts=t[0].pts,n.dts=t[0].dts,e=0;e<t.length;e++)i=t[e],i.keyFrame?(a.length&&(n.push(a),n.byteLength+=a.byteLength,n.nalCount+=a.nalCount,n.duration+=a.duration),a=[i],a.nalCount=i.length,a.byteLength=i.byteLength,a.pts=i.pts,a.dts=i.dts,a.duration=i.duration):(a.duration+=i.duration,a.nalCount+=i.length,a.byteLength+=i.byteLength,a.push(i));return n.length&&a.duration<=0&&(a.duration=n[n.length-1].duration),n.byteLength+=a.byteLength,n.nalCount+=a.nalCount,n.duration+=a.duration,n.push(a),n},this.generateSampleTable_=function(t,e){var i,a,n,r,s,d=e||0,h=[];for(i=0;i<t.length;i++)for(r=t[i],a=0;a<r.length;a++)s=r[a],n=o(),n.dataOffset=d,n.compositionTimeOffset=s.pts-s.dts,n.duration=s.duration,n.size=4*s.length,n.size+=s.byteLength,s.keyFrame&&(n.flags.dependsOn=2),d+=n.size,h.push(n);return h},this.concatenateNalData_=function(t){var e,i,a,n,r,s,o=0,d=t.byteLength,h=t.nalCount,p=d+4*h,u=new Uint8Array(p),l=new DataView(u.buffer);for(e=0;e<t.length;e++)for(n=t[e],i=0;i<n.length;i++)for(r=n[i],a=0;a<r.length;a++)s=r[a],l.setUint32(o,s.data.byteLength),o+=4,u.set(s.data,o),o+=s.data.byteLength;return u},this.alignGopsAtStart_=function(t){var e,i,a,n,r,s,o,h;for(r=t.byteLength,s=t.nalCount,o=t.duration,e=i=0;e<d.length&&i<t.length&&(a=d[e],n=t[i],a.pts!==n.pts);)n.pts>a.pts?e++:(i++,r-=n.byteLength,s-=n.nalCount,o-=n.duration);return 0===i?t:i===t.length?null:(h=t.slice(i),h.byteLength=r,h.duration=o,h.nalCount=s,h.pts=h[0].pts,h.dts=h[0].dts,h)},this.alignGopsAtEnd_=function(t){var e,i,a,n,r,s;for(e=d.length-1,i=t.length-1,r=null,s=!1;e>=0&&i>=0;){if(a=d[e],n=t[i],a.pts===n.pts){s=!0;break}a.pts>n.pts?e--:(e===d.length-1&&(r=i),i--)}if(!s&&null===r)return null;var o;if(0===(o=s?i:r))return t;var h=t.slice(o),p=h.reduce(function(t,e){return t.byteLength+=e.byteLength,t.duration+=e.duration,t.nalCount+=e.nalCount,t},{byteLength:0,duration:0,nalCount:0});return h.byteLength=p.byteLength,h.duration=p.duration,h.nalCount=p.nalCount,h.pts=h[0].pts,h.dts=h[0].dts,h},this.alignGopsWith=function(t){d=t}},a.prototype=new m,h=function(t,e){"number"==typeof e.pts&&(void 0===t.timelineStartInfo.pts&&(t.timelineStartInfo.pts=e.pts),void 0===t.minSegmentPts?t.minSegmentPts=e.pts:t.minSegmentPts=Math.min(t.minSegmentPts,e.pts),void 0===t.maxSegmentPts?t.maxSegmentPts=e.pts:t.maxSegmentPts=Math.max(t.maxSegmentPts,e.pts)),"number"==typeof e.dts&&(void 0===t.timelineStartInfo.dts&&(t.timelineStartInfo.dts=e.dts),void 0===t.minSegmentDts?t.minSegmentDts=e.dts:t.minSegmentDts=Math.min(t.minSegmentDts,e.dts),void 0===t.maxSegmentDts?t.maxSegmentDts=e.dts:t.maxSegmentDts=Math.max(t.maxSegmentDts,e.dts))},p=function(t){delete t.minSegmentDts,delete t.maxSegmentDts,delete t.minSegmentPts,delete t.maxSegmentPts},u=function(t){var e,i,a=t.minSegmentDts-t.timelineStartInfo.dts;return e=t.timelineStartInfo.baseMediaDecodeTime,e+=a,e=Math.max(0,e),"audio"===t.type&&(i=t.samplerate/9e4,e*=i,e=Math.floor(e)),e},s=function(t,e){this.numberOfTracks=0,this.metadataStream=e,void 0!==t.remux?this.remuxTracks=!!t.remux:this.remuxTracks=!0,this.pendingTracks=[],this.videoTrack=null,this.pendingBoxes=[],this.pendingCaptions=[],this.pendingMetadata=[],this.pendingBytes=0,this.emittedTracks=0,s.prototype.init.call(this),this.push=function(t){return t.text?this.pendingCaptions.push(t):t.frames?this.pendingMetadata.push(t):(this.pendingTracks.push(t.track),this.pendingBoxes.push(t.boxes),this.pendingBytes+=t.boxes.byteLength,"video"===t.track.type&&(this.videoTrack=t.track),void("audio"===t.track.type&&(this.audioTrack=t.track)))}},s.prototype=new m,s.prototype.flush=function(t){var e,i,a,n,r=0,s={captions:[],captionStreams:{},metadata:[],info:{}},o=0;if(this.pendingTracks.length<this.numberOfTracks){if("VideoSegmentStream"!==t&&"AudioSegmentStream"!==t)return;if(this.remuxTracks)return;if(0===this.pendingTracks.length)return void(++this.emittedTracks>=this.numberOfTracks&&(this.trigger("done"),this.emittedTracks=0))}for(this.videoTrack?(o=this.videoTrack.timelineStartInfo.pts,A.forEach(function(t){s.info[t]=this.videoTrack[t]},this)):this.audioTrack&&(o=this.audioTrack.timelineStartInfo.pts,T.forEach(function(t){s.info[t]=this.audioTrack[t]},this)),1===this.pendingTracks.length?s.type=this.pendingTracks[0].type:s.type="combined",this.emittedTracks+=this.pendingTracks.length,a=f.initSegment(this.pendingTracks),s.initSegment=new Uint8Array(a.byteLength),s.initSegment.set(a),s.data=new Uint8Array(this.pendingBytes),n=0;n<this.pendingBoxes.length;n++)s.data.set(this.pendingBoxes[n],r),r+=this.pendingBoxes[n].byteLength;for(n=0;n<this.pendingCaptions.length;n++)e=this.pendingCaptions[n],e.startTime=e.startPts-o,e.startTime/=9e4,e.endTime=e.endPts-o,e.endTime/=9e4,s.captionStreams[e.stream]=!0,s.captions.push(e);for(n=0;n<this.pendingMetadata.length;n++)i=this.pendingMetadata[n],i.cueTime=i.pts-o,i.cueTime/=9e4,s.metadata.push(i);s.metadata.dispatchType=this.metadataStream.dispatchType,this.pendingTracks.length=0,this.videoTrack=null,this.pendingBoxes.length=0,this.pendingCaptions.length=0,this.pendingBytes=0,this.pendingMetadata.length=0,this.trigger("data",s),this.emittedTracks>=this.numberOfTracks&&(this.trigger("done"),this.emittedTracks=0)},r=function(t){var e,i,o=this,h=!0;r.prototype.init.call(this),t=t||{},this.baseMediaDecodeTime=t.baseMediaDecodeTime||0,this.transmuxPipeline_={},this.setupAacPipeline=function(){var e={};this.transmuxPipeline_=e,e.type="aac",e.metadataStream=new g.MetadataStream,e.aacStream=new S,e.audioTimestampRolloverStream=new g.TimestampRolloverStream("audio"),e.timedMetadataTimestampRolloverStream=new g.TimestampRolloverStream("timed-metadata"),e.adtsStream=new y,e.coalesceStream=new s(t,e.metadataStream),e.headOfPipeline=e.aacStream,e.aacStream.pipe(e.audioTimestampRolloverStream).pipe(e.adtsStream),e.aacStream.pipe(e.timedMetadataTimestampRolloverStream).pipe(e.metadataStream).pipe(e.coalesceStream),e.metadataStream.on("timestamp",function(t){e.aacStream.setTimestamp(t.timeStamp)}),e.aacStream.on("data",function(t){"timed-metadata"!==t.type||e.audioSegmentStream||(i=i||{timelineStartInfo:{baseMediaDecodeTime:o.baseMediaDecodeTime},codec:"adts",type:"audio"},e.coalesceStream.numberOfTracks++,e.audioSegmentStream=new n(i),e.adtsStream.pipe(e.audioSegmentStream).pipe(e.coalesceStream))}),e.coalesceStream.on("data",this.trigger.bind(this,"data")),e.coalesceStream.on("done",this.trigger.bind(this,"done"))},this.setupTsPipeline=function(){var r={};this.transmuxPipeline_=r,r.type="ts",r.metadataStream=new g.MetadataStream,r.packetStream=new g.TransportPacketStream,r.parseStream=new g.TransportParseStream,r.elementaryStream=new g.ElementaryStream,r.videoTimestampRolloverStream=new g.TimestampRolloverStream("video"),r.audioTimestampRolloverStream=new g.TimestampRolloverStream("audio"),r.timedMetadataTimestampRolloverStream=new g.TimestampRolloverStream("timed-metadata"),r.adtsStream=new y,r.h264Stream=new _,r.captionStream=new g.CaptionStream,r.coalesceStream=new s(t,r.metadataStream),r.headOfPipeline=r.packetStream,r.packetStream.pipe(r.parseStream).pipe(r.elementaryStream),r.elementaryStream.pipe(r.videoTimestampRolloverStream).pipe(r.h264Stream),r.elementaryStream.pipe(r.audioTimestampRolloverStream).pipe(r.adtsStream),r.elementaryStream.pipe(r.timedMetadataTimestampRolloverStream).pipe(r.metadataStream).pipe(r.coalesceStream),r.h264Stream.pipe(r.captionStream).pipe(r.coalesceStream),r.elementaryStream.on("data",function(s){var d;if("metadata"===s.type){for(d=s.tracks.length;d--;)e||"video"!==s.tracks[d].type?i||"audio"!==s.tracks[d].type||(i=s.tracks[d],i.timelineStartInfo.baseMediaDecodeTime=o.baseMediaDecodeTime):(e=s.tracks[d],e.timelineStartInfo.baseMediaDecodeTime=o.baseMediaDecodeTime);e&&!r.videoSegmentStream&&(r.coalesceStream.numberOfTracks++,r.videoSegmentStream=new a(e,t),r.videoSegmentStream.on("timelineStartInfo",function(t){i&&(i.timelineStartInfo=t,r.audioSegmentStream.setEarliestDts(t.dts))}),r.videoSegmentStream.on("processedGopsInfo",o.trigger.bind(o,"gopInfo")),r.videoSegmentStream.on("baseMediaDecodeTime",function(t){i&&r.audioSegmentStream.setVideoBaseMediaDecodeTime(t)}),r.h264Stream.pipe(r.videoSegmentStream).pipe(r.coalesceStream)),i&&!r.audioSegmentStream&&(r.coalesceStream.numberOfTracks++,r.audioSegmentStream=new n(i),r.adtsStream.pipe(r.audioSegmentStream).pipe(r.coalesceStream))}}),r.coalesceStream.on("data",this.trigger.bind(this,"data")),r.coalesceStream.on("done",this.trigger.bind(this,"done"))},this.setBaseMediaDecodeTime=function(t){var a=this.transmuxPipeline_;this.baseMediaDecodeTime=t,i&&(i.timelineStartInfo.dts=void 0,i.timelineStartInfo.pts=void 0,p(i),i.timelineStartInfo.baseMediaDecodeTime=t,a.audioTimestampRolloverStream&&a.audioTimestampRolloverStream.discontinuity()),e&&(a.videoSegmentStream&&(a.videoSegmentStream.gopCache_=[],a.videoTimestampRolloverStream.discontinuity()),e.timelineStartInfo.dts=void 0,e.timelineStartInfo.pts=void 0,p(e),a.captionStream.reset(),e.timelineStartInfo.baseMediaDecodeTime=t),a.timedMetadataTimestampRolloverStream&&a.timedMetadataTimestampRolloverStream.discontinuity()},this.setAudioAppendStart=function(t){i&&this.transmuxPipeline_.audioSegmentStream.setAudioAppendStart(t)},this.alignGopsWith=function(t){e&&this.transmuxPipeline_.videoSegmentStream&&this.transmuxPipeline_.videoSegmentStream.alignGopsWith(t)},this.push=function(t){if(h){var e=d(t);e&&"aac"!==this.transmuxPipeline_.type?this.setupAacPipeline():e||"ts"===this.transmuxPipeline_.type||this.setupTsPipeline(),h=!1}this.transmuxPipeline_.headOfPipeline.push(t)},this.flush=function(){h=!0,this.transmuxPipeline_.headOfPipeline.flush()},this.resetCaptions=function(){this.transmuxPipeline_.captionStream&&this.transmuxPipeline_.captionStream.reset()}},r.prototype=new m,e.exports={Transmuxer:r,VideoSegmentStream:a,AudioSegmentStream:n,AUDIO_PROPERTIES:T,VIDEO_PROPERTIES:A}},{}],13:[function(t,e,i){var a,n,r,s,o,d;a=function(t){return 9e4*t},n=function(t,e){return t*e},r=function(t){return t/9e4},s=function(t,e){return t/e},o=function(t,e){return a(s(t,e))},d=function(t,e){return n(r(t),e)},e.exports={secondsToVideoTs:a,secondsToAudioTs:n,videoTsToSeconds:r,audioTsToSeconds:s,audioTsToVideoTs:o,videoTsToAudioTs:d}},{}],14:[function(t,e,i){"use strict";var a;a=function(t){var e=t.byteLength,i=0,a=0;this.length=function(){return 8*e},this.bitsAvailable=function(){return 8*e+a},this.loadWord=function(){var n=t.byteLength-e,r=new Uint8Array(4),s=Math.min(4,e);if(0===s)throw new Error("no bytes available");r.set(t.subarray(n,n+s)),i=new DataView(r.buffer).getUint32(0),a=8*s,e-=s},this.skipBits=function(t){var n;a>t?(i<<=t,a-=t):(t-=a,n=Math.floor(t/8),t-=8*n,e-=n,this.loadWord(),i<<=t,a-=t)},this.readBits=function(t){var n=Math.min(a,t),r=i>>>32-n;return a-=n,a>0?i<<=n:e>0&&this.loadWord(),n=t-n,n>0?r<<n|this.readBits(n):r},this.skipLeadingZeros=function(){var t;for(t=0;t<a;++t)if(0!=(i&2147483648>>>t))return i<<=t,a-=t,t;return this.loadWord(),t+this.skipLeadingZeros()},this.skipUnsignedExpGolomb=function(){this.skipBits(1+this.skipLeadingZeros())},this.skipExpGolomb=function(){this.skipBits(1+this.skipLeadingZeros())},this.readUnsignedExpGolomb=function(){var t=this.skipLeadingZeros();return this.readBits(t+1)-1},this.readExpGolomb=function(){var t=this.readUnsignedExpGolomb();return 1&t?1+t>>>1:-1*(t>>>1)},this.readBoolean=function(){return 1===this.readBits(1)},this.readUnsignedByte=function(){return this.readBits(8)},this.loadWord()},e.exports=a},{}],15:[function(t,e,i){"use strict";var a=function(){this.init=function(){var t={};this.on=function(e,i){t[e]||(t[e]=[]),t[e]=t[e].concat(i)},this.off=function(e,i){var a;return!!t[e]&&(a=t[e].indexOf(i),t[e]=t[e].slice(),t[e].splice(a,1),a>-1)},this.trigger=function(e){var i,a,n,r;if(i=t[e])if(2===arguments.length)for(n=i.length,a=0;a<n;++a)i[a].call(this,arguments[1]);else{for(r=[],a=arguments.length,a=1;a<arguments.length;++a)r.push(arguments[a]);for(n=i.length,a=0;a<n;++a)i[a].apply(this,r)}},this.dispose=function(){t={}}}};a.prototype.pipe=function(t){return this.on("data",function(e){t.push(e)}),this.on("done",function(e){t.flush(e)}),t},a.prototype.push=function(t){this.trigger("data",t)},a.prototype.flush=function(t){this.trigger("done",t)},e.exports=a},{}]},{},[10]);