!function t(e,i,n){function a(s,o){if(!i[s]){if(!e[s]){var h="function"==typeof require&&require;if(!o&&h)return h(s,!0);if(r)return r(s,!0);var d=new Error("Cannot find module '"+s+"'");throw d.code="MODULE_NOT_FOUND",d}var p=i[s]={exports:{}};e[s][0].call(p.exports,function(t){var i=e[s][1][t];return a(i||t)},p,p.exports,t,e,i,n)}return i[s].exports}for(var r="function"==typeof require&&require,s=0;s>4?i+20:i+10},this.parseAdtsSize=function(t,e){var i=(224&t[e+5])>>5,n=t[e+4]<<3;return 6144&t[e+3]|n|i},this.push=function(i){var n,a,r,s,o=0,h=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-h>=3;)if(t[h]!=="I".charCodeAt(0)||t[h+1]!=="D".charCodeAt(0)||t[h+2]!=="3".charCodeAt(0))if(!0&t[h]&&240==(240&t[h+1])){if(t.length-h<7)break;if((o=this.parseAdtsSize(t,h))>t.length)break;r={type:"audio",data:t.subarray(h,h+o),pts:e,dts:e},this.trigger("data",r),h+=o}else h++;else{if(t.length-h<10)break;if((o=this.parseId3TagSize(t,h))>t.length)break;a={type:"timed-metadata",data:t.subarray(h,h+o)},this.trigger("data",a),h+=o}n=t.length-h,t=n>0?t.subarray(h):new Uint8Array}},n.prototype=new a,e.exports=n},{}],2:[function(t,e,i){"use strict";var n=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],a=function(t){return t[0]<<21|t[1]<<14|t[2]<<7|t[3]},r=function(t,e,i){var n,a="";for(n=e;n>4?i+20:i+10},h=function(t,e){var i=(224&t[e+5])>>5,n=t[e+4]<<3;return 6144&t[e+3]|n|i},d=function(t,e){return t[e]==="I".charCodeAt(0)&&t[e+1]==="D".charCodeAt(0)&&t[e+2]==="3".charCodeAt(0)?"timed-metadata":!0&t[e]&&240==(240&t[e+1])?"audio":null},p=function(t){for(var e=0;e+5>>2];e++}return null},u=function(t){var e,i,n;e=10,64&t[5]&&(e+=4,e+=a(t.subarray(10,14)));do{if((i=a(t.subarray(e+4,e+8)))<1)return null;if("PRIV"===String.fromCharCode(t[e],t[e+1],t[e+2],t[e+3])){n=t.subarray(e+10,e+i+10);for(var r=0;r>>2;return d*=4,d+=3&h[7]}break}}e+=10,e+=i}while(e>5,o=1024*(1+(3&t[d+6])),h=9e4*o/r[(60&t[d+2])>>>2],a=d+i,t.byteLength>>6&3),channelcount:(1&t[d+2])<<2|(192&t[d+3])>>>6,samplerate:r[(60&t[d+2])>>>2],samplingfrequencyindex:(60&t[d+2])>>>2,samplesize:16,data:t.subarray(d+7+n,a)}),t.byteLength===a)return void(t=void 0);p++,t=t.subarray(a)}else d++},this.flush=function(){this.trigger("done")}},n.prototype=new a,e.exports=n},{}],4:[function(t,e,i){"use strict";var n,a,r,s=t(30),o=t(29);a=function(){var t,e,i=0;a.prototype.init.call(this),this.push=function(n){var a;for(e?(a=new Uint8Array(e.byteLength+n.data.byteLength),a.set(e),a.set(n.data,e.byteLength),e=a):e=n.data;i3&&this.trigger("data",e.subarray(i+3)),e=null,i=0,this.trigger("done")}},a.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},n=function(){var t,e,i,s,h,d,p,u=new a;n.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(n){var a={trackId:e,pts:i,dts:s,data:n};switch(31&n[0]){case 5:a.nalUnitType="slice_layer_without_partitioning_rbsp_idr";break;case 6:a.nalUnitType="sei_rbsp",a.escapedRBSP=h(n.subarray(1));break;case 7:a.nalUnitType="seq_parameter_set_rbsp",a.escapedRBSP=h(n.subarray(1)),a.config=d(a.escapedRBSP);break;case 8:a.nalUnitType="pic_parameter_set_rbsp";break;case 9:a.nalUnitType="access_unit_delimiter_rbsp"}t.trigger("data",a)}),u.on("done",function(){t.trigger("done")}),this.flush=function(){u.flush()},p=function(t,e){var i,n,a=8,r=8;for(i=0;i0)throw new Error("Attempted to create new NAL wihout closing the old one");a=this.length,this.length+=4,this.position=this.length},this.endNalUnit=function(t){var e,i;this.length===a+4?this.length-=4:a>0&&(e=a+4,i=this.length-e,this.position=a,this.view.setUint32(this.position,i),this.position=this.length,t&&t.push(this.bytes.subarray(e,e+i))),a=0},this.writeMetaDataDouble=function(t,e){var i;if(s(this,2+t.length+9),this.view.setUint16(this.position,t.length),this.position+=2,"width"===t)this.bytes.set(o,this.position),this.position+=5;else if("height"===t)this.bytes.set(h,this.position),this.position+=6;else if("videocodecid"===t)this.bytes.set(d,this.position),this.position+=12;else for(i=0;i>>16,this.bytes[14]=(65280&t)>>>8,this.bytes[15]=(255&t)>>>0;break;case n.AUDIO_TAG:this.bytes[11]=175,this.bytes[12]=e?0:1;break;case n.METADATA_TAG:this.position=11,this.view.setUint8(this.position,2),this.position++,this.view.setUint16(this.position,10),this.position+=2,this.bytes.set([111,110,77,101,116,97,68,97,116,97],this.position),this.position+=10,this.bytes[this.position]=8,this.position++,this.view.setUint32(this.position,a),this.position=this.length,this.bytes.set([0,0,9],this.position),this.position+=3,this.length=this.position}return i=this.length-11,this.bytes[1]=(16711680&i)>>>16,this.bytes[2]=(65280&i)>>>8,this.bytes[3]=(255&i)>>>0,this.bytes[4]=(16711680&this.dts)>>>16,this.bytes[5]=(65280&this.dts)>>>8,this.bytes[6]=(255&this.dts)>>>0,this.bytes[7]=(4278190080&this.dts)>>>24,this.bytes[8]=0,this.bytes[9]=0,this.bytes[10]=0,s(this,4),this.view.setUint32(this.length,this.length),this.length+=4,this.position+=4,this.bytes=this.bytes.subarray(0,this.length),this.frameTime=n.frameTime(this.bytes),this}},n.AUDIO_TAG=8,n.VIDEO_TAG=9,n.METADATA_TAG=18,n.isAudioFrame=function(t){return n.AUDIO_TAG===t[0]},n.isVideoFrame=function(t){return n.VIDEO_TAG===t[0]},n.isMetaData=function(t){return n.METADATA_TAG===t[0]},n.isKeyFrame=function(t){return n.isVideoFrame(t)?23===t[11]:!!n.isAudioFrame(t)||!!n.isMetaData(t)},n.frameTime=function(t){var e=t[4]<<16;return e|=t[5]<<8,e|=t[6]<<0,e|=t[7]<<24},e.exports=n},{}],10:[function(t,e,i){e.exports={tag:t(9),Transmuxer:t(12),getFlvHeader:t(8)}},{}],11:[function(t,e,i){"use strict";var n=function(){var t=this;this.list=[],this.push=function(t){this.list.push({bytes:t.bytes,dts:t.dts,pts:t.pts,keyFrame:t.keyFrame,metaDataTag:t.metaDataTag})},Object.defineProperty(this,"length",{get:function(){return t.list.length}})};e.exports=n},{}],12:[function(t,e,i){"use strict";var n,a,r,s,o,h,d=t(30),p=t(9),u=t(16),c=t(3),l=t(4).H264Stream,f=t(7),m=t(11);s=function(t,e){"number"==typeof e.pts&&(void 0===t.timelineStartInfo.pts?t.timelineStartInfo.pts=e.pts:t.timelineStartInfo.pts=Math.min(t.timelineStartInfo.pts,e.pts)),"number"==typeof e.dts&&(void 0===t.timelineStartInfo.dts?t.timelineStartInfo.dts=e.dts:t.timelineStartInfo.dts=Math.min(t.timelineStartInfo.dts,e.dts))},o=function(t,e){var i=new p(p.METADATA_TAG);return i.dts=e,i.pts=e,i.writeMetaDataDouble("videocodecid",7),i.writeMetaDataDouble("width",t.width),i.writeMetaDataDouble("height",t.height),i},h=function(t,e){var i,n=new p(p.VIDEO_TAG,!0);for(n.dts=e,n.pts=e,n.writeByte(1),n.writeByte(t.profileIdc),n.writeByte(t.profileCompatibility),n.writeByte(t.levelIdc),n.writeByte(255),n.writeByte(225),n.writeShort(t.sps[0].length),n.writeBytes(t.sps[0]),n.writeByte(t.pps.length),i=0;i=n[0]&&(s=n.shift(),this.writeMetaDataTags(o,s)),(t.extraData!==e||a.pts-s>=1e3)&&(this.writeMetaDataTags(o,a.pts),e=t.extraData,s=a.pts),r=new p(p.AUDIO_TAG),r.pts=a.pts,r.dts=a.dts,r.writeBytes(a.data),o.push(r.finalize());n.length=0,e=null,this.trigger("data",{track:t,tags:o.list}),this.trigger("done","AudioSegmentStream")},this.writeMetaDataTags=function(e,i){var n;n=new p(p.METADATA_TAG),n.pts=i,n.dts=i,n.writeMetaDataDouble("audiocodecid",10),n.writeMetaDataBoolean("stereo",2===t.channelcount),n.writeMetaDataDouble("audiosamplerate",t.samplerate),n.writeMetaDataDouble("audiosamplesize",16),e.push(n.finalize()),n=new p(p.AUDIO_TAG,!0),n.pts=i,n.dts=i,n.view.setUint16(n.position,t.extraData),n.position+=2,n.length=Math.max(n.length,n.position),e.push(n.finalize())},this.onVideoKeyFrame=function(t){n.push(t)}},r.prototype=new d,a=function(t){var e,i,n=[];a.prototype.init.call(this),this.finishFrame=function(n,a){if(a){if(e&&t&&t.newMetadata&&(a.keyFrame||0===n.length)){var r=o(e,a.dts).finalize(),s=h(t,a.dts).finalize();r.metaDataTag=s.metaDataTag=!0,n.push(r),n.push(s),t.newMetadata=!1,this.trigger("keyframe",a.dts)}a.endNalUnit(),n.push(a.finalize()),i=null}},this.push=function(e){s(t,e),e.pts=Math.round(e.pts/90),e.dts=Math.round(e.dts/90),n.push(e)},this.flush=function(){for(var a,r=new m;n.length&&"access_unit_delimiter_rbsp"!==n[0].nalUnitType;)n.shift();if(0===n.length)return void this.trigger("done","VideoSegmentStream");for(;n.length;)a=n.shift(),"seq_parameter_set_rbsp"===a.nalUnitType?(t.newMetadata=!0,e=a.config,t.width=e.width,t.height=e.height,t.sps=[a.data],t.profileIdc=e.profileIdc,t.levelIdc=e.levelIdc,t.profileCompatibility=e.profileCompatibility,i.endNalUnit()):"pic_parameter_set_rbsp"===a.nalUnitType?(t.newMetadata=!0,t.pps=[a.data],i.endNalUnit()):"access_unit_delimiter_rbsp"===a.nalUnitType?(i&&this.finishFrame(r,i),i=new p(p.VIDEO_TAG),i.pts=a.pts,i.dts=a.dts):("slice_layer_without_partitioning_rbsp_idr"===a.nalUnitType&&(i.keyFrame=!0),i.endNalUnit()),i.startNalUnit(),i.writeBytes(a.data);i&&this.finishFrame(r,i),this.trigger("data",{track:t,tags:r.list}),this.trigger("done","VideoSegmentStream")}},a.prototype=new d,n=function(t){var e,i,s,o,h,d,p,m,g,y,b,v,T=this;n.prototype.init.call(this),t=t||{},this.metadataStream=new u.MetadataStream,t.metadataStream=this.metadataStream,e=new u.TransportPacketStream,i=new u.TransportParseStream,s=new u.ElementaryStream,o=new u.TimestampRolloverStream("video"),h=new u.TimestampRolloverStream("audio"),d=new u.TimestampRolloverStream("timed-metadata"),p=new c,m=new l,v=new f(t),e.pipe(i).pipe(s),s.pipe(o).pipe(m),s.pipe(h).pipe(p),s.pipe(d).pipe(this.metadataStream).pipe(v),b=new u.CaptionStream,m.pipe(b).pipe(v),s.on("data",function(t){var e,i,n;if("metadata"===t.type){for(e=t.tracks.length;e--;)"video"===t.tracks[e].type?i=t.tracks[e]:"audio"===t.tracks[e].type&&(n=t.tracks[e]);i&&!g&&(v.numberOfTracks++,g=new a(i),m.pipe(g).pipe(v)),n&&!y&&(v.numberOfTracks++,y=new r(n),p.pipe(y).pipe(v),g&&g.on("keyframe",y.onVideoKeyFrame))}}),this.push=function(t){e.push(t)},this.flush=function(){e.flush()},this.resetCaptions=function(){b.reset()},v.on("data",function(t){T.trigger("data",t)}),v.on("done",function(){T.trigger("done")})},n.prototype=new d,e.exports=n},{}],13:[function(t,e,i){"use strict";var n={codecs:t(5),mp4:t(21),flv:t(10),mp2t:t(15)};n.mp4.tools=t(26),n.flv.tools=t(25),n.mp2t.tools=t(27),e.exports=n},{}],14:[function(t,e,i){"use strict";var n=t(30),a=function(t){for(var e=0,i={payloadType:-1,payloadSize:0},n=0,a=0;e>>8,a=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(n,a))n=(3&n)<<8,r=d(n|a),this[this.mode_](t.pts,r),this.column_++;else if(this.isExtCharacter(n,a))"popOn"===this.mode_?this.nonDisplayed_[this.row_]=this.nonDisplayed_[this.row_].slice(0,-1):this.displayed_[14]=this.displayed_[14].slice(0,-1),n=(3&n)<<8,r=d(n|a),this[this.mode_](t.pts,r),this.column_++;else if(this.isMidRowCode(n,a))this.clearFormatting(t.pts),this[this.mode_](t.pts," "),this.column_++,14==(14&a)&&this.addFormatting(t.pts,["i"]),1==(1&a)&&this.addFormatting(t.pts,["u"]);else if(this.isOffsetControlCode(n,a))this.column_+=3&a;else if(this.isPAC(n,a)){var s=p.indexOf(7968&e);s!==this.row_&&(this.clearFormatting(t.pts),this.row_=s),1&a&&-1===this.formatting_.indexOf("u")&&this.addFormatting(t.pts,["u"]),16==(16&e)&&(this.column_=4*((14&e)>>1)),this.isColorPAC(a)&&14==(14&a)&&this.addFormatting(t.pts,["i"])}else this.isNormalChar(n)&&(0===a&&(a=null),r=d(n),r+=d(a),this[this.mode_](t.pts,r),this.column_+=r.length)}};c.prototype=new n,c.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_})},c.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_=[]},c.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_},c.prototype.isSpecialCharacter=function(t,e){return t===this.EXT_&&e>=48&&e<=63},c.prototype.isExtCharacter=function(t,e){return(t===this.EXT_+1||t===this.EXT_+2)&&e>=32&&e<=63},c.prototype.isMidRowCode=function(t,e){return t===this.EXT_&&e>=32&&e<=47},c.prototype.isOffsetControlCode=function(t,e){return t===this.OFFSET_&&e>=33&&e<=35},c.prototype.isPAC=function(t,e){return t>=this.BASE_&&t=64&&e<=127},c.prototype.isColorPAC=function(t){return t>=64&&t<=79||t>=96&&t<=127},c.prototype.isNormalChar=function(t){return t>=32&&t<=127},c.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)},c.prototype.clearFormatting=function(t){if(this.formatting_.length){var e=this.formatting_.reverse().reduce(function(t,e){return t+""},"");this.formatting_=[],this[this.mode_](t,e)}},c.prototype.popOn=function(t,e){var i=this.nonDisplayed_[this.row_];i+=e,this.nonDisplayed_[this.row_]=i},c.prototype.rollUp=function(t,e){var i=this.displayed_[14];i+=e,this.displayed_[14]=i},c.prototype.shiftRowsUp_=function(){var t;for(t=0;t>>4>1&&(n+=e[n]+1),0===i.pid)i.type="pat",t(e.subarray(n),i),this.trigger("data",i);else if(i.pid===this.pmtPid)for(i.type="pmt",t(e.subarray(n),i),this.trigger("data",i);this.packetsWaitingForPmt.length;)this.processPes_.apply(this,this.packetsWaitingForPmt.shift());else void 0===this.programMapTable?this.packetsWaitingForPmt.push([e,n,i]):this.processPes_(e,n,i)},this.processPes_=function(t,e,i){i.pid===this.programMapTable.video?i.streamType=h.H264_STREAM_TYPE:i.pid===this.programMapTable.audio?i.streamType=h.ADTS_STREAM_TYPE:i.streamType=this.programMapTable["timed-metadata"][i.pid],i.type="pes",i.data=t.subarray(e),this.trigger("data",i)}},a.prototype=new s,a.STREAM_TYPES={h264:27,adts:15},r=function(){var t=this,e={data:[],size:0},i={data:[],size:0},n={data:[],size:0},a=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,n){var r,s=new Uint8Array(e.size),o={type:i},h=0,d=0,p=!1;if(e.data.length&&!(e.size<9)){for(o.trackId=e.data[0].pid,h=0;h>>2;f*=4,f+=3&l[7],h.timeStamp=f,void 0===e.pts&&void 0===e.dts&&(e.pts=h.timeStamp,e.dts=h.timeStamp),this.trigger("timestamp",h)}e.frames.push(h),n+=10,n+=r}while(n>>4>1&&(e+=t[4]+1),e},o=function(t,e){var i=a(t);return 0===i?"pat":i===e?"pmt":e?"pes":null},h=function(t){var e=r(t),i=4+s(t);return e&&(i+=t[i]+1),(31&t[i+10])<<8|t[i+11]},d=function(t){var e={},i=r(t),n=4+s(t);if(i&&(n+=t[n]+1),1&t[n+5]){var a,o,h;a=(15&t[n+1])<<8|t[n+2],o=3+a-4,h=(15&t[n+10])<<8|t[n+11];for(var d=12+h;d=t.byteLength)return null;var i,n=null;return i=t[e+7],192&i&&(n={},n.pts=(14&t[e+9])<<27|(255&t[e+10])<<20|(254&t[e+11])<<12|(255&t[e+12])<<5|(254&t[e+13])>>>3,n.pts*=4,n.pts+=(6&t[e+13])>>>1,n.dts=n.pts,64&i&&(n.dts=(14&t[e+14])<<27|(255&t[e+15])<<20|(254&t[e+16])<<12|(255&t[e+17])<<5|(254&t[e+18])>>>3,n.dts*=4,n.dts+=(6&t[e+18])>>>1)),n},c=function(t){switch(t){case 5:return"slice_layer_without_partitioning_rbsp_idr";case 6:return"sei_rbsp";case 7:return"seq_parameter_set_rbsp";case 8:return"pic_parameter_set_rbsp";case 9:return"access_unit_delimiter_rbsp";default:return null}},l=function(t){for(var e,i=4+s(t),n=t.subarray(i),a=0,r=0,o=!1;r3&&"slice_layer_without_partitioning_rbsp_idr"===(e=c(31&n[r+3]))&&(o=!0),o};e.exports={parseType:o,parsePat:h,parsePmt:d,parsePayloadUnitStartIndicator:r,parsePesType:p,parsePesTime:u,videoPacketContainsKeyFrame:l}},{}],19:[function(t,e,i){"use strict";e.exports={H264_STREAM_TYPE:27,ADTS_STREAM_TYPE:15,METADATA_STREAM_TYPE:21}},{}],20:[function(t,e,i){"use strict";var n=t(30),a=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=a(t.dts,i),t.pts=a(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 n,e.exports={TimestampRolloverStream:r,handleRollover:a}},{}],21:[function(t,e,i){e.exports={generator:t(22),Transmuxer:t(24).Transmuxer,AudioSegmentStream:t(24).AudioSegmentStream,VideoSegmentStream:t(24).VideoSegmentStream}},{}],22:[function(t,e,i){"use strict";var n,a,r,s,o,h,d,p,u,c,l,f,m,g,y,b,v,T,S,_,w,A,U,k,D,C,L,M,x,P,E,O,I,R,B,F,z=Math.pow(2,32)-1;!function(){var t;if(U={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 U)U.hasOwnProperty(t)&&(U[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]);k=new Uint8Array(["i".charCodeAt(0),"s".charCodeAt(0),"o".charCodeAt(0),"m".charCodeAt(0)]),C=new Uint8Array(["a".charCodeAt(0),"v".charCodeAt(0),"c".charCodeAt(0),"1".charCodeAt(0)]),D=new Uint8Array([0,0,0,1]),L=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]),M=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:L,audio:M},O=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),E=new Uint8Array([0,0,0,0,0,0,0,0]),I=new Uint8Array([0,0,0,0,0,0,0,0]),R=I,B=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),F=I,P=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])}}(),n=function(t){var e,i,n,a=[],r=0;for(e=1;e>>1,t.samplingfrequencyindex<<7|t.channelcount<<3,6,1,2]))},s=function(){return n(U.ftyp,k,D,k,C)},b=function(t){return n(U.hdlr,x[t])},o=function(t){return n(U.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),n(U.mdhd,e)},g=function(t){return n(U.mdia,y(t),b(t.type),d(t))},h=function(t){return n(U.mfhd,new Uint8Array([0,0,0,0,(4278190080&t)>>24,(16711680&t)>>16,(65280&t)>>8,255&t]))},d=function(t){return n(U.minf,"video"===t.type?n(U.vmhd,P):n(U.smhd,E),a(),T(t))},p=function(t,e){for(var i=[],a=e.length;a--;)i[a]=_(e[a]);return n.apply(null,[U.moof,h(t)].concat(i))},u=function(t){for(var e=t.length,i=[];e--;)i[e]=f(t[e]);return n.apply(null,[U.moov,l(4294967295)].concat(i).concat(c(t)))},c=function(t){for(var e=t.length,i=[];e--;)i[e]=w(t[e]);return n.apply(null,[U.mvex].concat(i))},l=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 n(U.mvhd,e)},v=function(t){var e,i,a=t.samples||[],r=new Uint8Array(4+a.length);for(i=0;i>>8),r.push(255&i[e].byteLength),r=r.concat(Array.prototype.slice.call(i[e]));for(e=0;e>>8),s.push(255&a[e].byteLength),s=s.concat(Array.prototype.slice.call(a[e]));return n(U.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]),n(U.avcC,new Uint8Array([1,t.profileIdc,t.profileCompatibility,t.levelIdc,255].concat([i.length]).concat(r).concat([a.length]).concat(s))),n(U.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])))},e=function(t){return n(U.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))}}(),m=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 n(U.tkhd,e)},_=function(t){var e,i,a,r,s,o,h;return e=n(U.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/(z+1)),h=Math.floor(t.baseMediaDecodeTime%(z+1)),i=n(U.tfdt,new Uint8Array([1,0,0,0,o>>>24&255,o>>>16&255,o>>>8&255,255&o,h>>>24&255,h>>>16&255,h>>>8&255,255&h])),s=92,"audio"===t.type?(a=A(t,s),n(U.traf,e,i,a)):(r=v(t),a=A(t,r.length+s),n(U.traf,e,i,a,r))},f=function(t){return t.duration=t.duration||4294967295,n(U.trak,m(t),g(t))},w=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),n(U.trex,e)},function(){var t,e,i;i=function(t,e){var i=0,n=0,a=0,r=0;return t.length&&(void 0!==t[0].duration&&(i=1),void 0!==t[0].size&&(n=2),void 0!==t[0].flags&&(a=4),void 0!==t[0].compositionTimeOffset&&(r=8)),[0,0,i|n|a|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 a,r,s,o;for(r=t.samples||[],e+=20+16*r.length,a=i(r,e),o=0;o>>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 n(U.trun,new Uint8Array(a))},t=function(t,e){var a,r,s,o;for(r=t.samples||[],e+=20+8*r.length,a=i(r,e),o=0;o>>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 n(U.trun,new Uint8Array(a))},A=function(i,n){return"audio"===i.type?t(i,n):e(i,n)}}(),e.exports={ftyp:s,mdat:o,moof:p,moov:u,initSegment:function(t){var e,i=s(),n=u(t);return e=new Uint8Array(i.byteLength+n.byteLength),e.set(i),e.set(n,i.byteLength),e}}},{}],23:[function(t,e,i){"use strict";var n,a,r,s;n=function(t,e){var i,r,s,o,h,d=[];if(!e.length)return null;for(i=0;i1?i+r:t.byteLength,s===e[0]&&(1===e.length?d.push(t.subarray(i+8,o)):(h=n(t.subarray(i+8,o),e.slice(1)),h.length&&(d=d.concat(h)))),i=o;return d},a=function(t){var e="";return e+=String.fromCharCode(t[0]),e+=String.fromCharCode(t[1]),e+=String.fromCharCode(t[2]),e+=String.fromCharCode(t[3])},r=function(t){var e={};return n(t,["moov","trak"]).reduce(function(t,e){var i,a,r,s,o;return(i=n(e,["tkhd"])[0])?(a=i[0],r=0===a?12:20,s=i[r]<<24|i[r+1]<<16|i[r+2]<<8|i[r+3],(o=n(e,["mdia","mdhd"])[0])?(a=o[0],r=0===a?12:20,t[s]=o[r]<<24|o[r+1]<<16|o[r+2]<<8|o[r+3],t):null):null},e)},s=function(t,e){var i,a,r;return i=n(e,["moof","traf"]),a=[].concat.apply([],i.map(function(e){return n(e,["tfhd"]).map(function(i){var a,r,s;return a=i[4]<<24|i[5]<<16|i[6]<<8|i[7],r=t[a]||9e4,s=n(e,["tfdt"]).map(function(t){var e,i;return e=t[0],i=t[4]<<24|t[5]<<16|t[6]<<8|t[7],1===e&&(i*=Math.pow(2,32),i+=t[8]<<24|t[9]<<16|t[10]<<8|t[11]),i})[0],(s=s||1/0)/r})})),r=Math.min.apply(null,a),isFinite(r)?r:0},e.exports={parseType:a,timescale:r,startTime:s}},{}],24:[function(t,e,i){"use strict";var n,a,r,s,o,h,d,p,u,c,l,f=t(30),m=t(22),g=t(16),y=t(3),b=t(4).H264Stream,v=t(1),T=t(6),S=t(28),_=["audioobjecttype","channelcount","samplerate","samplingfrequencyindex","samplesize"],w=["width","height","profileIdc","levelIdc","profileCompatibility"];o=function(){return{size:0,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0,degradationPriority:0}}},h=function(t){return t[0]==="I".charCodeAt(0)&&t[1]==="D".charCodeAt(0)&&t[2]==="3".charCodeAt(0)},c=function(t,e){var i;if(t.length!==e.length)return!1;for(i=0;i45e3))){for(n=T[t.samplerate],n||(n=e[0].data),a=0;a=n?e:(t.minSegmentDts=1/0,e.filter(function(e){return e.dts>=n&&(t.minSegmentDts=Math.min(t.minSegmentDts,e.dts),t.minSegmentPts=t.minSegmentDts,!0)}))},this.generateSampleTable_=function(t){var e,i,n=[];for(e=0;e=-1e4&&i<=45e3&&(!n||o>i)&&(n=r,o=i));return n?n.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,n=[],a=[];for(n.byteLength=0,e=0;en.pts?e++:(i++,r-=a.byteLength,s-=a.nalCount,o-=a.duration);return 0===i?t:i===t.length?null:(d=t.slice(i),d.byteLength=r,d.duration=o,d.nalCount=s,d.pts=d[0].pts,d.dts=d[0].dts,d)},this.alignGopsAtEnd_=function(t){var e,i,n,a,r,s;for(e=h.length-1,i=t.length-1,r=null,s=!1;e>=0&&i>=0;){if(n=h[e],a=t[i],n.pts===a.pts){s=!0;break}n.pts>a.pts?e--:(e===h.length-1&&(r=i),i--)}if(!s&&null===r)return null;var o;if(0===(o=s?i:r))return t;var d=t.slice(o),p=d.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 d.byteLength=p.byteLength,d.duration=p.duration,d.nalCount=p.nalCount,d.pts=d[0].pts,d.dts=d[0].dts,d},this.alignGopsWith=function(t){h=t}},n.prototype=new f,d=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,n=t.minSegmentDts-t.timelineStartInfo.dts;return e=t.timelineStartInfo.baseMediaDecodeTime,e+=n,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 f,s.prototype.flush=function(t){var e,i,n,a,r=0,s={captions:[],captionStreams:{},metadata:[],info:{}},o=0;if(this.pendingTracks.length=this.numberOfTracks&&(this.trigger("done"),this.emittedTracks=0))}for(this.videoTrack?(o=this.videoTrack.timelineStartInfo.pts,w.forEach(function(t){s.info[t]=this.videoTrack[t]},this)):this.audioTrack&&(o=this.audioTrack.timelineStartInfo.pts,_.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,n=m.initSegment(this.pendingTracks),s.initSegment=new Uint8Array(n.byteLength),s.initSegment.set(n),s.data=new Uint8Array(this.pendingBytes),a=0;a=this.numberOfTracks&&(this.trigger("done"),this.emittedTracks=0)},r=function(t){var e,i,o=this,d=!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 v,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 a(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 b,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 h;if("metadata"===s.type){for(h=s.tracks.length;h--;)e||"video"!==s.tracks[h].type?i||"audio"!==s.tracks[h].type||(i=s.tracks[h],i.timelineStartInfo.baseMediaDecodeTime=o.baseMediaDecodeTime):(e=s.tracks[h],e.timelineStartInfo.baseMediaDecodeTime=o.baseMediaDecodeTime);e&&!r.videoSegmentStream&&(r.coalesceStream.numberOfTracks++,r.videoSegmentStream=new n(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 a(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 n=this.transmuxPipeline_;this.baseMediaDecodeTime=t,i&&(i.timelineStartInfo.dts=void 0,i.timelineStartInfo.pts=void 0,p(i),i.timelineStartInfo.baseMediaDecodeTime=t,n.audioTimestampRolloverStream&&n.audioTimestampRolloverStream.discontinuity()),e&&(n.videoSegmentStream&&(n.videoSegmentStream.gopCache_=[],n.videoTimestampRolloverStream.discontinuity()),e.timelineStartInfo.dts=void 0,e.timelineStartInfo.pts=void 0,p(e),n.captionStream.reset(),e.timelineStartInfo.baseMediaDecodeTime=t),n.timedMetadataTimestampRolloverStream&&n.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(d){var e=h(t);e&&"aac"!==this.transmuxPipeline_.type?this.setupAacPipeline():e||"ts"===this.transmuxPipeline_.type||this.setupTsPipeline(),d=!1}this.transmuxPipeline_.headOfPipeline.push(t)},this.flush=function(){d=!0,this.transmuxPipeline_.headOfPipeline.flush()},this.resetCaptions=function(){this.transmuxPipeline_.captionStream&&this.transmuxPipeline_.captionStream.reset()}},r.prototype=new f,e.exports={Transmuxer:r,VideoSegmentStream:n,AudioSegmentStream:a,AUDIO_PROPERTIES:_,VIDEO_PROPERTIES:w}},{}],25:[function(t,e,i){"use strict";var n={8:"audio",9:"video",18:"metadata"},a=function(t){return"0x"+("00"+t.toString(16)).slice(-2).toUpperCase()},r=function(t){for(var e,i=[];t.byteLength>0;)e=0,i.push(a(t[e++])),t=t.subarray(e);return i.join(" ")},s=function(t,e){var i=["AVC Sequence Header","AVC NALU","AVC End-of-Sequence"],n=t[1]&parseInt("01111111",2)<<16|t[2]<<8|t[3];return e=e||{},e.avcPacketType=i[t[0]],e.CompositionTime=t[1]&parseInt("10000000",2)?-n:n,1===t[0]?e.nalUnitTypeRaw=r(t.subarray(4,100)):e.data=r(t.subarray(4)),e},o=function(t,e){var i=["Unknown","Keyframe (for AVC, a seekable frame)","Inter frame (for AVC, a nonseekable frame)","Disposable inter frame (H.263 only)","Generated keyframe (reserved for server use only)","Video info/command frame"],n=t[0]&parseInt("00001111",2);return e=e||{},e.frameType=i[(t[0]&parseInt("11110000",2))>>>4],e.codecID=n,7===n?s(t.subarray(1),e):e},h=function(t,e){var i=["AAC Sequence Header","AAC Raw"];return e=e||{},e.aacPacketType=i[t[0]],e.data=r(t.subarray(1)),e},d=function(t,e){var i=["Linear PCM, platform endian","ADPCM","MP3","Linear PCM, little endian","Nellymoser 16-kHz mono","Nellymoser 8-kHz mono","Nellymoser","G.711 A-law logarithmic PCM","G.711 mu-law logarithmic PCM","reserved","AAC","Speex","MP3 8-Khz","Device-specific sound"],n=["5.5-kHz","11-kHz","22-kHz","44-kHz"],a=(t[0]&parseInt("11110000",2))>>>4;return e=e||{},e.soundFormat=i[a],e.soundRate=n[(t[0]&parseInt("00001100",2))>>>2],e.soundSize=(t[0]&parseInt("00000010",2))>>>1?"16-bit":"8-bit",e.soundType=t[0]&parseInt("00000001",2)?"Stereo":"Mono",10===a?h(t.subarray(1),e):e},p=function(t){return{tagType:n[t[0]],dataSize:t[1]<<16|t[2]<<8|t[3],timestamp:t[7]<<24|t[4]<<16|t[5]<<8|t[6],streamID:t[8]<<16|t[9]<<8|t[10]}},u=function(t){var e=p(t);switch(t[0]){case 8:d(t.subarray(11),e);break;case 9:o(t.subarray(11),e)}return e},c=function(t){var e,i,n=9,a=[];for(n+=4;n>>2,dependsOn:3&t[0],isDependedOn:(192&t[1])>>>6,hasRedundancy:(48&t[1])>>>4,paddingValue:(14&t[1])>>>1,isNonSyncSample:1&t[1],degradationPriority:t[2]<<8|t[3]}},h=function(t){var e,i,n=new DataView(t.buffer,t.byteOffset,t.byteLength),a=[];for(e=0;e+4MALFORMED DATA");else switch(31&t[e]){case 1:a.push("slice_layer_without_partitioning_rbsp");break;case 5:a.push("slice_layer_without_partitioning_rbsp_idr");break;case 6:a.push("sei_rbsp");break;case 7:a.push("seq_parameter_set_rbsp");break;case 8:a.push("pic_parameter_set_rbsp");break;case 9:a.push("access_unit_delimiter_rbsp");break;default:a.push("UNKNOWN NAL - "+t[e]&31)}return a},d={avc1:function(t){var e=new DataView(t.buffer,t.byteOffset,t.byteLength);return{dataReferenceIndex:e.getUint16(6),width:e.getUint16(24),height:e.getUint16(26),horizresolution:e.getUint16(28)+e.getUint16(30)/16,vertresolution:e.getUint16(32)+e.getUint16(34)/16,frameCount:e.getUint16(40),depth:e.getUint16(74),config:n(t.subarray(78,t.byteLength))}},avcC:function(t){var e,i,n,a,r=new DataView(t.buffer,t.byteOffset,t.byteLength),s={configurationVersion:t[0],avcProfileIndication:t[1],profileCompatibility:t[2],avcLevelIndication:t[3],lengthSizeMinusOne:3&t[4],sps:[],pps:[]},o=31&t[5];for(n=6,a=0;a>>2&63,bufferSize:t[13]<<16|t[14]<<8|t[15],maxBitrate:t[16]<<24|t[17]<<16|t[18]<<8|t[19],avgBitrate:t[20]<<24|t[21]<<16|t[22]<<8|t[23],decoderConfigDescriptor:{tag:t[24],length:t[25],audioObjectType:t[26]>>>3&31,samplingFrequencyIndex:(7&t[26])<<1|t[27]>>>7&1,channelConfiguration:t[27]>>>3&15}}}},ftyp:function(t){for(var e=new DataView(t.buffer,t.byteOffset,t.byteLength),i={majorBrand:r(t.subarray(0,4)),minorVersion:e.getUint32(4),compatibleBrands:[]},n=8;n>10)),a.language+=String.fromCharCode(96+((960&e)>>5)),a.language+=String.fromCharCode(96+(31&e)),a},mdia:function(t){return{boxes:n(t)}},mfhd:function(t){return{version:t[0],flags:new Uint8Array(t.subarray(1,4)),sequenceNumber:t[4]<<24|t[5]<<16|t[6]<<8|t[7]}},minf:function(t){return{boxes:n(t)}},mp4a:function(t){var e=new DataView(t.buffer,t.byteOffset,t.byteLength),i={dataReferenceIndex:e.getUint16(6),channelcount:e.getUint16(16),samplesize:e.getUint16(18),samplerate:e.getUint16(24)+e.getUint16(26)/65536};return t.byteLength>28&&(i.streamDescriptor=n(t.subarray(28))[0]),i},moof:function(t){return{boxes:n(t)}},moov:function(t){return{boxes:n(t)}},mvex:function(t){return{boxes:n(t)}},mvhd:function(t){var e=new DataView(t.buffer,t.byteOffset,t.byteLength),i=4,n={version:e.getUint8(0),flags:new Uint8Array(t.subarray(1,4))};return 1===n.version?(i+=4,n.creationTime=s(e.getUint32(i)),i+=8,n.modificationTime=s(e.getUint32(i)),i+=4,n.timescale=e.getUint32(i),i+=8,n.duration=e.getUint32(i)):(n.creationTime=s(e.getUint32(i)),i+=4,n.modificationTime=s(e.getUint32(i)),i+=4,n.timescale=e.getUint32(i),i+=4,n.duration=e.getUint32(i)),i+=4,n.rate=e.getUint16(i)+e.getUint16(i+2)/16,i+=4,n.volume=e.getUint8(i)+e.getUint8(i+1)/8,i+=2,i+=2,i+=8,n.matrix=new Uint32Array(t.subarray(i,i+36)),i+=36,i+=24,n.nextTrackId=e.getUint32(i),n},pdin:function(t){var e=new DataView(t.buffer,t.byteOffset,t.byteLength);return{version:e.getUint8(0),flags:new Uint8Array(t.subarray(1,4)),rate:e.getUint32(4),initialDelay:e.getUint32(8)}},sdtp:function(t){var e,i={version:t[0],flags:new Uint8Array(t.subarray(1,4)),samples:[]};for(e=4;e>4,isDependedOn:(12&t[e])>>2,hasRedundancy:3&t[e]});return i},sidx:function(t){var e,i=new DataView(t.buffer,t.byteOffset,t.byteLength),n={version:t[0],flags:new Uint8Array(t.subarray(1,4)),references:[],referenceId:i.getUint32(4),timescale:i.getUint32(8),earliestPresentationTime:i.getUint32(12),firstOffset:i.getUint32(16)},a=i.getUint16(22);for(e=24;a;e+=12,a--)n.references.push({referenceType:(128&t[e])>>>7,referencedSize:2147483647&i.getUint32(e),subsegmentDuration:i.getUint32(e+4),startsWithSap:!!(128&t[e+8]),sapType:(112&t[e+8])>>>4,sapDeltaTime:268435455&i.getUint32(e+8)});return n},smhd:function(t){return{version:t[0],flags:new Uint8Array(t.subarray(1,4)),balance:t[4]+t[5]/256}},stbl:function(t){return{boxes:n(t)}},stco:function(t){var e,i=new DataView(t.buffer,t.byteOffset,t.byteLength),n={version:t[0],flags:new Uint8Array(t.subarray(1,4)),chunkOffsets:[]},a=i.getUint32(4);for(e=8;a;e+=4,a--)n.chunkOffsets.push(i.getUint32(e));return n},stsc:function(t){var e,i=new DataView(t.buffer,t.byteOffset,t.byteLength),n=i.getUint32(4),a={version:t[0],flags:new Uint8Array(t.subarray(1,4)),sampleToChunks:[]};for(e=8;n;e+=12,n--)a.sampleToChunks.push({firstChunk:i.getUint32(e),samplesPerChunk:i.getUint32(e+4),sampleDescriptionIndex:i.getUint32(e+8)});return a},stsd:function(t){return{version:t[0],flags:new Uint8Array(t.subarray(1,4)),sampleDescriptions:n(t.subarray(8))}},stsz:function(t){var e,i=new DataView(t.buffer,t.byteOffset,t.byteLength),n={version:t[0],flags:new Uint8Array(t.subarray(1,4)),sampleSize:i.getUint32(4),entries:[]};for(e=12;e>6,sampleHasRedundancy:(48&t[21])>>4,samplePaddingValue:(14&t[21])>>1,sampleIsDifferenceSample:!!(1&t[21]),sampleDegradationPriority:e.getUint16(22)}},trun:function(t){var e,i={version:t[0],flags:new Uint8Array(t.subarray(1,4)),samples:[]},n=new DataView(t.buffer,t.byteOffset,t.byteLength),a=1&i.flags[2],r=4&i.flags[2],s=1&i.flags[1],h=2&i.flags[1],d=4&i.flags[1],p=8&i.flags[1],u=n.getUint32(4),c=8;for(a&&(i.dataOffset=n.getUint32(c),c+=4),r&&u&&(e={flags:o(t.subarray(c,c+4))},c+=4,s&&(e.duration=n.getUint32(c),c+=4),h&&(e.size=n.getUint32(c),c+=4),p&&(e.compositionTimeOffset=n.getUint32(c),c+=4),i.samples.push(e),u--);u--;)e={},s&&(e.duration=n.getUint32(c),c+=4),h&&(e.size=n.getUint32(c),c+=4),d&&(e.flags=o(t.subarray(c,c+4)),c+=4),p&&(e.compositionTimeOffset=n.getUint32(c),c+=4),i.samples.push(e);return i},"url ":function(t){return{version:t[0],flags:new Uint8Array(t.subarray(1,4))}},vmhd:function(t){var e=new DataView(t.buffer,t.byteOffset,t.byteLength);return{version:t[0],flags:new Uint8Array(t.subarray(1,4)),graphicsmode:e.getUint16(4),opcolor:new Uint16Array([e.getUint16(6),e.getUint16(8),e.getUint16(10)])}}};n=function(t){for(var e,i,n,a,s,o=0,h=[],p=new ArrayBuffer(t.length),u=new Uint8Array(p),c=0;c1?o+i:t.byteLength,s=(d[n]||function(t){return{data:t}})(t.subarray(o+8,a)),s.size=i,s.type=n,h.push(s),o=a;return h},a=function(t,e){var i;return e=e||0,i=new Array(2*e+1).join(" "),t.map(function(t,n){return i+t.type+"\n"+Object.keys(t).filter(function(t){return"type"!==t&&"boxes"!==t}).map(function(e){var n=i+" "+e+": ",a=t[e];if(a instanceof Uint8Array||a instanceof Uint32Array){var r=Array.prototype.slice.call(new Uint8Array(a.buffer,a.byteOffset,a.byteLength)).map(function(t){return" "+("00"+t.toString(16)).slice(-2)}).join("").match(/.{1,24}/g);return r?1===r.length?n+"<"+r.join("").slice(1)+">":n+"<\n"+r.map(function(t){return i+" "+t}).join("\n")+"\n"+i+" >":n+"<>"}return n+JSON.stringify(a,null,2).split("\n").map(function(t,e){return 0===e?t:i+" "+t}).join("\n")}).join("\n")+(t.boxes?"\n"+a(t.boxes,e+1):"")}).join("\n")},e.exports={inspect:n,textify:a}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],27:[function(t,e,i){"use strict";var n=t(19),a=t(20).handleRollover,r={};r.ts=t(18),r.aac=t(2);var s=function(t){return t[0]==="I".charCodeAt(0)&&t[1]==="D".charCodeAt(0)&&t[2]==="3".charCodeAt(0)},o=function(t,e){for(var i,n=0,a=188;a=0;)if(71!==t[h]||71!==t[d])h--,d--;else{switch(n=t.subarray(h,d),r.ts.parseType(n,e.pid)){case"pes":a=r.ts.parsePesType(n,e.table),s=r.ts.parsePayloadUnitStartIndicator(n),"audio"===a&&s&&(o=r.ts.parsePesTime(n))&&(o.type="audio",i.audio.push(o),p=!0)}if(p)break;h-=188,d-=188}},d=function(t,e,i){for(var n,a,s,o,h,d,p,u=0,c=188,l=!1,f={data:[],size:0};c=0;)if(71!==t[u]||71!==t[c])u--,c--;else{switch(n=t.subarray(u,c),r.ts.parseType(n,e.pid)){case"pes":a=r.ts.parsePesType(n,e.table),s=r.ts.parsePayloadUnitStartIndicator(n),"video"===a&&s&&(o=r.ts.parsePesTime(n))&&(o.type="video",i.video.push(o),l=!0)}if(l)break;u-=188,c-=188}},p=function(t,e){if(t.audio&&t.audio.length){var i=e;void 0===i&&(i=t.audio[0].dts),t.audio.forEach(function(t){t.dts=a(t.dts,i),t.pts=a(t.pts,i),t.dtsTime=t.dts/9e4,t.ptsTime=t.pts/9e4})}if(t.video&&t.video.length){var n=e;if(void 0===n&&(n=t.video[0].dts),t.video.forEach(function(t){t.dts=a(t.dts,n),t.pts=a(t.pts,n),t.dtsTime=t.dts/9e4,t.ptsTime=t.pts/9e4}),t.firstKeyFrame){var r=t.firstKeyFrame;r.dts=a(r.dts,n),r.pts=a(r.pts,n),r.dtsTime=r.dts/9e4,r.ptsTime=r.dts/9e4}}},u=function(t){for(var e,i=!1,n=0,a=null,s=null,o=0,h=0;t.length-h>=3;){switch(r.aac.parseType(t,h)){case"timed-metadata":if(t.length-h<10){i=!0;break}if((o=r.aac.parseId3TagSize(t,h))>t.length){i=!0;break}null===s&&(e=t.subarray(h,h+o),s=r.aac.parseAacTimestamp(e)),h+=o;break;case"audio":if(t.length-h<7){i=!0;break}if((o=r.aac.parseAdtsSize(t,h))>t.length){i=!0;break}null===a&&(e=t.subarray(h,h+o),a=r.aac.parseSampleRate(e)),n++,h+=o;break;default:h++}if(i)return null}if(null===a||null===s)return null;var d=9e4/a;return{audio:[{type:"audio",dts:s,pts:s},{type:"audio",dts:s+1024*n*d,pts:s+1024*n*d}]}},c=function(t){var e={pid:null,table:null},i={};o(t,e);for(var a in e.table)if(e.table.hasOwnProperty(a)){var r=e.table[a];switch(r){case n.H264_STREAM_TYPE:i.video=[],d(t,e,i),0===i.video.length&&delete i.video;break;case n.ADTS_STREAM_TYPE:i.audio=[],h(t,e,i),0===i.audio.length&&delete i.audio}}return i},l=function(t,e){var i,n=s(t);return(i=n?u(t):c(t))&&(i.audio||i.video)?(p(i,e),i):null};e.exports={inspect:l}},{}],28:[function(t,e,i){var n,a,r,s,o,h;n=function(t){return 9e4*t},a=function(t,e){return t*e},r=function(t){return t/9e4},s=function(t,e){return t/e},o=function(t,e){return n(s(t,e))},h=function(t,e){return a(r(t),e)},e.exports={secondsToVideoTs:n,secondsToAudioTs:a,videoTsToSeconds:r,audioTsToSeconds:s,audioTsToVideoTs:o,videoTsToAudioTs:h}},{}],29:[function(t,e,i){"use strict";var n;n=function(t){var e=t.byteLength,i=0,n=0;this.length=function(){return 8*e},this.bitsAvailable=function(){return 8*e+n},this.loadWord=function(){var a=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(a,a+s)),i=new DataView(r.buffer).getUint32(0),n=8*s,e-=s},this.skipBits=function(t){var a;n>t?(i<<=t,n-=t):(t-=n,a=Math.floor(t/8),t-=8*a,e-=a,this.loadWord(),i<<=t,n-=t)},this.readBits=function(t){var a=Math.min(n,t),r=i>>>32-a;return n-=a,n>0?i<<=a:e>0&&this.loadWord(),a=t-a,a>0?r<>>t))return i<<=t,n-=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=n},{}],30:[function(t,e,i){"use strict";var n=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 n;return!!t[e]&&(n=t[e].indexOf(i),t[e]=t[e].slice(),t[e].splice(n,1),n>-1)},this.trigger=function(e){var i,n,a,r;if(i=t[e])if(2===arguments.length)for(a=i.length,n=0;n