(function(t){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=t()}else if(typeof define==="function"&&define.amd){define([],t)}else{var e;if(typeof window!=="undefined"){e=window}else if(typeof global!=="undefined"){e=global}else if(typeof self!=="undefined"){e=self}else{e=this}e.muxjs=t()}})(function(){var t,e,i;return function r(s,o,u){function p(i,t){if(!o[i]){if(!s[i]){var e=typeof require=="function"&&require;if(!t&&e)return e(i,!0);if(d)return d(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var n=o[i]={exports:{}};s[i][0].call(n.exports,function(t){var e=s[i][1][t];return p(e?e:t)},n,n.exports,r,s,o,u)}return o[i].exports}var d=typeof require=="function"&&require;for(var t=0;t<u.length;t++)p(u[t]);return p}({1:[function(t,e,i){"use strict";var a=t("../utils/stream.js");var p=t("./utils");var n;n=function(){var o=new Uint8Array,u=0;n.prototype.init.call(this);this.setTimestamp=function(t){u=t};this.push=function(t){var e=0,i=0,a,n,r,s;if(o.length){s=o.length;o=new Uint8Array(t.byteLength+s);o.set(o.subarray(0,s));o.set(t,s)}else{o=t}while(o.length-i>=3){if(o[i]==="I".charCodeAt(0)&&o[i+1]==="D".charCodeAt(0)&&o[i+2]==="3".charCodeAt(0)){if(o.length-i<10){break}e=p.parseId3TagSize(o,i);if(i+e>o.length){break}n={type:"timed-metadata",data:o.subarray(i,i+e)};this.trigger("data",n);i+=e;continue}else if((o[i]&255)===255&&(o[i+1]&240)===240){if(o.length-i<7){break}e=p.parseAdtsSize(o,i);if(i+e>o.length){break}r={type:"audio",data:o.subarray(i,i+e),pts:u,dts:u};this.trigger("data",r);i+=e;continue}i++}a=o.length-i;if(a>0){o=o.subarray(i)}else{o=new Uint8Array}}};n.prototype=new a;e.exports=n},{"../utils/stream.js":36,"./utils":2}],2:[function(t,e,i){"use strict";var a=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];var n=function(t){if(t[0]==="I".charCodeAt(0)&&t[1]==="D".charCodeAt(0)&&t[2]==="3".charCodeAt(0)){return true}return false};var p=function(t){return t[0]<<21|t[1]<<14|t[2]<<7|t[3]};var r=function(t,e,i){var a,n="";for(a=e;a<i;a++){n+="%"+("00"+t[a].toString(16)).slice(-2)}return n};var d=function(t,e,i){return unescape(r(t,e,i))};var s=function(t,e){var i=t[e+6]<<21|t[e+7]<<14|t[e+8]<<7|t[e+9],a=t[e+5],n=(a&16)>>4;if(n){return i+20}return i+10};var o=function(t,e){var i=(t[e+5]&224)>>5,a=t[e+4]<<3,n=t[e+3]&3<<11;return n|a|i};var u=function(t,e){if(t[e]==="I".charCodeAt(0)&&t[e+1]==="D".charCodeAt(0)&&t[e+2]==="3".charCodeAt(0)){return"timed-metadata"}else if(t[e]&255===255&&(t[e+1]&240)===240){return"audio"}return null};var h=function(t){var e=0;while(e+5<t.length){if(t[e]!==255||(t[e+1]&246)!==240){e++;continue}return a[(t[e+2]&60)>>>2]}return null};var f=function(t){var e,i,a,n;e=10;if(t[5]&64){e+=4;e+=p(t.subarray(10,14))}do{i=p(t.subarray(e+4,e+8));if(i<1){return null}n=String.fromCharCode(t[e],t[e+1],t[e+2],t[e+3]);if(n==="PRIV"){a=t.subarray(e+10,e+i+10);for(var r=0;r<a.byteLength;r++){if(a[r]===0){var s=d(a,0,r);if(s==="com.apple.streaming.transportStreamTimestamp"){var o=a.subarray(r+1);var u=(o[3]&1)<<30|o[4]<<22|o[5]<<14|o[6]<<6|o[7]>>>2;u*=4;u+=o[7]&3;return u}break}}}e+=10;e+=i}while(e<t.byteLength);return null};e.exports={isLikelyAacData:n,parseId3TagSize:s,parseAdtsSize:o,parseType:u,parseSampleRate:h,parseAacTimestamp:f}},{}],3:[function(t,e,i){"use strict";var a=t("../utils/stream.js");var n;var d=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];n=function(){var p;n.prototype.init.call(this);this.push=function(t){var e=0,i=0,a,n,r,s,o,u;if(t.type!=="audio"){return}if(p){s=p;p=new Uint8Array(s.byteLength+t.data.byteLength);p.set(s);p.set(t.data,s.byteLength)}else{p=t.data}while(e+5<p.length){if(p[e]!==255||(p[e+1]&246)!==240){e++;continue}n=(~p[e+1]&1)*2;a=(p[e+3]&3)<<11|p[e+4]<<3|(p[e+5]&224)>>5;o=((p[e+6]&3)+1)*1024;u=o*9e4/d[(p[e+2]&60)>>>2];r=e+a;if(p.byteLength<r){return}this.trigger("data",{pts:t.pts+i*u,dts:t.dts+i*u,sampleCount:o,audioobjecttype:(p[e+2]>>>6&3)+1,channelcount:(p[e+2]&1)<<2|(p[e+3]&192)>>>6,samplerate:d[(p[e+2]&60)>>>2],samplingfrequencyindex:(p[e+2]&60)>>>2,samplesize:16,data:p.subarray(e+7+n,r)});if(p.byteLength===r){p=undefined;return}i++;p=p.subarray(r)}};this.flush=function(){this.trigger("done")}};n.prototype=new a;e.exports=n},{"../utils/stream.js":36}],4:[function(t,e,i){"use strict";var a=t("../utils/stream.js");var S=t("../utils/exp-golomb.js");var u,p;var _;p=function(){var i=0,a,n;p.prototype.init.call(this);this.push=function(t){var e;if(!n){n=t.data}else{e=new Uint8Array(n.byteLength+t.data.byteLength);e.set(n);e.set(t.data,n.byteLength);n=e}for(;i<n.byteLength-3;i++){if(n[i+2]===1){a=i+5;break}}while(a<n.byteLength){switch(n[a]){case 0:if(n[a-1]!==0){a+=2;break}else if(n[a-2]!==0){a++;break}if(i+3!==a-2){this.trigger("data",n.subarray(i+3,a-2))}do{a++}while(n[a]!==1&&a<n.length);i=a-2;a+=3;break;case 1:if(n[a-1]!==0||n[a-2]!==0){a+=3;break}this.trigger("data",n.subarray(i+3,a-2));i=a-2;a+=3;break;default:a+=3;break}}n=n.subarray(i);a-=i;i=0};this.flush=function(){if(n&&n.byteLength>3){this.trigger("data",n.subarray(i+3))}n=null;i=0;this.trigger("done")}};p.prototype=new a;_={100:true,110:true,122:true,244:true,44:true,83:true,86:true,118:true,128:true,138:true,139:true,134:true};u=function(){var e=new p,i,a,n,r,s,o,T;u.prototype.init.call(this);i=this;this.push=function(t){if(t.type!=="video"){return}a=t.trackId;n=t.pts;r=t.dts;e.push(t)};e.on("data",function(t){var e={trackId:a,pts:n,dts:r,data:t};switch(t[0]&31){case 5:e.nalUnitType="slice_layer_without_partitioning_rbsp_idr";break;case 6:e.nalUnitType="sei_rbsp";e.escapedRBSP=s(t.subarray(1));break;case 7:e.nalUnitType="seq_parameter_set_rbsp";e.escapedRBSP=s(t.subarray(1));e.config=o(e.escapedRBSP);break;case 8:e.nalUnitType="pic_parameter_set_rbsp";break;case 9:e.nalUnitType="access_unit_delimiter_rbsp";break;default:break}i.trigger("data",e)});e.on("done",function(){i.trigger("done")});this.flush=function(){e.flush()};T=function(t,e){var i=8,a=8,n,r;for(n=0;n<t;n++){if(a!==0){r=e.readExpGolomb();a=(i+r+256)%256}i=a===0?i:a}};s=function(t){var e=t.byteLength,i=[],a=1,n,r;while(a<e-2){if(t[a]===0&&t[a+1]===0&&t[a+2]===3){i.push(a+2);a+=2}else{a++}}if(i.length===0){return t}n=e-i.length;r=new Uint8Array(n);var s=0;for(a=0;a<n;s++,a++){if(s===i[0]){s++;i.shift()}r[a]=t[s]}return r};o=function(t){var e=0,i=0,a=0,n=0,r=1,s,o,u,p,d,h,f,l,c,m,g,y,b,v;s=new S(t);o=s.readUnsignedByte();p=s.readUnsignedByte();u=s.readUnsignedByte();s.skipUnsignedExpGolomb();if(_[o]){d=s.readUnsignedExpGolomb();if(d===3){s.skipBits(1)}s.skipUnsignedExpGolomb();s.skipUnsignedExpGolomb();s.skipBits(1);if(s.readBoolean()){g=d!==3?8:12;for(v=0;v<g;v++){if(s.readBoolean()){if(v<6){T(16,s)}else{T(64,s)}}}}}s.skipUnsignedExpGolomb();h=s.readUnsignedExpGolomb();if(h===0){s.readUnsignedExpGolomb()}else if(h===1){s.skipBits(1);s.skipExpGolomb();s.skipExpGolomb();f=s.readUnsignedExpGolomb();for(v=0;v<f;v++){s.skipExpGolomb()}}s.skipUnsignedExpGolomb();s.skipBits(1);l=s.readUnsignedExpGolomb();c=s.readUnsignedExpGolomb();m=s.readBits(1);if(m===0){s.skipBits(1)}s.skipBits(1);if(s.readBoolean()){e=s.readUnsignedExpGolomb();i=s.readUnsignedExpGolomb();a=s.readUnsignedExpGolomb();n=s.readUnsignedExpGolomb()}if(s.readBoolean()){if(s.readBoolean()){b=s.readUnsignedByte();switch(b){case 1:y=[1,1];break;case 2:y=[12,11];break;case 3:y=[10,11];break;case 4:y=[16,11];break;case 5:y=[40,33];break;case 6:y=[24,11];break;case 7:y=[20,11];break;case 8:y=[32,11];break;case 9:y=[80,33];break;case 10:y=[18,11];break;case 11:y=[15,11];break;case 12:y=[64,33];break;case 13:y=[160,99];break;case 14:y=[4,3];break;case 15:y=[3,2];break;case 16:y=[2,1];break;case 255:{y=[s.readUnsignedByte()<<8|s.readUnsignedByte(),s.readUnsignedByte()<<8|s.readUnsignedByte()];break}}if(y){r=y[0]/y[1]}}}return{profileIdc:o,levelIdc:u,profileCompatibility:p,width:Math.ceil(((l+1)*16-e*2-i*2)*r),height:(2-m)*(c+1)*16-a*2-n*2}}};u.prototype=new a;e.exports={H264Stream:u,NalByteStream:p}},{"../utils/exp-golomb.js":35,"../utils/stream.js":36}],5:[function(t,e,i){e.exports={adts:t("./adts"),h264:t("./h264")}},{"./adts":3,"./h264":4}],6:[function(t,e,i){var a=[33,16,5,32,164,27];var n=[33,65,108,84,1,2,4,8,168,2,4,8,17,191,252];var r=function(t){var e=[];while(t--){e.push(0)}return e};var s=function(i){return Object.keys(i).reduce(function(t,e){t[e]=new Uint8Array(i[e].reduce(function(t,e){return t.concat(e)},[]));return t},{})};var o={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=s(o)},{}],7:[function(t,e,i){"use strict";var a=t("../utils/stream.js");var n=function(t){this.numberOfTracks=0;this.metadataStream=t.metadataStream;this.videoTags=[];this.audioTags=[];this.videoTrack=null;this.audioTrack=null;this.pendingCaptions=[];this.pendingMetadata=[];this.pendingTracks=0;this.processedTracks=0;n.prototype.init.call(this);this.push=function(t){if(t.text){return this.pendingCaptions.push(t)}if(t.frames){return this.pendingMetadata.push(t)}if(t.track.type==="video"){this.videoTrack=t.track;this.videoTags=t.tags;this.pendingTracks++}if(t.track.type==="audio"){this.audioTrack=t.track;this.audioTags=t.tags;this.pendingTracks++}}};n.prototype=new a;n.prototype.flush=function(t){var e,i,a,n,r={tags:{},captions:[],captionStreams:{},metadata:[]};if(this.pendingTracks<this.numberOfTracks){if(t!=="VideoSegmentStream"&&t!=="AudioSegmentStream"){return}else if(this.pendingTracks===0){this.processedTracks++;if(this.processedTracks<this.numberOfTracks){return}}}this.processedTracks+=this.pendingTracks;this.pendingTracks=0;if(this.processedTracks<this.numberOfTracks){return}if(this.videoTrack){n=this.videoTrack.timelineStartInfo.pts}else if(this.audioTrack){n=this.audioTrack.timelineStartInfo.pts}r.tags.videoTags=this.videoTags;r.tags.audioTags=this.audioTags;for(a=0;a<this.pendingCaptions.length;a++){i=this.pendingCaptions[a];i.startTime=i.startPts-n;i.startTime/=9e4;i.endTime=i.endPts-n;i.endTime/=9e4;r.captionStreams[i.stream]=true;r.captions.push(i)}for(a=0;a<this.pendingMetadata.length;a++){e=this.pendingMetadata[a];e.cueTime=e.pts-n;e.cueTime/=9e4;r.metadata.push(e)}r.metadata.dispatchType=this.metadataStream.dispatchType;this.videoTrack=null;this.audioTrack=null;this.videoTags=[];this.audioTags=[];this.pendingCaptions.length=0;this.pendingMetadata.length=0;this.pendingTracks=0;this.processedTracks=0;this.trigger("data",r);this.trigger("done")};e.exports=n},{"../utils/stream.js":36}],8:[function(t,e,i){"use strict";var u=t("./flv-tag.js");var a=function(t,e,i){var a=new Uint8Array(3+1+1+4),n=new DataView(a.buffer),r,s,o;t=t||0;e=e===undefined?true:e;i=i===undefined?true:i;n.setUint8(0,70);n.setUint8(1,76);n.setUint8(2,86);n.setUint8(3,1);n.setUint8(4,(e?4:0)|(i?1:0));n.setUint32(5,a.byteLength);if(t<=0){s=new Uint8Array(a.byteLength+4);s.set(a);s.set([0,0,0,0],a.byteLength);return s}r=new u(u.METADATA_TAG);r.pts=r.dts=0;r.writeMetaDataDouble("duration",t);o=r.finalize().length;s=new Uint8Array(a.byteLength+o);s.set(a);s.set(n.byteLength,o);return s};e.exports=a},{"./flv-tag.js":9}],9:[function(t,e,i){"use strict";var p;p=function(t,i){var a=0,e=16384,r=function(t,e){var i,a=t.position+e;if(a<t.bytes.byteLength){return}i=new Uint8Array(a*2);i.set(t.bytes.subarray(0,t.position),0);t.bytes=i;t.view=new DataView(t.bytes.buffer)},n=p.widthBytes||new Uint8Array("width".length),s=p.heightBytes||new Uint8Array("height".length),o=p.videocodecidBytes||new Uint8Array("videocodecid".length),u;if(!p.widthBytes){for(u=0;u<"width".length;u++){n[u]="width".charCodeAt(u)}for(u=0;u<"height".length;u++){s[u]="height".charCodeAt(u)}for(u=0;u<"videocodecid".length;u++){o[u]="videocodecid".charCodeAt(u)}p.widthBytes=n;p.heightBytes=s;p.videocodecidBytes=o}this.keyFrame=false;switch(t){case p.VIDEO_TAG:this.length=16;e*=6;break;case p.AUDIO_TAG:this.length=13;this.keyFrame=true;break;case p.METADATA_TAG:this.length=29;this.keyFrame=true;break;default:throw new Error("Unknown FLV tag type")}this.bytes=new Uint8Array(e);this.view=new DataView(this.bytes.buffer);this.bytes[0]=t;this.position=this.length;this.keyFrame=i;this.pts=0;this.dts=0;this.writeBytes=function(t,e,i){var a=e||0,n;i=i||t.byteLength;n=a+i;r(this,i);this.bytes.set(t.subarray(a,n),this.position);this.position+=i;this.length=Math.max(this.length,this.position)};this.writeByte=function(t){r(this,1);this.bytes[this.position]=t;this.position++;this.length=Math.max(this.length,this.position)};this.writeShort=function(t){r(this,2);this.view.setUint16(this.position,t);this.position+=2;this.length=Math.max(this.length,this.position)};this.negIndex=function(t){return this.bytes[this.length-t]};this.nalUnitSize=function(){if(a===0){return 0}return this.length-(a+4)};this.startNalUnit=function(){if(a>0){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;if(this.length===a+4){this.length-=4}else if(a>0){e=a+4;i=this.length-e;this.position=a;this.view.setUint32(this.position,i);this.position=this.length;if(t){t.push(this.bytes.subarray(e,e+i))}}a=0};this.writeMetaDataDouble=function(t,e){var i;r(this,2+t.length+9);this.view.setUint16(this.position,t.length);this.position+=2;if(t==="width"){this.bytes.set(n,this.position);this.position+=5}else if(t==="height"){this.bytes.set(s,this.position);this.position+=6}else if(t==="videocodecid"){this.bytes.set(o,this.position);this.position+=12}else{for(i=0;i<t.length;i++){this.bytes[this.position]=t.charCodeAt(i);this.position++}}this.position++;this.view.setFloat64(this.position,e);this.position+=8;this.length=Math.max(this.length,this.position);++a};this.writeMetaDataBoolean=function(t,e){var i;r(this,2);this.view.setUint16(this.position,t.length);this.position+=2;for(i=0;i<t.length;i++){r(this,1);this.bytes[this.position]=t.charCodeAt(i);this.position++}r(this,2);this.view.setUint8(this.position,1);this.position++;this.view.setUint8(this.position,e?1:0);this.position++;this.length=Math.max(this.length,this.position);++a};this.finalize=function(){var t,e;switch(this.bytes[0]){case p.VIDEO_TAG:this.bytes[11]=(this.keyFrame||i?16:32)|7;this.bytes[12]=i?0:1;t=this.pts-this.dts;this.bytes[13]=(t&16711680)>>>16;this.bytes[14]=(t&65280)>>>8;this.bytes[15]=(t&255)>>>0;break;case p.AUDIO_TAG:this.bytes[11]=175;this.bytes[12]=i?0:1;break;case p.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;break}e=this.length-11;this.bytes[1]=(e&16711680)>>>16;this.bytes[2]=(e&65280)>>>8;this.bytes[3]=(e&255)>>>0;this.bytes[4]=(this.dts&16711680)>>>16;this.bytes[5]=(this.dts&65280)>>>8;this.bytes[6]=(this.dts&255)>>>0;this.bytes[7]=(this.dts&4278190080)>>>24;this.bytes[8]=0;this.bytes[9]=0;this.bytes[10]=0;r(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=p.frameTime(this.bytes);return this}};p.AUDIO_TAG=8;p.VIDEO_TAG=9;p.METADATA_TAG=18;p.isAudioFrame=function(t){return p.AUDIO_TAG===t[0]};p.isVideoFrame=function(t){return p.VIDEO_TAG===t[0]};p.isMetaData=function(t){return p.METADATA_TAG===t[0]};p.isKeyFrame=function(t){if(p.isVideoFrame(t)){return t[11]===23}if(p.isAudioFrame(t)){return true}if(p.isMetaData(t)){return true}return false};p.frameTime=function(t){var e=t[4]<<16;e|=t[5]<<8;e|=t[6]<<0;e|=t[7]<<24;return e};e.exports=p},{}],10:[function(t,e,i){e.exports={tag:t("./flv-tag"),Transmuxer:t("./transmuxer"),getFlvHeader:t("./flv-header")}},{"./flv-header":8,"./flv-tag":9,"./transmuxer":12}],11:[function(t,e,i){"use strict";var a=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=a},{}],12:[function(t,e,i){"use strict";var a=t("../utils/stream.js");var u=t("./flv-tag.js");var c=t("../m2ts/m2ts.js");var m=t("../codecs/adts.js");var g=t("../codecs/h264").H264Stream;var y=t("./coalesce-stream.js");var p=t("./tag-list.js");var b,v,T,d,o,h;d=function(t,e){if(typeof e.pts==="number"){if(t.timelineStartInfo.pts===undefined){t.timelineStartInfo.pts=e.pts}else{t.timelineStartInfo.pts=Math.min(t.timelineStartInfo.pts,e.pts)}}if(typeof e.dts==="number"){if(t.timelineStartInfo.dts===undefined){t.timelineStartInfo.dts=e.dts}else{t.timelineStartInfo.dts=Math.min(t.timelineStartInfo.dts,e.dts)}}};o=function(t,e){var i=new u(u.METADATA_TAG);i.dts=e;i.pts=e;i.writeMetaDataDouble("videocodecid",7);i.writeMetaDataDouble("width",t.width);i.writeMetaDataDouble("height",t.height);return i};h=function(t,e){var i,a=new u(u.VIDEO_TAG,true);a.dts=e;a.pts=e;a.writeByte(1);a.writeByte(t.profileIdc);a.writeByte(t.profileCompatibility);a.writeByte(t.levelIdc);a.writeByte(252|3);a.writeByte(224|1);a.writeShort(t.sps[0].length);a.writeBytes(t.sps[0]);a.writeByte(t.pps.length);for(i=0;i<t.pps.length;++i){a.writeShort(t.pps[i].length);a.writeBytes(t.pps[i])}return a};T=function(n){var r=[],s=[],o;T.prototype.init.call(this);this.push=function(t){d(n,t);if(n){n.audioobjecttype=t.audioobjecttype;n.channelcount=t.channelcount;n.samplerate=t.samplerate;n.samplingfrequencyindex=t.samplingfrequencyindex;n.samplesize=t.samplesize;n.extraData=n.audioobjecttype<<11|n.samplingfrequencyindex<<7|n.channelcount<<3}t.pts=Math.round(t.pts/90);t.dts=Math.round(t.dts/90);r.push(t)};this.flush=function(){var t,e,i,a=new p;if(r.length===0){this.trigger("done","AudioSegmentStream");return}i=-Infinity;while(r.length){t=r.shift();if(s.length&&t.pts>=s[0]){i=s.shift();this.writeMetaDataTags(a,i)}if(n.extraData!==o||t.pts-i>=1e3){this.writeMetaDataTags(a,t.pts);o=n.extraData;i=t.pts}e=new u(u.AUDIO_TAG);e.pts=t.pts;e.dts=t.dts;e.writeBytes(t.data);a.push(e.finalize())}s.length=0;o=null;this.trigger("data",{track:n,tags:a.list});this.trigger("done","AudioSegmentStream")};this.writeMetaDataTags=function(t,e){var i;i=new u(u.METADATA_TAG);i.pts=e;i.dts=e;i.writeMetaDataDouble("audiocodecid",10);i.writeMetaDataBoolean("stereo",n.channelcount===2);i.writeMetaDataDouble("audiosamplerate",n.samplerate);i.writeMetaDataDouble("audiosamplesize",16);t.push(i.finalize());i=new u(u.AUDIO_TAG,true);i.pts=e;i.dts=e;i.view.setUint16(i.position,n.extraData);i.position+=2;i.length=Math.max(i.length,i.position);t.push(i.finalize())};this.onVideoKeyFrame=function(t){s.push(t)}};T.prototype=new a;v=function(n){var i=[],r,s;v.prototype.init.call(this);this.finishFrame=function(t,e){if(!e){return}if(r&&n&&n.newMetadata&&(e.keyFrame||t.length===0)){var i=o(r,e.dts).finalize();var a=h(n,e.dts).finalize();i.metaDataTag=a.metaDataTag=true;t.push(i);t.push(a);n.newMetadata=false;this.trigger("keyframe",e.dts)}e.endNalUnit();t.push(e.finalize());s=null};this.push=function(t){d(n,t);t.pts=Math.round(t.pts/90);t.dts=Math.round(t.dts/90);i.push(t)};this.flush=function(){var t,e=new p;while(i.length){if(i[0].nalUnitType==="access_unit_delimiter_rbsp"){break}i.shift()}if(i.length===0){this.trigger("done","VideoSegmentStream");return}while(i.length){t=i.shift();if(t.nalUnitType==="seq_parameter_set_rbsp"){n.newMetadata=true;r=t.config;n.width=r.width;n.height=r.height;n.sps=[t.data];n.profileIdc=r.profileIdc;n.levelIdc=r.levelIdc;n.profileCompatibility=r.profileCompatibility;s.endNalUnit()}else if(t.nalUnitType==="pic_parameter_set_rbsp"){n.newMetadata=true;n.pps=[t.data];s.endNalUnit()}else if(t.nalUnitType==="access_unit_delimiter_rbsp"){if(s){this.finishFrame(e,s)}s=new u(u.VIDEO_TAG);s.pts=t.pts;s.dts=t.dts}else{if(t.nalUnitType==="slice_layer_without_partitioning_rbsp_idr"){s.keyFrame=true}s.endNalUnit()}s.startNalUnit();s.writeBytes(t.data)}if(s){this.finishFrame(e,s)}this.trigger("data",{track:n,tags:e.list});this.trigger("done","VideoSegmentStream")}};v.prototype=new a;b=function(t){var e=this,i,a,n,r,s,o,u,p,d,h,f,l;b.prototype.init.call(this);t=t||{};this.metadataStream=new c.MetadataStream;t.metadataStream=this.metadataStream;i=new c.TransportPacketStream;a=new c.TransportParseStream;n=new c.ElementaryStream;r=new c.TimestampRolloverStream("video");s=new c.TimestampRolloverStream("audio");o=new c.TimestampRolloverStream("timed-metadata");u=new m;p=new g;l=new y(t);i.pipe(a).pipe(n);n.pipe(r).pipe(p);n.pipe(s).pipe(u);n.pipe(o).pipe(this.metadataStream).pipe(l);f=new c.CaptionStream;p.pipe(f).pipe(l);n.on("data",function(t){var e,i,a;if(t.type==="metadata"){e=t.tracks.length;while(e--){if(t.tracks[e].type==="video"){i=t.tracks[e]}else if(t.tracks[e].type==="audio"){a=t.tracks[e]}}if(i&&!d){l.numberOfTracks++;d=new v(i);p.pipe(d).pipe(l)}if(a&&!h){l.numberOfTracks++;h=new T(a);u.pipe(h).pipe(l);if(d){d.on("keyframe",h.onVideoKeyFrame)}}}});this.push=function(t){i.push(t)};this.flush=function(){i.flush()};this.resetCaptions=function(){f.reset()};l.on("data",function(t){e.trigger("data",t)});l.on("done",function(){e.trigger("done")})};b.prototype=new a;e.exports=b},{"../codecs/adts.js":3,"../codecs/h264":4,"../m2ts/m2ts.js":16,"../utils/stream.js":36,"./coalesce-stream.js":7,"./flv-tag.js":9,"./tag-list.js":11}],13:[function(t,e,i){"use strict";var a={codecs:t("./codecs"),mp4:t("./mp4"),flv:t("./flv"),mp2t:t("./m2ts")};a.mp4.tools=t("./tools/mp4-inspector");a.flv.tools=t("./tools/flv-inspector");a.mp2t.tools=t("./tools/ts-inspector");e.exports=a},{"./codecs":5,"./flv":10,"./m2ts":15,"./mp4":24,"./tools/flv-inspector":30,"./tools/mp4-inspector":31,"./tools/ts-inspector":32}],14:[function(t,e,i){"use strict";var a=t("../utils/stream");var n=t("../tools/caption-packet-parser");var r=function(){r.prototype.init.call(this);this.captionPackets_=[];this.ccStreams_=[new h(0,0),new h(0,1),new h(1,0),new h(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)};r.prototype=new a;r.prototype.push=function(t){var e,i,a;if(t.nalUnitType!=="sei_rbsp"){return}e=n.parseSei(t.escapedRBSP);if(e.payloadType!==n.USER_DATA_REGISTERED_ITU_T_T35){return}i=n.parseUserData(e);if(!i){return}if(t.dts<this.latestDts_){this.ignoreNextEqualDts_=true;return}else if(t.dts===this.latestDts_&&this.ignoreNextEqualDts_){this.numSameDts_--;if(!this.numSameDts_){this.ignoreNextEqualDts_=false}return}a=n.parseCaptionPackets(t.pts,i);this.captionPackets_=this.captionPackets_.concat(a);if(this.latestDts_!==t.dts){this.numSameDts_=0}this.numSameDts_++;this.latestDts_=t.dts};r.prototype.flush=function(){if(!this.captionPackets_.length){this.ccStreams_.forEach(function(t){t.flush()},this);return}this.captionPackets_.forEach(function(t,e){t.presortIndex=e});this.captionPackets_.sort(function(t,e){if(t.pts===e.pts){return t.presortIndex-e.presortIndex}return t.pts-e.pts});this.captionPackets_.forEach(function(t){if(t.type<2){this.dispatchCea608Packet(t)}},this);this.captionPackets_.length=0;this.ccStreams_.forEach(function(t){t.flush()},this);return};r.prototype.reset=function(){this.latestDts_=null;this.ignoreNextEqualDts_=false;this.numSameDts_=0;this.activeCea608Channel_=[null,null];this.ccStreams_.forEach(function(t){t.reset()})};r.prototype.dispatchCea608Packet=function(t){if(this.setsTextOrXDSActive(t)){this.activeCea608Channel_[t.type]=null}else if(this.setsChannel1Active(t)){this.activeCea608Channel_[t.type]=0}else if(this.setsChannel2Active(t)){this.activeCea608Channel_[t.type]=1}if(this.activeCea608Channel_[t.type]===null){return}this.ccStreams_[(t.type<<1)+this.activeCea608Channel_[t.type]].push(t)};r.prototype.setsChannel1Active=function(t){return(t.ccData&30720)===4096};r.prototype.setsChannel2Active=function(t){return(t.ccData&30720)===6144};r.prototype.setsTextOrXDSActive=function(t){return(t.ccData&28928)===256||(t.ccData&30974)===4138||(t.ccData&30974)===6186};var s={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};var o=function(t){if(t===null){return""}t=s[t]||t;return String.fromCharCode(t)};var u=14;var p=[4352,4384,4608,4640,5376,5408,5632,5664,5888,5920,4096,4864,4896,5120,5152];var d=function(){var t=[],e=u+1;while(e--){t.push("")}return t};var h=function(t,e){h.prototype.init.call(this);this.field_=t||0;this.dataChannel_=e||0;this.name_="CC"+((this.field_<<1|this.dataChannel_)+1);this.setConstants();this.reset();this.push=function(t){var e,i,a,n,r;e=t.ccData&32639;if(e===this.lastControlCode_){this.lastControlCode_=null;return}if((e&61440)===4096){this.lastControlCode_=e}else if(e!==this.PADDING_){this.lastControlCode_=null}a=e>>>8;n=e&255;if(e===this.PADDING_){return}else if(e===this.RESUME_CAPTION_LOADING_){this.mode_="popOn"}else if(e===this.END_OF_CAPTION_){this.mode_="popOn";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.rollUpRows_=2;this.setRollUp(t.pts)}else if(e===this.ROLL_UP_3_ROWS_){this.rollUpRows_=3;this.setRollUp(t.pts)}else if(e===this.ROLL_UP_4_ROWS_){this.rollUpRows_=4;this.setRollUp(t.pts)}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_){if(this.mode_==="popOn"){this.nonDisplayed_[this.row_]=this.nonDisplayed_[this.row_].slice(0,-1)}else{this.displayed_[this.row_]=this.displayed_[this.row_].slice(0,-1)}}else if(e===this.ERASE_DISPLAYED_MEMORY_){this.flushDisplayed(t.pts);this.displayed_=d()}else if(e===this.ERASE_NON_DISPLAYED_MEMORY_){this.nonDisplayed_=d()}else if(e===this.RESUME_DIRECT_CAPTIONING_){if(this.mode_!=="paintOn"){this.flushDisplayed(t.pts);this.displayed_=d()}this.mode_="paintOn";this.startPts_=t.pts}else if(this.isSpecialCharacter(a,n)){a=(a&3)<<8;r=o(a|n);this[this.mode_](t.pts,r);this.column_++}else if(this.isExtCharacter(a,n)){if(this.mode_==="popOn"){this.nonDisplayed_[this.row_]=this.nonDisplayed_[this.row_].slice(0,-1)}else{this.displayed_[this.row_]=this.displayed_[this.row_].slice(0,-1)}a=(a&3)<<8;r=o(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_++;if((n&14)===14){this.addFormatting(t.pts,["i"])}if((n&1)===1){this.addFormatting(t.pts,["u"])}}else if(this.isOffsetControlCode(a,n)){this.column_+=n&3}else if(this.isPAC(a,n)){var s=p.indexOf(e&7968);if(this.mode_==="rollUp"){if(s-this.rollUpRows_+1<0){s=this.rollUpRows_-1}this.setRollUp(t.pts,s)}if(s!==this.row_){this.clearFormatting(t.pts);this.row_=s}if(n&1&&this.formatting_.indexOf("u")===-1){this.addFormatting(t.pts,["u"])}if((e&16)===16){this.column_=((e&14)>>1)*4}if(this.isColorPAC(n)){if((n&14)===14){this.addFormatting(t.pts,["i"])}}}else if(this.isNormalChar(a)){if(n===0){n=null}r=o(a);r+=o(n);this[this.mode_](t.pts,r);this.column_+=r.length}}};h.prototype=new a;h.prototype.flushDisplayed=function(t){var e=this.displayed_.map(function(t){try{return t.trim()}catch(t){console.error("Skipping malformed caption.");return""}}).join("\n").replace(/^\n+|\n+$/g,"");if(e.length){this.trigger("data",{startPts:this.startPts_,endPts:t,text:e,stream:this.name_})}};h.prototype.reset=function(){this.mode_="popOn";this.topRow_=0;this.startPts_=0;this.displayed_=d();this.nonDisplayed_=d();this.lastControlCode_=null;this.column_=0;this.row_=u;this.rollUpRows_=2;this.formatting_=[]};h.prototype.setConstants=function(){if(this.dataChannel_===0){this.BASE_=16;this.EXT_=17;this.CONTROL_=(20|this.field_)<<8;this.OFFSET_=23}else if(this.dataChannel_===1){this.BASE_=24;this.EXT_=25;this.CONTROL_=(28|this.field_)<<8;this.OFFSET_=31}this.PADDING_=0;this.RESUME_CAPTION_LOADING_=this.CONTROL_|32;this.END_OF_CAPTION_=this.CONTROL_|47;this.ROLL_UP_2_ROWS_=this.CONTROL_|37;this.ROLL_UP_3_ROWS_=this.CONTROL_|38;this.ROLL_UP_4_ROWS_=this.CONTROL_|39;this.CARRIAGE_RETURN_=this.CONTROL_|45;this.RESUME_DIRECT_CAPTIONING_=this.CONTROL_|41;this.BACKSPACE_=this.CONTROL_|33;this.ERASE_DISPLAYED_MEMORY_=this.CONTROL_|44;this.ERASE_NON_DISPLAYED_MEMORY_=this.CONTROL_|46};h.prototype.isSpecialCharacter=function(t,e){return t===this.EXT_&&e>=48&&e<=63};h.prototype.isExtCharacter=function(t,e){return(t===this.EXT_+1||t===this.EXT_+2)&&(e>=32&&e<=63)};h.prototype.isMidRowCode=function(t,e){return t===this.EXT_&&(e>=32&&e<=47)};h.prototype.isOffsetControlCode=function(t,e){return t===this.OFFSET_&&(e>=33&&e<=35)};h.prototype.isPAC=function(t,e){return t>=this.BASE_&&t<this.BASE_+8&&(e>=64&&e<=127)};h.prototype.isColorPAC=function(t){return t>=64&&t<=79||t>=96&&t<=127};h.prototype.isNormalChar=function(t){return t>=32&&t<=127};h.prototype.setRollUp=function(t,e){if(this.mode_!=="rollUp"){this.row_=u;this.mode_="rollUp";this.flushDisplayed(t);this.nonDisplayed_=d();this.displayed_=d()}if(e!==undefined&&e!==this.row_){for(var i=0;i<this.rollUpRows_;i++){this.displayed_[e-i]=this.displayed_[this.row_-i];this.displayed_[this.row_-i]=""}}if(e===undefined){e=this.row_}this.topRow_=e-this.rollUpRows_+1};h.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)};h.prototype.clearFormatting=function(t){if(!this.formatting_.length){return}var e=this.formatting_.reverse().reduce(function(t,e){return t+"</"+e+">"},"");this.formatting_=[];this[this.mode_](t,e)};h.prototype.popOn=function(t,e){var i=this.nonDisplayed_[this.row_];i+=e;this.nonDisplayed_[this.row_]=i};h.prototype.rollUp=function(t,e){var i=this.displayed_[this.row_];i+=e;this.displayed_[this.row_]=i};h.prototype.shiftRowsUp_=function(){var t;for(t=0;t<this.topRow_;t++){this.displayed_[t]=""}for(t=this.row_+1;t<u+1;t++){this.displayed_[t]=""}for(t=this.topRow_;t<this.row_;t++){this.displayed_[t]=this.displayed_[t+1]}this.displayed_[this.row_]=""};h.prototype.paintOn=function(t,e){var i=this.displayed_[this.row_];i+=e;this.displayed_[this.row_]=i};e.exports={CaptionStream:r,Cea608Stream:h}},{"../tools/caption-packet-parser":29,"../utils/stream":36}],15:[function(t,e,i){e.exports=t("./m2ts")},{"./m2ts":16}],16:[function(t,e,i){"use strict";var a=t("../utils/stream.js"),n=t("./caption-stream"),h=t("./stream-types"),r=t("./timestamp-rollover-stream").TimestampRolloverStream;var o=t("./stream-types.js");var s,p,u;var d=188,f=71;s=function(){var n=new Uint8Array(d),r=0;s.prototype.init.call(this);this.push=function(t){var e=0,i=d,a;if(r){a=new Uint8Array(t.byteLength+r);a.set(n.subarray(0,r));a.set(t,r);r=0}else{a=t}while(i<a.byteLength){if(a[e]===f&&a[i]===f){this.trigger("data",a.subarray(e,i));e+=d;i+=d;continue}e++;i++}if(e<a.byteLength){n.set(a.subarray(e),0);r=a.byteLength-e}};this.flush=function(){if(r===d&&n[0]===f){this.trigger("data",n);r=0}this.trigger("done")}};s.prototype=new a;p=function(){var a,n,r,u;p.prototype.init.call(this);u=this;this.packetsWaitingForPmt=[];this.programMapTable=undefined;a=function(t,e){var i=0;if(e.payloadUnitStartIndicator){i+=t[i]+1}if(e.type==="pat"){n(t.subarray(i),e)}else{r(t.subarray(i),e)}};n=function(t,e){e.section_number=t[7];e.last_section_number=t[8];u.pmtPid=(t[10]&31)<<8|t[11];e.pmtPid=u.pmtPid};r=function(t,e){var i,a,n,r;if(!(t[5]&1)){return}u.programMapTable={video:null,audio:null,"timed-metadata":{}};i=(t[1]&15)<<8|t[2];a=3+i-4;n=(t[10]&15)<<8|t[11];r=12+n;while(r<a){var s=t[r];var o=(t[r+1]&31)<<8|t[r+2];if(s===h.H264_STREAM_TYPE&&u.programMapTable.video===null){u.programMapTable.video=o}else if(s===h.ADTS_STREAM_TYPE&&u.programMapTable.audio===null){u.programMapTable.audio=o}else if(s===h.METADATA_STREAM_TYPE){u.programMapTable["timed-metadata"][o]=s}r+=((t[r+3]&15)<<8|t[r+4])+5}e.programMapTable=u.programMapTable};this.push=function(t){var e={},i=4;e.payloadUnitStartIndicator=!!(t[1]&64);e.pid=t[1]&31;e.pid<<=8;e.pid|=t[2];if((t[3]&48)>>>4>1){i+=t[i]+1}if(e.pid===0){e.type="pat";a(t.subarray(i),e);this.trigger("data",e)}else if(e.pid===this.pmtPid){e.type="pmt";a(t.subarray(i),e);this.trigger("data",e);while(this.packetsWaitingForPmt.length){this.processPes_.apply(this,this.packetsWaitingForPmt.shift())}}else if(this.programMapTable===undefined){this.packetsWaitingForPmt.push([t,i,e])}else{this.processPes_(t,i,e)}};this.processPes_=function(t,e,i){if(i.pid===this.programMapTable.video){i.streamType=h.H264_STREAM_TYPE}else if(i.pid===this.programMapTable.audio){i.streamType=h.ADTS_STREAM_TYPE}else{i.streamType=this.programMapTable["timed-metadata"][i.pid]}i.type="pes";i.data=t.subarray(e);this.trigger("data",i)}};p.prototype=new a;p.STREAM_TYPES={h264:27,adts:15};u=function(){var p=this,a={data:[],size:0},n={data:[],size:0},r={data:[],size:0},d=function(t,e){var i;e.packetLength=6+(t[4]<<8|t[5]);e.dataAlignmentIndicator=(t[6]&4)!==0;i=t[7];if(i&192){e.pts=(t[9]&14)<<27|(t[10]&255)<<20|(t[11]&254)<<12|(t[12]&255)<<5|(t[13]&254)>>>3;e.pts*=4;e.pts+=(t[13]&6)>>>1;e.dts=e.pts;if(i&64){e.dts=(t[14]&14)<<27|(t[15]&255)<<20|(t[16]&254)<<12|(t[17]&255)<<5|(t[18]&254)>>>3;e.dts*=4;e.dts+=(t[18]&6)>>>1}}e.data=t.subarray(9+t[8])},s=function(t,e,i){var a=new Uint8Array(t.size),n={type:e},r=0,s=0,o=false,u;if(!t.data.length||t.size<9){return}n.trackId=t.data[0].pid;for(r=0;r<t.data.length;r++){u=t.data[r];a.set(u.data,s);s+=u.data.byteLength}d(a,n);o=e==="video"||n.packetLength<=t.size;if(i||o){t.size=0;t.data.length=0}if(o){p.trigger("data",n)}};u.prototype.init.call(this);this.push=function(i){({pat:function(){},pes:function(){var t,e;switch(i.streamType){case h.H264_STREAM_TYPE:case o.H264_STREAM_TYPE:t=a;e="video";break;case h.ADTS_STREAM_TYPE:t=n;e="audio";break;case h.METADATA_STREAM_TYPE:t=r;e="timed-metadata";break;default:return}if(i.payloadUnitStartIndicator){s(t,e,true)}t.data.push(i);t.size+=i.data.byteLength},pmt:function(){var t={type:"metadata",tracks:[]},e=i.programMapTable;if(e.video!==null){t.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+e.video,codec:"avc",type:"video"})}if(e.audio!==null){t.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+e.audio,codec:"adts",type:"audio"})}p.trigger("data",t)}})[i.type]()};this.flush=function(){s(a,"video");s(n,"audio");s(r,"timed-metadata");this.trigger("done")}};u.prototype=new a;var l={PAT_PID:0,MP2T_PACKET_LENGTH:d,TransportPacketStream:s,TransportParseStream:p,ElementaryStream:u,TimestampRolloverStream:r,CaptionStream:n.CaptionStream,Cea608Stream:n.Cea608Stream,MetadataStream:t("./metadata-stream")};for(var c in h){if(h.hasOwnProperty(c)){l[c]=h[c]}}e.exports=l},{"../utils/stream.js":36,"./caption-stream":14,"./metadata-stream":17,"./stream-types":19,"./stream-types.js":19,"./timestamp-rollover-stream":20}],17:[function(t,e,i){"use strict";var a=t("../utils/stream"),n=t("./stream-types"),r=function(t,e,i){var a,n="";for(a=e;a<i;a++){n+="%"+("00"+t[a].toString(16)).slice(-2)}return n},s=function(t,e,i){return decodeURIComponent(r(t,e,i))},o=function(t,e,i){return unescape(r(t,e,i))},l=function(t){return t[0]<<21|t[1]<<14|t[2]<<7|t[3]},c={TXXX:function(t){var e;if(t.data[0]!==3){return}for(e=1;e<t.data.length;e++){if(t.data[e]===0){t.description=s(t.data,1,e);t.value=s(t.data,e+1,t.data.length).replace(/\0*$/,"");break}}t.data=t.value},WXXX:function(t){var e;if(t.data[0]!==3){return}for(e=1;e<t.data.length;e++){if(t.data[e]===0){t.description=s(t.data,1,e);t.url=s(t.data,e+1,t.data.length);break}}},PRIV:function(t){var e;for(e=0;e<t.data.length;e++){if(t.data[e]===0){t.owner=o(t.data,0,e);break}}t.privateData=t.data.subarray(e+1);t.data=t.privateData}},u;u=function(t){var p={debug:!!(t&&t.debug),descriptor:t&&t.descriptor},d=0,h=[],f=0,e;u.prototype.init.call(this);this.dispatchType=n.METADATA_STREAM_TYPE.toString(16);if(p.descriptor){for(e=0;e<p.descriptor.length;e++){this.dispatchType+=("00"+p.descriptor[e].toString(16)).slice(-2)}}this.push=function(t){var e,i,a,n,r,s;if(t.type!=="timed-metadata"){return}if(t.dataAlignmentIndicator){f=0;h.length=0}if(h.length===0&&(t.data.length<10||t.data[0]!=="I".charCodeAt(0)||t.data[1]!=="D".charCodeAt(0)||t.data[2]!=="3".charCodeAt(0))){if(p.debug){console.log("Skipping unrecognized metadata packet")}return}h.push(t);f+=t.data.byteLength;if(h.length===1){d=l(t.data.subarray(6,10));d+=10}if(f<d){return}e={data:new Uint8Array(d),frames:[],pts:h[0].pts,dts:h[0].dts};for(r=0;r<d;){e.data.set(h[0].data.subarray(0,d-r),r);r+=h[0].data.byteLength;f-=h[0].data.byteLength;h.shift()}i=10;if(e.data[5]&64){i+=4;i+=l(e.data.subarray(10,14));d-=l(e.data.subarray(16,20))}do{a=l(e.data.subarray(i+4,i+8));if(a<1){return console.log("Malformed ID3 frame encountered. Skipping metadata parsing.")}s=String.fromCharCode(e.data[i],e.data[i+1],e.data[i+2],e.data[i+3]);n={id:s,data:e.data.subarray(i+10,i+a+10)};n.key=n.id;if(c[n.id]){c[n.id](n);if(n.owner==="com.apple.streaming.transportStreamTimestamp"){var o=n.data,u=(o[3]&1)<<30|o[4]<<22|o[5]<<14|o[6]<<6|o[7]>>>2;u*=4;u+=o[7]&3;n.timeStamp=u;if(e.pts===undefined&&e.dts===undefined){e.pts=n.timeStamp;e.dts=n.timeStamp}this.trigger("timestamp",n)}}e.frames.push(n);i+=10;i+=a}while(i<d);this.trigger("data",e)}};u.prototype=new a;e.exports=u},{"../utils/stream":36,"./stream-types":19}],18:[function(t,e,i){"use strict";var n=t("./stream-types.js");var r=function(t){var e=t[1]&31;e<<=8;e|=t[2];return e};var p=function(t){return!!(t[1]&64)};var d=function(t){var e=0;if((t[3]&48)>>>4>1){e+=t[4]+1}return e};var a=function(t,e){var i=r(t);if(i===0){return"pat"}else if(i===e){return"pmt"}else if(e){return"pes"}return null};var s=function(t){var e=p(t);var i=4+d(t);if(e){i+=t[i]+1}return(t[i+10]&31)<<8|t[i+11]};var o=function(t){var e={};var i=p(t);var a=4+d(t);if(i){a+=t[a]+1}if(!(t[a+5]&1)){return}var n,r,s;n=(t[a+1]&15)<<8|t[a+2];r=3+n-4;s=(t[a+10]&15)<<8|t[a+11];var o=12+s;while(o<r){var u=a+o;e[(t[u+1]&31)<<8|t[u+2]]=t[u];o+=((t[u+3]&15)<<8|t[u+4])+5}return e};var u=function(t,e){var i=r(t);var a=e[i];switch(a){case n.H264_STREAM_TYPE:return"video";case n.ADTS_STREAM_TYPE:return"audio";case n.METADATA_STREAM_TYPE:return"timed-metadata";default:return null}};var h=function(t){var e=p(t);if(!e){return null}var i=4+d(t);if(i>=t.byteLength){return null}var a=null;var n;n=t[i+7];if(n&192){a={};a.pts=(t[i+9]&14)<<27|(t[i+10]&255)<<20|(t[i+11]&254)<<12|(t[i+12]&255)<<5|(t[i+13]&254)>>>3;a.pts*=4;a.pts+=(t[i+13]&6)>>>1;a.dts=a.pts;if(n&64){a.dts=(t[i+14]&14)<<27|(t[i+15]&255)<<20|(t[i+16]&254)<<12|(t[i+17]&255)<<5|(t[i+18]&254)>>>3;a.dts*=4;a.dts+=(t[i+18]&6)>>>1}}return a};var f=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}};var l=function(t){var e=4+d(t);var i=t.subarray(e);var a=0;var n=0;var r=false;var s;for(;n<i.byteLength-3;n++){if(i[n+2]===1){a=n+5;break}}while(a<i.byteLength){switch(i[a]){case 0:if(i[a-1]!==0){a+=2;break}else if(i[a-2]!==0){a++;break}if(n+3!==a-2){s=f(i[n+3]&31);if(s==="slice_layer_without_partitioning_rbsp_idr"){r=true}}do{a++}while(i[a]!==1&&a<i.length);n=a-2;a+=3;break;case 1:if(i[a-1]!==0||i[a-2]!==0){a+=3;break}s=f(i[n+3]&31);if(s==="slice_layer_without_partitioning_rbsp_idr"){r=true}n=a-2;a+=3;break;default:a+=3;break}}i=i.subarray(n);a-=n;n=0;if(i&&i.byteLength>3){s=f(i[n+3]&31);if(s==="slice_layer_without_partitioning_rbsp_idr"){r=true}}return r};e.exports={parseType:a,parsePat:s,parsePmt:o,parsePayloadUnitStartIndicator:p,parsePesType:u,parsePesTime:h,videoPacketContainsKeyFrame:l}},{"./stream-types.js":19}],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 a=t("../utils/stream");var n=8589934592;var r=4294967296;var s=function(t,e){var i=1;if(t>e){i=-1}while(Math.abs(e-t)>r){t+=i*n}return t};var o=function(t){var e,i;o.prototype.init.call(this);this.type_=t;this.push=function(t){if(t.type!==this.type_){return}if(i===undefined){i=t.dts}t.dts=s(t.dts,i);t.pts=s(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}};o.prototype=new a;e.exports={TimestampRolloverStream:o,handleRollover:s}},{"../utils/stream":36}],21:[function(t,e,i){var h=t("../data/silence");var f=t("../utils/clock");var l=9e4;var r=function(t){var e,i,a=0;for(e=0;e<t.length;e++){i=t[e];a+=i.data.byteLength}return a};var a=function(t,e,i,a){var n,r=0,s=0,o=0,u=0,p,d;if(!e.length){return}n=f.audioTsToVideoTs(t.baseMediaDecodeTime,t.samplerate);r=Math.ceil(l/(t.samplerate/1024));if(i&&a){s=n-Math.max(i,a);o=Math.floor(s/r);u=o*r}if(o<1||u>l/2){return}p=h[t.samplerate];if(!p){p=e[0].data}for(d=0;d<o;d++){e.splice(d,0,{data:p})}t.baseMediaDecodeTime-=Math.floor(f.videoTsToAudioTs(u,t.samplerate))};var n=function(t,e,i){if(e.minSegmentDts>=i){return t}e.minSegmentDts=Infinity;return t.filter(function(t){if(t.dts>=i){e.minSegmentDts=Math.min(e.minSegmentDts,t.dts);e.minSegmentPts=e.minSegmentDts;return true}return false})};var s=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};var o=function(t){var e,i,a=0,n=new Uint8Array(r(t));for(e=0;e<t.length;e++){i=t[e];n.set(i.data,a);a+=i.data.byteLength}return n};e.exports={prefixWithSilence:a,trimAdtsFramesByEarliestDts:n,generateSampleTable:s,concatenateFrameData:o}},{"../data/silence":6,"../utils/clock":34}],22:[function(t,e,i){"use strict";var h=t("../tools/caption-packet-parser").discardEmulationPreventionBytes;var a=t("../m2ts/caption-stream").CaptionStream;var l=t("./probe");var c=t("../tools/mp4-inspector");var f=function(t,e){var i=t;for(var a=0;a<e.length;a++){var n=e[a];if(i<n.size){return n}i-=n.size}return null};var m=function(t,e,i){var a=new DataView(t.buffer,t.byteOffset,t.byteLength),n=[],r,s,o,u;for(s=0;s+4<t.length;s+=o){o=a.getUint32(s);s+=4;if(o<=0){continue}switch(t[s]&31){case 6:var p=t.subarray(s+1,s+1+o);var d=f(s,e);r={nalUnitType:"sei_rbsp",size:o,data:p,escapedRBSP:h(p),trackId:i};if(d){r.pts=d.pts;r.dts=d.dts;u=d}else{r.pts=u.pts;r.dts=u.dts}n.push(r);break;default:break}}return n};var g=function(t,e,i){var a=e;var n=i.defaultSampleDuration||0;var r=i.defaultSampleSize||0;var s=i.trackId;var o=[];t.forEach(function(t){var e=c.parseTrun(t);var i=e.samples;i.forEach(function(t){if(t.duration===undefined){t.duration=n}if(t.size===undefined){t.size=r}t.trackId=s;t.dts=a;if(t.compositionTimeOffset===undefined){t.compositionTimeOffset=0}t.pts=a+t.compositionTimeOffset;a+=t.duration});o=o.concat(i)});return o};var n=function(t,h){var a=l.findBox(t,["moof","traf"]);var e=l.findBox(t,["mdat"]);var f={};var n=[];e.forEach(function(t,e){var i=a[e];n.push({mdat:t,traf:i})});n.forEach(function(t){var e=t.mdat;var i=t.traf;var a=l.findBox(i,["tfhd"]);var n=c.parseTfhd(a[0]);var r=n.trackId;var s=l.findBox(i,["tfdt"]);var o=s.length>0?c.parseTfdt(s[0]).baseMediaDecodeTime:0;var u=l.findBox(i,["trun"]);var p;var d;if(h===r&&u.length>0){p=g(u,o,n);d=m(e,p,r);if(!f[r]){f[r]=[]}f[r]=f[r].concat(d)}});return f};var p=function(t,e,i){var a;if(!e){return null}a=n(t,e);return{seiNals:a[e],timescale:i}};var r=function(){var t=false;var e;var r;var s;var o;var u;this.isInitialized=function(){return t};this.init=function(){e=new a;t=true;e.on("data",function(t){t.startTime=t.startPts/o;t.endTime=t.endPts/o;u.captions.push(t);u.captionStreams[t.stream]=true})};this.isNewInit=function(t,e){if(t&&t.length===0||e&&typeof e==="object"&&Object.keys(e).length===0){return false}return s!==t[0]||o!==e[s]};this.parse=function(t,e,i){var a;if(!this.isInitialized()){return null}else if(!e||!i){return null}else if(this.isNewInit(e,i)){s=e[0];o=i[s]}else if(!s||!o){r.push(t);return null}while(r.length>0){var n=r.shift();this.parse(n,e,i)}a=p(t,s,o);if(a===null||!a.seiNals){return null}this.pushNals(a.seiNals);this.flushStream();return u};this.pushNals=function(t){if(!this.isInitialized()||!t||t.length===0){return null}t.forEach(function(t){e.push(t)})};this.flushStream=function(){if(!this.isInitialized()){return null}e.flush()};this.clearParsedCaptions=function(){u.captions=[];u.captionStreams={}};this.resetCaptionStream=function(){if(!this.isInitialized()){return null}e.reset()};this.clearAllCaptions=function(){this.clearParsedCaptions();this.resetCaptionStream()};this.reset=function(){r=[];s=null;o=null;if(!u){u={captions:[],captionStreams:{}}}else{this.clearParsedCaptions()}this.resetCaptionStream()};this.reset()};e.exports=r},{"../m2ts/caption-stream":14,"../tools/caption-packet-parser":29,"../tools/mp4-inspector":31,"./probe":26}],23:[function(t,e,i){var a=function(t){var e,i,a=[],n=[];a.byteLength=0;for(e=0;e<t.length;e++){i=t[e];if(i.nalUnitType==="access_unit_delimiter_rbsp"){if(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}else{if(i.nalUnitType==="slice_layer_without_partitioning_rbsp_idr"){a.keyFrame=true}a.duration=i.dts-a.dts;a.byteLength+=i.data.byteLength;a.push(i)}}if(n.length&&(!a.duration||a.duration<=0)){a.duration=n[n.length-1].duration}n.push(a);return n};var n=function(t){var e,i,a=[],n=[];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;for(e=0;e<t.length;e++){i=t[e];if(i.keyFrame){if(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}else{a.duration+=i.duration;a.nalCount+=i.length;a.byteLength+=i.byteLength;a.push(i)}}if(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);return n};var r=function(t){var e;if(!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}return t};var s=function(){return{size:0,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0,degradationPriority:0,isNonSyncSample:1}}};var p=function(t,e){var i=s();i.dataOffset=e;i.compositionTimeOffset=t.pts-t.dts;i.duration=t.duration;i.size=4*t.length;i.size+=t.byteLength;if(t.keyFrame){i.flags.dependsOn=2;i.flags.isNonSyncSample=0}return i};var o=function(t,e){var i,a,n,r,s,o=e||0,u=[];for(i=0;i<t.length;i++){r=t[i];for(a=0;a<r.length;a++){s=r[a];n=p(s,o);o+=n.size;u.push(n)}}return u};var u=function(t){var e,i,a,n,r,s,o=0,u=t.byteLength,p=t.nalCount,d=u+4*p,h=new Uint8Array(d),f=new DataView(h.buffer);for(e=0;e<t.length;e++){n=t[e];for(i=0;i<n.length;i++){r=n[i];for(a=0;a<r.length;a++){s=r[a];f.setUint32(o,s.data.byteLength);o+=4;h.set(s.data,o);o+=s.data.byteLength}}}return h};e.exports={groupNalsIntoFrames:a,groupFramesIntoGops:n,extendFirstKeyFrame:r,generateSampleTable:o,concatenateNalData:u}},{}],24:[function(t,e,i){e.exports={generator:t("./mp4-generator"),probe:t("./probe"),Transmuxer:t("./transmuxer").Transmuxer,AudioSegmentStream:t("./transmuxer").AudioSegmentStream,VideoSegmentStream:t("./transmuxer").VideoSegmentStream,CaptionParser:t("./caption-parser")}},{"./caption-parser":22,"./mp4-generator":25,"./probe":26,"./transmuxer":28}],25:[function(t,e,i){"use strict";var u=Math.pow(2,32)-1;var p,a,n,r,s,o,d,h,f,l,c,m,g,y,b,v,T,S,_,w,U,k,A,D,C,x,L,P,I,E,O,M,R,B,z,F;(function(){var t;A={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:[]};if(typeof Uint8Array==="undefined"){return}for(t in A){if(A.hasOwnProperty(t)){A[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]}}D=new Uint8Array(["i".charCodeAt(0),"s".charCodeAt(0),"o".charCodeAt(0),"m".charCodeAt(0)]);x=new Uint8Array(["a".charCodeAt(0),"v".charCodeAt(0),"c".charCodeAt(0),"1".charCodeAt(0)]);C=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]);P=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);I={video:L,audio:P};M=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]);O=new Uint8Array([0,0,0,0,0,0,0,0]);R=new Uint8Array([0,0,0,0,0,0,0,0]);B=R;z=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]);F=R;E=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])})();p=function(t){var e=[],i=0,a,n,r;for(a=1;a<arguments.length;a++){e.push(arguments[a])}a=e.length;while(a--){i+=e[a].byteLength}n=new Uint8Array(i+8);r=new DataView(n.buffer,n.byteOffset,n.byteLength);r.setUint32(0,n.byteLength);n.set(t,4);for(a=0,i=8;a<e.length;a++){n.set(e[a],i);i+=e[a].byteLength}return n};a=function(){return p(A.dinf,p(A.dref,M))};n=function(t){return p(A.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]))};r=function(){return p(A.ftyp,D,C,D,x)};v=function(t){return p(A.hdlr,I[t])};s=function(t){return p(A.mdat,t)};b=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,t.duration&255,85,196,0,0]);if(t.samplerate){e[12]=t.samplerate>>>24&255;e[13]=t.samplerate>>>16&255;e[14]=t.samplerate>>>8&255;e[15]=t.samplerate&255}return p(A.mdhd,e)};y=function(t){return p(A.mdia,b(t),v(t.type),d(t))};o=function(t){return p(A.mfhd,new Uint8Array([0,0,0,0,(t&4278190080)>>24,(t&16711680)>>16,(t&65280)>>8,t&255]))};d=function(t){return p(A.minf,t.type==="video"?p(A.vmhd,E):p(A.smhd,O),a(),S(t))};h=function(t,e){var i=[],a=e.length;while(a--){i[a]=w(e[a])}return p.apply(null,[A.moof,o(t)].concat(i))};f=function(t){var e=t.length,i=[];while(e--){i[e]=m(t[e])}return p.apply(null,[A.moov,c(4294967295)].concat(i).concat(l(t)))};l=function(t){var e=t.length,i=[];while(e--){i[e]=U(t[e])}return p.apply(null,[A.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,(t&4278190080)>>24,(t&16711680)>>16,(t&65280)>>8,t&255,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 p(A.mvhd,e)};T=function(t){var e=t.samples||[],i=new Uint8Array(4+e.length),a,n;for(n=0;n<e.length;n++){a=e[n].flags;i[n+4]=a.dependsOn<<4|a.isDependedOn<<2|a.hasRedundancy}return p(A.sdtp,i)};S=function(t){return p(A.stbl,_(t),p(A.stts,F),p(A.stsc,B),p(A.stsz,z),p(A.stco,R))};(function(){var e,i;_=function(t){return p(A.stsd,new Uint8Array([0,0,0,0,0,0,0,1]),t.type==="video"?e(t):i(t))};e=function(t){var e=t.sps||[],i=t.pps||[],a=[],n=[],r;for(r=0;r<e.length;r++){a.push((e[r].byteLength&65280)>>>8);a.push(e[r].byteLength&255);a=a.concat(Array.prototype.slice.call(e[r]))}for(r=0;r<i.length;r++){n.push((i[r].byteLength&65280)>>>8);n.push(i[r].byteLength&255);n=n.concat(Array.prototype.slice.call(i[r]))}return p(A.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,(t.width&65280)>>8,t.width&255,(t.height&65280)>>8,t.height&255,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]),p(A.avcC,new Uint8Array([1,t.profileIdc,t.profileCompatibility,t.levelIdc,255].concat([e.length]).concat(a).concat([i.length]).concat(n))),p(A.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])))};i=function(t){return p(A.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,(t.channelcount&65280)>>8,t.channelcount&255,(t.samplesize&65280)>>8,t.samplesize&255,0,0,0,0,(t.samplerate&65280)>>8,t.samplerate&255,0,0]),n(t))}})();g=function(t){var e=new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,(t.id&4278190080)>>24,(t.id&16711680)>>16,(t.id&65280)>>8,t.id&255,0,0,0,0,(t.duration&4278190080)>>24,(t.duration&16711680)>>16,(t.duration&65280)>>8,t.duration&255,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,(t.width&65280)>>8,t.width&255,0,0,(t.height&65280)>>8,t.height&255,0,0]);return p(A.tkhd,e)};w=function(t){var e,i,a,n,r,s,o;e=p(A.tfhd,new Uint8Array([0,0,0,58,(t.id&4278190080)>>24,(t.id&16711680)>>16,(t.id&65280)>>8,t.id&255,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0]));s=Math.floor(t.baseMediaDecodeTime/(u+1));o=Math.floor(t.baseMediaDecodeTime%(u+1));i=p(A.tfdt,new Uint8Array([1,0,0,0,s>>>24&255,s>>>16&255,s>>>8&255,s&255,o>>>24&255,o>>>16&255,o>>>8&255,o&255]));r=32+20+8+16+8+8;if(t.type==="audio"){a=k(t,r);return p(A.traf,e,i,a)}n=T(t);a=k(t,n.length+r);return p(A.traf,e,i,a,n)};m=function(t){t.duration=t.duration||4294967295;return p(A.trak,g(t),y(t))};U=function(t){var e=new Uint8Array([0,0,0,0,(t.id&4278190080)>>24,(t.id&16711680)>>16,(t.id&65280)>>8,t.id&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);if(t.type!=="video"){e[e.length-1]=0}return p(A.trex,e)};(function(){var i,a,s;s=function(t,e){var i=0,a=0,n=0,r=0;if(t.length){if(t[0].duration!==undefined){i=1}if(t[0].size!==undefined){a=2}if(t[0].flags!==undefined){n=4}if(t[0].compositionTimeOffset!==undefined){r=8}}return[0,0,i|a|n|r,1,(t.length&4278190080)>>>24,(t.length&16711680)>>>16,(t.length&65280)>>>8,t.length&255,(e&4278190080)>>>24,(e&16711680)>>>16,(e&65280)>>>8,e&255]};a=function(t,e){var i,a,n,r;a=t.samples||[];e+=8+12+16*a.length;i=s(a,e);for(r=0;r<a.length;r++){n=a[r];i=i.concat([(n.duration&4278190080)>>>24,(n.duration&16711680)>>>16,(n.duration&65280)>>>8,n.duration&255,(n.size&4278190080)>>>24,(n.size&16711680)>>>16,(n.size&65280)>>>8,n.size&255,n.flags.isLeading<<2|n.flags.dependsOn,n.flags.isDependedOn<<6|n.flags.hasRedundancy<<4|n.flags.paddingValue<<1|n.flags.isNonSyncSample,n.flags.degradationPriority&240<<8,n.flags.degradationPriority&15,(n.compositionTimeOffset&4278190080)>>>24,(n.compositionTimeOffset&16711680)>>>16,(n.compositionTimeOffset&65280)>>>8,n.compositionTimeOffset&255])}return p(A.trun,new Uint8Array(i))};i=function(t,e){var i,a,n,r;a=t.samples||[];e+=8+12+8*a.length;i=s(a,e);for(r=0;r<a.length;r++){n=a[r];i=i.concat([(n.duration&4278190080)>>>24,(n.duration&16711680)>>>16,(n.duration&65280)>>>8,n.duration&255,(n.size&4278190080)>>>24,(n.size&16711680)>>>16,(n.size&65280)>>>8,n.size&255])}return p(A.trun,new Uint8Array(i))};k=function(t,e){if(t.type==="audio"){return i(t,e)}return a(t,e)}})();e.exports={ftyp:r,mdat:s,moof:h,moov:f,initSegment:function(t){var e=r(),i=f(t),a;a=new Uint8Array(e.byteLength+i.byteLength);a.set(e);a.set(i,e.byteLength);return a}}},{}],26:[function(t,e,i){"use strict";var u=t("../utils/bin").toUnsigned;var p,d,a,n,r;p=function(t,e){var i=[],a,n,r,s,o;if(!e.length){return null}for(a=0;a<t.byteLength;){n=u(t[a]<<24|t[a+1]<<16|t[a+2]<<8|t[a+3]);r=d(t.subarray(a+4,a+8));s=n>1?a+n:t.byteLength;if(r===e[0]){if(e.length===1){i.push(t.subarray(a+8,s))}else{o=p(t.subarray(a+8,s),e.slice(1));if(o.length){i=i.concat(o)}}}a=s}return i};d=function(t){var e="";e+=String.fromCharCode(t[0]);e+=String.fromCharCode(t[1]);e+=String.fromCharCode(t[2]);e+=String.fromCharCode(t[3]);return e};a=function(t){var e={},i=p(t,["moov","trak"]);return i.reduce(function(t,e){var i,a,n,r,s;i=p(e,["tkhd"])[0];if(!i){return null}a=i[0];n=a===0?12:20;r=u(i[n]<<24|i[n+1]<<16|i[n+2]<<8|i[n+3]);s=p(e,["mdia","mdhd"])[0];if(!s){return null}a=s[0];n=a===0?12:20;t[r]=u(s[n]<<24|s[n+1]<<16|s[n+2]<<8|s[n+3]);return t},e)};n=function(r,t){var e,i,a;e=p(t,["moof","traf"]);i=[].concat.apply([],e.map(function(n){return p(n,["tfhd"]).map(function(t){var e,i,a;e=u(t[4]<<24|t[5]<<16|t[6]<<8|t[7]);i=r[e]||9e4;a=p(n,["tfdt"]).map(function(t){var e,i;e=t[0];i=u(t[4]<<24|t[5]<<16|t[6]<<8|t[7]);if(e===1){i*=Math.pow(2,32);i+=u(t[8]<<24|t[9]<<16|t[10]<<8|t[11])}return i})[0];a=a||Infinity;return a/i})}));a=Math.min.apply(null,i);return isFinite(a)?a:0};r=function(t){var e=p(t,["moov","trak"]);var u=[];e.forEach(function(t){var e=p(t,["mdia","hdlr"]);var o=p(t,["tkhd"]);e.forEach(function(t,e){var i=d(t.subarray(8,12));var a=o[e];var n;var r;var s;if(i==="vide"){n=new DataView(a.buffer,a.byteOffset,a.byteLength);r=n.getUint8(0);s=r===0?n.getUint32(12):n.getUint32(20);u.push(s)}})});return u};e.exports={findBox:p,parseType:d,timescale:a,startTime:n,videoTrackIds:r}},{"../utils/bin":33}],27:[function(t,e,i){var r=9e4;var a=function(t,e){if(typeof e.pts==="number"){if(t.timelineStartInfo.pts===undefined){t.timelineStartInfo.pts=e.pts}if(t.minSegmentPts===undefined){t.minSegmentPts=e.pts}else{t.minSegmentPts=Math.min(t.minSegmentPts,e.pts)}if(t.maxSegmentPts===undefined){t.maxSegmentPts=e.pts}else{t.maxSegmentPts=Math.max(t.maxSegmentPts,e.pts)}}if(typeof e.dts==="number"){if(t.timelineStartInfo.dts===undefined){t.timelineStartInfo.dts=e.dts}if(t.minSegmentDts===undefined){t.minSegmentDts=e.dts}else{t.minSegmentDts=Math.min(t.minSegmentDts,e.dts)}if(t.maxSegmentDts===undefined){t.maxSegmentDts=e.dts}else{t.maxSegmentDts=Math.max(t.maxSegmentDts,e.dts)}}};var n=function(t){delete t.minSegmentDts;delete t.maxSegmentDts;delete t.minSegmentPts;delete t.maxSegmentPts};var s=function(t,e){var i,a,n=t.minSegmentDts;if(!e){n-=t.timelineStartInfo.dts}i=t.timelineStartInfo.baseMediaDecodeTime;i+=n;i=Math.max(0,i);if(t.type==="audio"){a=t.samplerate/r;i*=a;i=Math.floor(i)}return i};e.exports={clearDtsInfo:n,calculateTrackBaseMediaDecodeTime:s,collectDtsInfo:a}},{}],28:[function(t,e,i){"use strict";var a=t("../utils/stream.js");var m=t("./mp4-generator.js");var g=t("./frame-utils");var h=t("./audio-frame-utils");var y=t("./track-decode-info");var o=t("../m2ts/m2ts.js");var u=t("../codecs/adts.js");var p=t("../codecs/h264").H264Stream;var d=t("../aac");var f=t("../aac/utils").isLikelyAacData;var l=["audioobjecttype","channelcount","samplerate","samplingfrequencyindex","samplesize"];var b=["width","height","profileIdc","levelIdc","profileCompatibility"];var v,c,T,S;var _=function(t,e){var i;if(t.length!==e.length){return false}for(i=0;i<t.length;i++){if(t[i]!==e[i]){return false}}return true};var w=function(t,e,i,a,n,r){var s=i-e,o=a-e,u=n-i;return{start:{dts:t,pts:t+s},end:{dts:t+o,pts:t+u},prependedContentDuration:r,baseMediaDecodeTime:t}};c=function(n,r){var s=[],o=0,u=0,p=0,d=Infinity;r=r||{};c.prototype.init.call(this);this.push=function(e){y.collectDtsInfo(n,e);if(n){l.forEach(function(t){n[t]=e[t]})}s.push(e)};this.setEarliestDts=function(t){u=t-n.timelineStartInfo.baseMediaDecodeTime};this.setVideoBaseMediaDecodeTime=function(t){d=t};this.setAudioAppendStart=function(t){p=t};this.flush=function(){var t,e,i,a;if(s.length===0){this.trigger("done","AudioSegmentStream");return}t=h.trimAdtsFramesByEarliestDts(s,n,u);n.baseMediaDecodeTime=y.calculateTrackBaseMediaDecodeTime(n,r.keepOriginalTimestamps);h.prefixWithSilence(n,t,p,d);n.samples=h.generateSampleTable(t);i=m.mdat(h.concatenateFrameData(t));s=[];e=m.moof(o,[n]);a=new Uint8Array(e.byteLength+i.byteLength);o++;a.set(e);a.set(i,e.byteLength);y.clearDtsInfo(n);this.trigger("data",{track:n,boxes:a});this.trigger("done","AudioSegmentStream")}};c.prototype=new a;v=function(d,h){var f=0,l=[],c=[],e,i;h=h||{};v.prototype.init.call(this);delete d.minPTS;this.gopCache_=[];this.push=function(t){y.collectDtsInfo(d,t);if(t.nalUnitType==="seq_parameter_set_rbsp"&&!e){e=t.config;d.sps=[t.data];b.forEach(function(t){d[t]=e[t]},this)}if(t.nalUnitType==="pic_parameter_set_rbsp"&&!i){i=t.data;d.pps=[t.data]}l.push(t)};this.flush=function(){var t,e,i,a,n,r,s=0,o,u;while(l.length){if(l[0].nalUnitType==="access_unit_delimiter_rbsp"){break}l.shift()}if(l.length===0){this.resetStream_();this.trigger("done","VideoSegmentStream");return}t=g.groupNalsIntoFrames(l);i=g.groupFramesIntoGops(t);if(!i[0][0].keyFrame){e=this.getGopForFusion_(l[0],d);if(e){s=e.duration;i.unshift(e);i.byteLength+=e.byteLength;i.nalCount+=e.nalCount;i.pts=e.pts;i.dts=e.dts;i.duration+=e.duration}else{i=g.extendFirstKeyFrame(i)}}if(c.length){var p;if(h.alignGopsAtEnd){p=this.alignGopsAtEnd_(i)}else{p=this.alignGopsAtStart_(i)}if(!p){this.gopCache_.unshift({gop:i.pop(),pps:d.pps,sps:d.sps});this.gopCache_.length=Math.min(6,this.gopCache_.length);l=[];this.resetStream_();this.trigger("done","VideoSegmentStream");return}y.clearDtsInfo(d);i=p}y.collectDtsInfo(d,i);d.samples=g.generateSampleTable(i);n=m.mdat(g.concatenateNalData(i));d.baseMediaDecodeTime=y.calculateTrackBaseMediaDecodeTime(d,h.keepOriginalTimestamps);this.trigger("processedGopsInfo",i.map(function(t){return{pts:t.pts,dts:t.dts,byteLength:t.byteLength}}));o=i[0];u=i[i.length-1];this.trigger("segmentTimingInfo",w(d.baseMediaDecodeTime,o.dts,o.pts,u.dts+u.duration,u.pts+u.duration,s));this.gopCache_.unshift({gop:i.pop(),pps:d.pps,sps:d.sps});this.gopCache_.length=Math.min(6,this.gopCache_.length);l=[];this.trigger("baseMediaDecodeTime",d.baseMediaDecodeTime);this.trigger("timelineStartInfo",d.timelineStartInfo);a=m.moof(f,[d]);r=new Uint8Array(a.byteLength+n.byteLength);f++;r.set(a);r.set(n,a.byteLength);this.trigger("data",{track:d,boxes:r});this.resetStream_();this.trigger("done","VideoSegmentStream")};this.resetStream_=function(){y.clearDtsInfo(d);e=undefined;i=undefined};this.getGopForFusion_=function(t){var e=45e3,i=1e4,a=Infinity,n,r,s,o,u;for(u=0;u<this.gopCache_.length;u++){o=this.gopCache_[u];s=o.gop;if(!(d.pps&&_(d.pps[0],o.pps[0]))||!(d.sps&&_(d.sps[0],o.sps[0]))){continue}if(s.dts<d.timelineStartInfo.dts){continue}n=t.dts-s.dts-s.duration;if(n>=-i&&n<=e){if(!r||a>n){r=o;a=n}}}if(r){return r.gop}return null};this.alignGopsAtStart_=function(t){var e,i,a,n,r,s,o,u;r=t.byteLength;s=t.nalCount;o=t.duration;e=i=0;while(e<c.length&&i<t.length){a=c[e];n=t[i];if(a.pts===n.pts){break}if(n.pts>a.pts){e++;continue}i++;r-=n.byteLength;s-=n.nalCount;o-=n.duration}if(i===0){return t}if(i===t.length){return null}u=t.slice(i);u.byteLength=r;u.duration=o;u.nalCount=s;u.pts=u[0].pts;u.dts=u[0].dts;return u};this.alignGopsAtEnd_=function(t){var e,i,a,n,r,s;e=c.length-1;i=t.length-1;r=null;s=false;while(e>=0&&i>=0){a=c[e];n=t[i];if(a.pts===n.pts){s=true;break}if(a.pts>n.pts){e--;continue}if(e===c.length-1){r=i}i--}if(!s&&r===null){return null}var o;if(s){o=i}else{o=r}if(o===0){return t}var u=t.slice(o);var p=u.reduce(function(t,e){t.byteLength+=e.byteLength;t.duration+=e.duration;t.nalCount+=e.nalCount;return t},{byteLength:0,duration:0,nalCount:0});u.byteLength=p.byteLength;u.duration=p.duration;u.nalCount=p.nalCount;u.pts=u[0].pts;u.dts=u[0].dts;return u};this.alignGopsWith=function(t){c=t}};v.prototype=new a;S=function(t,e){this.numberOfTracks=0;this.metadataStream=e;t=t||{};if(typeof t.remux!=="undefined"){this.remuxTracks=!!t.remux}else{this.remuxTracks=true}if(typeof t.keepOriginalTimestamps==="boolean"){this.keepOriginalTimestamps=t.keepOriginalTimestamps}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){if(t.text){return this.pendingCaptions.push(t)}if(t.frames){return this.pendingMetadata.push(t)}this.pendingTracks.push(t.track);this.pendingBoxes.push(t.boxes);this.pendingBytes+=t.boxes.byteLength;if(t.track.type==="video"){this.videoTrack=t.track}if(t.track.type==="audio"){this.audioTrack=t.track}}};S.prototype=new a;S.prototype.flush=function(t){var e=0,i={captions:[],captionStreams:{},metadata:[],info:{}},a,n,r,s=0,o;if(this.pendingTracks.length<this.numberOfTracks){if(t!=="VideoSegmentStream"&&t!=="AudioSegmentStream"){return}else if(this.remuxTracks){return}else if(this.pendingTracks.length===0){this.emittedTracks++;if(this.emittedTracks>=this.numberOfTracks){this.trigger("done");this.emittedTracks=0}return}}if(this.videoTrack){s=this.videoTrack.timelineStartInfo.pts;b.forEach(function(t){i.info[t]=this.videoTrack[t]},this)}else if(this.audioTrack){s=this.audioTrack.timelineStartInfo.pts;l.forEach(function(t){i.info[t]=this.audioTrack[t]},this)}if(this.pendingTracks.length===1){i.type=this.pendingTracks[0].type}else{i.type="combined"}this.emittedTracks+=this.pendingTracks.length;r=m.initSegment(this.pendingTracks);i.initSegment=new Uint8Array(r.byteLength);i.initSegment.set(r);i.data=new Uint8Array(this.pendingBytes);for(o=0;o<this.pendingBoxes.length;o++){i.data.set(this.pendingBoxes[o],e);e+=this.pendingBoxes[o].byteLength}for(o=0;o<this.pendingCaptions.length;o++){a=this.pendingCaptions[o];a.startTime=a.startPts;if(!this.keepOriginalTimestamps){a.startTime-=s}a.startTime/=9e4;a.endTime=a.endPts;if(!this.keepOriginalTimestamps){a.endTime-=s}a.endTime/=9e4;i.captionStreams[a.stream]=true;i.captions.push(a)}for(o=0;o<this.pendingMetadata.length;o++){n=this.pendingMetadata[o];n.cueTime=n.pts;if(!this.keepOriginalTimestamps){n.cueTime-=s}n.cueTime/=9e4;i.metadata.push(n)}i.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",i);if(this.emittedTracks>=this.numberOfTracks){this.trigger("done");this.emittedTracks=0}};T=function(a){var n=this,i=true,r,s;T.prototype.init.call(this);a=a||{};this.baseMediaDecodeTime=a.baseMediaDecodeTime||0;this.transmuxPipeline_={};this.setupAacPipeline=function(){var e={};this.transmuxPipeline_=e;e.type="aac";e.metadataStream=new o.MetadataStream;e.aacStream=new d;e.audioTimestampRolloverStream=new o.TimestampRolloverStream("audio");e.timedMetadataTimestampRolloverStream=new o.TimestampRolloverStream("timed-metadata");e.adtsStream=new u;e.coalesceStream=new S(a,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){if(t.type==="timed-metadata"&&!e.audioSegmentStream){s=s||{timelineStartInfo:{baseMediaDecodeTime:n.baseMediaDecodeTime},codec:"adts",type:"audio"};e.coalesceStream.numberOfTracks++;e.audioSegmentStream=new c(s,a);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 i={};this.transmuxPipeline_=i;i.type="ts";i.metadataStream=new o.MetadataStream;i.packetStream=new o.TransportPacketStream;i.parseStream=new o.TransportParseStream;i.elementaryStream=new o.ElementaryStream;i.videoTimestampRolloverStream=new o.TimestampRolloverStream("video");i.audioTimestampRolloverStream=new o.TimestampRolloverStream("audio");i.timedMetadataTimestampRolloverStream=new o.TimestampRolloverStream("timed-metadata");i.adtsStream=new u;i.h264Stream=new p;i.captionStream=new o.CaptionStream;i.coalesceStream=new S(a,i.metadataStream);i.headOfPipeline=i.packetStream;i.packetStream.pipe(i.parseStream).pipe(i.elementaryStream);i.elementaryStream.pipe(i.videoTimestampRolloverStream).pipe(i.h264Stream);i.elementaryStream.pipe(i.audioTimestampRolloverStream).pipe(i.adtsStream);i.elementaryStream.pipe(i.timedMetadataTimestampRolloverStream).pipe(i.metadataStream).pipe(i.coalesceStream);i.h264Stream.pipe(i.captionStream).pipe(i.coalesceStream);i.elementaryStream.on("data",function(t){var e;if(t.type==="metadata"){e=t.tracks.length;while(e--){if(!r&&t.tracks[e].type==="video"){r=t.tracks[e];r.timelineStartInfo.baseMediaDecodeTime=n.baseMediaDecodeTime}else if(!s&&t.tracks[e].type==="audio"){s=t.tracks[e];s.timelineStartInfo.baseMediaDecodeTime=n.baseMediaDecodeTime}}if(r&&!i.videoSegmentStream){i.coalesceStream.numberOfTracks++;i.videoSegmentStream=new v(r,a);i.videoSegmentStream.on("timelineStartInfo",function(t){if(s){s.timelineStartInfo=t;i.audioSegmentStream.setEarliestDts(t.dts)}});i.videoSegmentStream.on("processedGopsInfo",n.trigger.bind(n,"gopInfo"));i.videoSegmentStream.on("segmentTimingInfo",n.trigger.bind(n,"videoSegmentTimingInfo"));i.videoSegmentStream.on("baseMediaDecodeTime",function(t){if(s){i.audioSegmentStream.setVideoBaseMediaDecodeTime(t)}});i.h264Stream.pipe(i.videoSegmentStream).pipe(i.coalesceStream)}if(s&&!i.audioSegmentStream){i.coalesceStream.numberOfTracks++;i.audioSegmentStream=new c(s,a);i.adtsStream.pipe(i.audioSegmentStream).pipe(i.coalesceStream)}}});i.coalesceStream.on("data",this.trigger.bind(this,"data"));i.coalesceStream.on("done",this.trigger.bind(this,"done"))};this.setBaseMediaDecodeTime=function(t){var e=this.transmuxPipeline_;if(!a.keepOriginalTimestamps){this.baseMediaDecodeTime=t}if(s){s.timelineStartInfo.dts=undefined;s.timelineStartInfo.pts=undefined;y.clearDtsInfo(s);if(!a.keepOriginalTimestamps){s.timelineStartInfo.baseMediaDecodeTime=t}if(e.audioTimestampRolloverStream){e.audioTimestampRolloverStream.discontinuity()}}if(r){if(e.videoSegmentStream){e.videoSegmentStream.gopCache_=[];e.videoTimestampRolloverStream.discontinuity()}r.timelineStartInfo.dts=undefined;r.timelineStartInfo.pts=undefined;y.clearDtsInfo(r);e.captionStream.reset();if(!a.keepOriginalTimestamps){r.timelineStartInfo.baseMediaDecodeTime=t}}if(e.timedMetadataTimestampRolloverStream){e.timedMetadataTimestampRolloverStream.discontinuity()}};this.setAudioAppendStart=function(t){if(s){this.transmuxPipeline_.audioSegmentStream.setAudioAppendStart(t)}};this.alignGopsWith=function(t){if(r&&this.transmuxPipeline_.videoSegmentStream){this.transmuxPipeline_.videoSegmentStream.alignGopsWith(t)}};this.push=function(t){if(i){var e=f(t);if(e&&this.transmuxPipeline_.type!=="aac"){this.setupAacPipeline()}else if(!e&&this.transmuxPipeline_.type!=="ts"){this.setupTsPipeline()}i=false}this.transmuxPipeline_.headOfPipeline.push(t)};this.flush=function(){i=true;this.transmuxPipeline_.headOfPipeline.flush()};this.resetCaptions=function(){if(this.transmuxPipeline_.captionStream){this.transmuxPipeline_.captionStream.reset()}}};T.prototype=new a;e.exports={Transmuxer:T,VideoSegmentStream:v,AudioSegmentStream:c,AUDIO_PROPERTIES:l,VIDEO_PROPERTIES:b,generateVideoSegmentTimingInfo:w}},{"../aac":1,"../aac/utils":2,"../codecs/adts.js":3,"../codecs/h264":4,"../m2ts/m2ts.js":16,"../utils/stream.js":36,"./audio-frame-utils":21,"./frame-utils":23,"./mp4-generator.js":25,"./track-decode-info":27}],29:[function(t,e,i){"use strict";var r=4,s=128;var a=function(t){var e=0,i={payloadType:-1,payloadSize:0},a=0,n=0;while(e<t.byteLength){if(t[e]===s){break}while(t[e]===255){a+=255;e++}a+=t[e++];while(t[e]===255){n+=255;e++}n+=t[e++];if(!i.payload&&a===r){i.payloadType=a;i.payloadSize=n;i.payload=t.subarray(e,e+n);break}e+=n;a=0;n=0}return i};var n=function(t){if(t.payload[0]!==181){return null}if((t.payload[1]<<8|t.payload[2])!==49){return null}if(String.fromCharCode(t.payload[3],t.payload[4],t.payload[5],t.payload[6])!=="GA94"){return null}if(t.payload[7]!==3){return null}return t.payload.subarray(8,t.payload.length-1)};var o=function(t,e){var i=[],a,n,r,s;if(!(e[0]&64)){return i}n=e[0]&31;for(a=0;a<n;a++){r=a*3;s={type:e[r+2]&3,pts:t};if(e[r+2]&4){s.ccData=e[r+3]<<8|e[r+4];i.push(s)}}return i};var u=function(t){var e=t.byteLength,i=[],a=1,n,r;while(a<e-2){if(t[a]===0&&t[a+1]===0&&t[a+2]===3){i.push(a+2);a+=2}else{a++}}if(i.length===0){return t}n=e-i.length;r=new Uint8Array(n);var s=0;for(a=0;a<n;s++,a++){if(s===i[0]){s++;i.shift()}r[a]=t[s]}return r};e.exports={parseSei:a,parseUserData:n,parseCaptionPackets:o,discardEmulationPreventionBytes:u,USER_DATA_REGISTERED_ITU_T_T35:r}},{}],30:[function(t,e,i){"use strict";var a={8:"audio",9:"video",18:"metadata"},n=function(t){return"0x"+("00"+t.toString(16)).slice(-2).toUpperCase()},r=function(t){var e=[],i;while(t.byteLength>0){i=0;e.push(n(t[i++]));t=t.subarray(i)}return e.join(" ")},s=function(t,e){var i=["AVC Sequence Header","AVC NALU","AVC End-of-Sequence"],a=t[1]&parseInt("01111111",2)<<16|t[2]<<8|t[3];e=e||{};e.avcPacketType=i[t[0]];e.CompositionTime=t[1]&parseInt("10000000",2)?-a:a;if(t[0]===1){e.nalUnitTypeRaw=r(t.subarray(4,100))}else{e.data=r(t.subarray(4))}return 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"],a=t[0]&parseInt("00001111",2);e=e||{};e.frameType=i[(t[0]&parseInt("11110000",2))>>>4];e.codecID=a;if(a===7){return s(t.subarray(1),e)}return e},u=function(t,e){var i=["AAC Sequence Header","AAC Raw"];e=e||{};e.aacPacketType=i[t[0]];e.data=r(t.subarray(1));return e},p=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"],a=["5.5-kHz","11-kHz","22-kHz","44-kHz"],n=(t[0]&parseInt("11110000",2))>>>4;e=e||{};e.soundFormat=i[n];e.soundRate=a[(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";if(n===10){return u(t.subarray(1),e)}return e},d=function(t){return{tagType:a[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]}},h=function(t){var e=d(t);switch(t[0]){case 8:p(t.subarray(11),e);break;case 9:o(t.subarray(11),e);break;case 18:}return e},f=function(t){var e=9,i,a=[],n;e+=4;while(e<t.byteLength){i=t[e+1]<<16;i|=t[e+2]<<8;i|=t[e+3];i+=11;n=t.subarray(e,e+i);a.push(h(n));e+=i+4}return a},l=function(t){return JSON.stringify(t,null,2)};e.exports={inspectTag:h,inspect:f,textify:l}},{}],31:[function(t,e,i){"use strict";var a,s,h=t("../mp4/probe").parseType,r=function(t){return new Date(t*1e3-20828448e5)},f=function(t){return{isLeading:(t[0]&12)>>>2,dependsOn:t[0]&3,isDependedOn:(t[1]&192)>>>6,hasRedundancy:(t[1]&48)>>>4,paddingValue:(t[1]&14)>>>1,isNonSyncSample:t[1]&1,degradationPriority:t[2]<<8|t[3]}},n=function(t){var e=new DataView(t.buffer,t.byteOffset,t.byteLength),i=[],a,n;for(a=0;a+4<t.length;a+=n){n=e.getUint32(a);a+=4;if(n<=0){i.push("<span style='color:red;'>MALFORMED DATA</span>");continue}switch(t[a]&31){case 1:i.push("slice_layer_without_partitioning_rbsp");break;case 5:i.push("slice_layer_without_partitioning_rbsp_idr");break;case 6:i.push("sei_rbsp");break;case 7:i.push("seq_parameter_set_rbsp");break;case 8:i.push("pic_parameter_set_rbsp");break;case 9:i.push("access_unit_delimiter_rbsp");break;default:i.push("UNKNOWN NAL - "+t[a]&31);break}}return i},l={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:a(t.subarray(78,t.byteLength))}},avcC:function(t){var e=new DataView(t.buffer,t.byteOffset,t.byteLength),i={configurationVersion:t[0],avcProfileIndication:t[1],profileCompatibility:t[2],avcLevelIndication:t[3],lengthSizeMinusOne:t[4]&3,sps:[],pps:[]},a=t[5]&31,n,r,s,o;s=6;for(o=0;o<a;o++){r=e.getUint16(s);s+=2;i.sps.push(new Uint8Array(t.subarray(s,s+r)));s+=r}n=t[s];s++;for(o=0;o<n;o++){r=e.getUint16(s);s+=2;i.pps.push(new Uint8Array(t.subarray(s,s+r)));s+=r}return i},btrt:function(t){var e=new DataView(t.buffer,t.byteOffset,t.byteLength);return{bufferSizeDB:e.getUint32(0),maxBitrate:e.getUint32(4),avgBitrate:e.getUint32(8)}},esds:function(t){return{version:t[0],flags:new Uint8Array(t.subarray(1,4)),esId:t[6]<<8|t[7],streamPriority:t[8]&31,decoderConfig:{objectProfileIndication:t[11],streamType:t[12]>>>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:(t[26]&7)<<1|t[27]>>>7&1,channelConfiguration:t[27]>>>3&15}}}},ftyp:function(t){var e=new DataView(t.buffer,t.byteOffset,t.byteLength),i={majorBrand:h(t.subarray(0,4)),minorVersion:e.getUint32(4),compatibleBrands:[]},a=8;while(a<t.byteLength){i.compatibleBrands.push(h(t.subarray(a,a+4)));a+=4}return i},dinf:function(t){return{boxes:a(t)}},dref:function(t){return{version:t[0],flags:new Uint8Array(t.subarray(1,4)),dataReferences:a(t.subarray(8))}},hdlr:function(t){var e=new DataView(t.buffer,t.byteOffset,t.byteLength),i={version:e.getUint8(0),flags:new Uint8Array(t.subarray(1,4)),handlerType:h(t.subarray(8,12)),name:""},a=8;for(a=24;a<t.byteLength;a++){if(t[a]===0){a++;break}i.name+=String.fromCharCode(t[a])}i.name=decodeURIComponent(escape(i.name));return i},mdat:function(t){return{byteLength:t.byteLength,nals:n(t)}},mdhd:function(t){var e=new DataView(t.buffer,t.byteOffset,t.byteLength),i=4,a,n={version:e.getUint8(0),flags:new Uint8Array(t.subarray(1,4)),language:""};if(n.version===1){i+=4;n.creationTime=r(e.getUint32(i));i+=8;n.modificationTime=r(e.getUint32(i));i+=4;n.timescale=e.getUint32(i);i+=8;n.duration=e.getUint32(i)}else{n.creationTime=r(e.getUint32(i));i+=4;n.modificationTime=r(e.getUint32(i));i+=4;n.timescale=e.getUint32(i);i+=4;n.duration=e.getUint32(i)}i+=4;a=e.getUint16(i);n.language+=String.fromCharCode((a>>10)+96);n.language+=String.fromCharCode(((a&992)>>5)+96);n.language+=String.fromCharCode((a&31)+96);return n},mdia:function(t){return{boxes:a(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:a(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};if(t.byteLength>28){i.streamDescriptor=a(t.subarray(28))[0]}return i},moof:function(t){return{boxes:a(t)}},moov:function(t){return{boxes:a(t)}},mvex:function(t){return{boxes:a(t)}},mvhd:function(t){var e=new DataView(t.buffer,t.byteOffset,t.byteLength),i=4,a={version:e.getUint8(0),flags:new Uint8Array(t.subarray(1,4))};if(a.version===1){i+=4;a.creationTime=r(e.getUint32(i));i+=8;a.modificationTime=r(e.getUint32(i));i+=4;a.timescale=e.getUint32(i);i+=8;a.duration=e.getUint32(i)}else{a.creationTime=r(e.getUint32(i));i+=4;a.modificationTime=r(e.getUint32(i));i+=4;a.timescale=e.getUint32(i);i+=4;a.duration=e.getUint32(i)}i+=4;a.rate=e.getUint16(i)+e.getUint16(i+2)/16;i+=4;a.volume=e.getUint8(i)+e.getUint8(i+1)/8;i+=2;i+=2;i+=2*4;a.matrix=new Uint32Array(t.subarray(i,i+9*4));i+=9*4;i+=6*4;a.nextTrackId=e.getUint32(i);return a},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={version:t[0],flags:new Uint8Array(t.subarray(1,4)),samples:[]},i;for(i=4;i<t.byteLength;i++){e.samples.push({dependsOn:(t[i]&48)>>4,isDependedOn:(t[i]&12)>>2,hasRedundancy:t[i]&3})}return e},sidx:function(t){var e=new DataView(t.buffer,t.byteOffset,t.byteLength),i={version:t[0],flags:new Uint8Array(t.subarray(1,4)),references:[],referenceId:e.getUint32(4),timescale:e.getUint32(8),earliestPresentationTime:e.getUint32(12),firstOffset:e.getUint32(16)},a=e.getUint16(22),n;for(n=24;a;n+=12,a--){i.references.push({referenceType:(t[n]&128)>>>7,referencedSize:e.getUint32(n)&2147483647,subsegmentDuration:e.getUint32(n+4),startsWithSap:!!(t[n+8]&128),sapType:(t[n+8]&112)>>>4,sapDeltaTime:e.getUint32(n+8)&268435455})}return i},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:a(t)}},stco:function(t){var e=new DataView(t.buffer,t.byteOffset,t.byteLength),i={version:t[0],flags:new Uint8Array(t.subarray(1,4)),chunkOffsets:[]},a=e.getUint32(4),n;for(n=8;a;n+=4,a--){i.chunkOffsets.push(e.getUint32(n))}return i},stsc:function(t){var e=new DataView(t.buffer,t.byteOffset,t.byteLength),i=e.getUint32(4),a={version:t[0],flags:new Uint8Array(t.subarray(1,4)),sampleToChunks:[]},n;for(n=8;i;n+=12,i--){a.sampleToChunks.push({firstChunk:e.getUint32(n),samplesPerChunk:e.getUint32(n+4),sampleDescriptionIndex:e.getUint32(n+8)})}return a},stsd:function(t){return{version:t[0],flags:new Uint8Array(t.subarray(1,4)),sampleDescriptions:a(t.subarray(8))}},stsz:function(t){var e=new DataView(t.buffer,t.byteOffset,t.byteLength),i={version:t[0],flags:new Uint8Array(t.subarray(1,4)),sampleSize:e.getUint32(4),entries:[]},a;for(a=12;a<t.byteLength;a+=4){i.entries.push(e.getUint32(a))}return i},stts:function(t){var e=new DataView(t.buffer,t.byteOffset,t.byteLength),i={version:t[0],flags:new Uint8Array(t.subarray(1,4)),timeToSamples:[]},a=e.getUint32(4),n;for(n=8;a;n+=8,a--){i.timeToSamples.push({sampleCount:e.getUint32(n),sampleDelta:e.getUint32(n+4)})}return i},styp:function(t){return l.ftyp(t)},tfdt:function(t){var e={version:t[0],flags:new Uint8Array(t.subarray(1,4)),baseMediaDecodeTime:t[4]<<24|t[5]<<16|t[6]<<8|t[7]};if(e.version===1){e.baseMediaDecodeTime*=Math.pow(2,32);e.baseMediaDecodeTime+=t[8]<<24|t[9]<<16|t[10]<<8|t[11]}return e},tfhd:function(t){var e=new DataView(t.buffer,t.byteOffset,t.byteLength),i={version:t[0],flags:new Uint8Array(t.subarray(1,4)),trackId:e.getUint32(4)},a=i.flags[2]&1,n=i.flags[2]&2,r=i.flags[2]&8,s=i.flags[2]&16,o=i.flags[2]&32,u=i.flags[0]&65536,p=i.flags[0]&131072,d;d=8;if(a){d+=4;i.baseDataOffset=e.getUint32(12);d+=4}if(n){i.sampleDescriptionIndex=e.getUint32(d);d+=4}if(r){i.defaultSampleDuration=e.getUint32(d);d+=4}if(s){i.defaultSampleSize=e.getUint32(d);d+=4}if(o){i.defaultSampleFlags=e.getUint32(d)}if(u){i.durationIsEmpty=true}if(!a&&p){i.baseDataOffsetIsMoof=true}return i},tkhd:function(t){var e=new DataView(t.buffer,t.byteOffset,t.byteLength),i=4,a={version:e.getUint8(0),flags:new Uint8Array(t.subarray(1,4))};if(a.version===1){i+=4;a.creationTime=r(e.getUint32(i));i+=8;a.modificationTime=r(e.getUint32(i));i+=4;a.trackId=e.getUint32(i);i+=4;i+=8;a.duration=e.getUint32(i)}else{a.creationTime=r(e.getUint32(i));i+=4;a.modificationTime=r(e.getUint32(i));i+=4;a.trackId=e.getUint32(i);i+=4;i+=4;a.duration=e.getUint32(i)}i+=4;i+=2*4;a.layer=e.getUint16(i);i+=2;a.alternateGroup=e.getUint16(i);i+=2;a.volume=e.getUint8(i)+e.getUint8(i+1)/8;i+=2;i+=2;a.matrix=new Uint32Array(t.subarray(i,i+9*4));i+=9*4;a.width=e.getUint16(i)+e.getUint16(i+2)/16;i+=4;a.height=e.getUint16(i)+e.getUint16(i+2)/16;return a},traf:function(t){return{boxes:a(t)}},trak:function(t){return{boxes:a(t)}},trex:function(t){var e=new DataView(t.buffer,t.byteOffset,t.byteLength);return{version:t[0],flags:new Uint8Array(t.subarray(1,4)),trackId:e.getUint32(4),defaultSampleDescriptionIndex:e.getUint32(8),defaultSampleDuration:e.getUint32(12),defaultSampleSize:e.getUint32(16),sampleDependsOn:t[20]&3,sampleIsDependedOn:(t[21]&192)>>6,sampleHasRedundancy:(t[21]&48)>>4,samplePaddingValue:(t[21]&14)>>1,sampleIsDifferenceSample:!!(t[21]&1),sampleDegradationPriority:e.getUint16(22)}},trun:function(t){var e={version:t[0],flags:new Uint8Array(t.subarray(1,4)),samples:[]},i=new DataView(t.buffer,t.byteOffset,t.byteLength),a=e.flags[2]&1,n=e.flags[2]&4,r=e.flags[1]&1,s=e.flags[1]&2,o=e.flags[1]&4,u=e.flags[1]&8,p=i.getUint32(4),d=8,h;if(a){e.dataOffset=i.getInt32(d);d+=4}if(n&&p){h={flags:f(t.subarray(d,d+4))};d+=4;if(r){h.duration=i.getUint32(d);d+=4}if(s){h.size=i.getUint32(d);d+=4}if(u){h.compositionTimeOffset=i.getUint32(d);d+=4}e.samples.push(h);p--}while(p--){h={};if(r){h.duration=i.getUint32(d);d+=4}if(s){h.size=i.getUint32(d);d+=4}if(o){h.flags=f(t.subarray(d,d+4));d+=4}if(u){h.compositionTimeOffset=i.getUint32(d);d+=4}e.samples.push(h)}return e},"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)])}}};a=function(t){var e=0,i=[],a,n,r,s,o;var u=new ArrayBuffer(t.length);var p=new Uint8Array(u);for(var d=0;d<t.length;++d){p[d]=t[d]}a=new DataView(u);while(e<t.byteLength){n=a.getUint32(e);r=h(t.subarray(e+4,e+8));s=n>1?e+n:t.byteLength;o=(l[r]||function(t){return{data:t}})(t.subarray(e+8,s));o.size=n;o.type=r;i.push(o);e=s}return i};s=function(t,e){var r;e=e||0;r=new Array(e*2+1).join(" ");return t.map(function(n,t){return r+n.type+"\n"+Object.keys(n).filter(function(t){return t!=="type"&&t!=="boxes"}).map(function(t){var e=r+"  "+t+": ",i=n[t];if(i instanceof Uint8Array||i instanceof Uint32Array){var a=Array.prototype.slice.call(new Uint8Array(i.buffer,i.byteOffset,i.byteLength)).map(function(t){return" "+("00"+t.toString(16)).slice(-2)}).join("").match(/.{1,24}/g);if(!a){return e+"<>"}if(a.length===1){return e+"<"+a.join("").slice(1)+">"}return e+"<\n"+a.map(function(t){return r+"  "+t}).join("\n")+"\n"+r+"  >"}return e+JSON.stringify(i,null,2).split("\n").map(function(t,e){if(e===0){return t}return r+"  "+t}).join("\n")}).join("\n")+(n.boxes?"\n"+s(n.boxes,e+1):"")}).join("\n")};e.exports={inspect:a,textify:s,parseTfdt:l.tfdt,parseHdlr:l.hdlr,parseTfhd:l.tfhd,parseTrun:l.trun,parseSidx:l.sidx}},{"../mp4/probe":26}],32:[function(t,e,i){"use strict";var r=t("../m2ts/stream-types.js");var s=t("../m2ts/timestamp-rollover-stream.js").handleRollover;var g={};g.ts=t("../m2ts/probe.js");g.aac=t("../aac/utils.js");var h=9e4,y=188,b=71;var o=function(t,e){var i=0,a=y,n,r;while(a<t.byteLength){if(t[i]===b&&t[a]===b){n=t.subarray(i,a);r=g.ts.parseType(n,e.pid);switch(r){case"pat":if(!e.pid){e.pid=g.ts.parsePat(n)}break;case"pmt":if(!e.table){e.table=g.ts.parsePmt(n)}break;default:break}if(e.pid&&e.table){return}i+=y;a+=y;continue}i++;a++}};var u=function(t,e,i){var a=0,n=y,r,s,o,u,p;var d=false;while(n<=t.byteLength){if(t[a]===b&&(t[n]===b||n===t.byteLength)){r=t.subarray(a,n);s=g.ts.parseType(r,e.pid);switch(s){case"pes":o=g.ts.parsePesType(r,e.table);u=g.ts.parsePayloadUnitStartIndicator(r);if(o==="audio"&&u){p=g.ts.parsePesTime(r);if(p){p.type="audio";i.audio.push(p);d=true}}break;default:break}if(d){break}a+=y;n+=y;continue}a++;n++}n=t.byteLength;a=n-y;d=false;while(a>=0){if(t[a]===b&&(t[n]===b||n===t.byteLength)){r=t.subarray(a,n);s=g.ts.parseType(r,e.pid);switch(s){case"pes":o=g.ts.parsePesType(r,e.table);u=g.ts.parsePayloadUnitStartIndicator(r);if(o==="audio"&&u){p=g.ts.parsePesTime(r);if(p){p.type="audio";i.audio.push(p);d=true}}break;default:break}if(d){break}a-=y;n-=y;continue}a--;n--}};var p=function(t,e,i){var a=0,n=y,r,s,o,u,p,d,h,f;var l=false;var c={data:[],size:0};while(n<t.byteLength){if(t[a]===b&&t[n]===b){r=t.subarray(a,n);s=g.ts.parseType(r,e.pid);switch(s){case"pes":o=g.ts.parsePesType(r,e.table);u=g.ts.parsePayloadUnitStartIndicator(r);if(o==="video"){if(u&&!l){p=g.ts.parsePesTime(r);if(p){p.type="video";i.video.push(p);l=true}}if(!i.firstKeyFrame){if(u){if(c.size!==0){d=new Uint8Array(c.size);h=0;while(c.data.length){f=c.data.shift();d.set(f,h);h+=f.byteLength}if(g.ts.videoPacketContainsKeyFrame(d)){var m=g.ts.parsePesTime(d);if(m){i.firstKeyFrame=m;i.firstKeyFrame.type="video"}else{console.warn("Failed to extract PTS/DTS from PES at first keyframe. "+"This could be an unusual TS segment, or else mux.js did not "+"parse your TS segment correctly. If you know your TS "+"segments do contain PTS/DTS on keyframes please file a bug "+"report! You can try ffprobe to double check for yourself.")}}c.size=0}}c.data.push(r);c.size+=r.byteLength}}break;default:break}if(l&&i.firstKeyFrame){break}a+=y;n+=y;continue}a++;n++}n=t.byteLength;a=n-y;l=false;while(a>=0){if(t[a]===b&&t[n]===b){r=t.subarray(a,n);s=g.ts.parseType(r,e.pid);switch(s){case"pes":o=g.ts.parsePesType(r,e.table);u=g.ts.parsePayloadUnitStartIndicator(r);if(o==="video"&&u){p=g.ts.parsePesTime(r);if(p){p.type="video";i.video.push(p);l=true}}break;default:break}if(l){break}a-=y;n-=y;continue}a--;n--}};var n=function(t,e){if(t.audio&&t.audio.length){var i=e;if(typeof i==="undefined"){i=t.audio[0].dts}t.audio.forEach(function(t){t.dts=s(t.dts,i);t.pts=s(t.pts,i);t.dtsTime=t.dts/h;t.ptsTime=t.pts/h})}if(t.video&&t.video.length){var a=e;if(typeof a==="undefined"){a=t.video[0].dts}t.video.forEach(function(t){t.dts=s(t.dts,a);t.pts=s(t.pts,a);t.dtsTime=t.dts/h;t.ptsTime=t.pts/h});if(t.firstKeyFrame){var n=t.firstKeyFrame;n.dts=s(n.dts,a);n.pts=s(n.pts,a);n.dtsTime=n.dts/h;n.ptsTime=n.dts/h}}};var d=function(t){var e=false,i=0,a=null,n=null,r=0,s=0,o;while(t.length-s>=3){var u=g.aac.parseType(t,s);switch(u){case"timed-metadata":if(t.length-s<10){e=true;break}r=g.aac.parseId3TagSize(t,s);if(r>t.length){e=true;break}if(n===null){o=t.subarray(s,s+r);n=g.aac.parseAacTimestamp(o)}s+=r;break;case"audio":if(t.length-s<7){e=true;break}r=g.aac.parseAdtsSize(t,s);if(r>t.length){e=true;break}if(a===null){o=t.subarray(s,s+r);a=g.aac.parseSampleRate(o)}i++;s+=r;break;default:s++;break}if(e){return null}}if(a===null||n===null){return null}var p=h/a;var d={audio:[{type:"audio",dts:n,pts:n},{type:"audio",dts:n+i*1024*p,pts:n+i*1024*p}]};return d};var f=function(t){var e={pid:null,table:null};var i={};o(t,e);for(var a in e.table){if(e.table.hasOwnProperty(a)){var n=e.table[a];switch(n){case r.H264_STREAM_TYPE:i.video=[];p(t,e,i);if(i.video.length===0){delete i.video}break;case r.ADTS_STREAM_TYPE:i.audio=[];u(t,e,i);if(i.audio.length===0){delete i.audio}break;default:break}}}return i};var a=function(t,e){var i=g.aac.isLikelyAacData(t);var a;if(i){a=d(t)}else{a=f(t)}if(!a||!a.audio&&!a.video){return null}n(a,e);return a};e.exports={inspect:a,parseAudioPes_:u}},{"../aac/utils.js":2,"../m2ts/probe.js":18,"../m2ts/stream-types.js":19,"../m2ts/timestamp-rollover-stream.js":20}],33:[function(t,e,i){var a=function(t){return t>>>0};e.exports={toUnsigned:a}},{}],34:[function(t,e,i){var a=9e4,n,r,s,o,u,p;n=function(t){return t*a};r=function(t,e){return t*e};s=function(t){return t/a};o=function(t,e){return t/e};u=function(t,e){return n(o(t,e))};p=function(t,e){return r(s(t),e)};e.exports={secondsToVideoTs:n,secondsToAudioTs:r,videoTsToSeconds:s,audioTsToSeconds:o,audioTsToVideoTs:u,videoTsToAudioTs:p}},{}],35:[function(t,e,i){"use strict";var a;a=function(a){var n=a.byteLength,r=0,s=0;this.length=function(){return 8*n};this.bitsAvailable=function(){return 8*n+s};this.loadWord=function(){var t=a.byteLength-n,e=new Uint8Array(4),i=Math.min(4,n);if(i===0){throw new Error("no bytes available")}e.set(a.subarray(t,t+i));r=new DataView(e.buffer).getUint32(0);s=i*8;n-=i};this.skipBits=function(t){var e;if(s>t){r<<=t;s-=t}else{t-=s;e=Math.floor(t/8);t-=e*8;n-=e;this.loadWord();r<<=t;s-=t}};this.readBits=function(t){var e=Math.min(s,t),i=r>>>32-e;s-=e;if(s>0){r<<=e}else if(n>0){this.loadWord()}e=t-e;if(e>0){return i<<e|this.readBits(e)}return i};this.skipLeadingZeros=function(){var t;for(t=0;t<s;++t){if((r&2147483648>>>t)!==0){r<<=t;s-=t;return t}}this.loadWord();return 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();if(1&t){return 1+t>>>1}return-1*(t>>>1)};this.readBoolean=function(){return this.readBits(1)===1};this.readUnsignedByte=function(){return this.readBits(8)};this.loadWord()};e.exports=a},{}],36:[function(t,e,i){"use strict";var a=function(){this.init=function(){var r={};this.on=function(t,e){if(!r[t]){r[t]=[]}r[t]=r[t].concat(e)};this.off=function(t,e){var i;if(!r[t]){return false}i=r[t].indexOf(e);r[t]=r[t].slice();r[t].splice(i,1);return i>-1};this.trigger=function(t){var e,i,a,n;e=r[t];if(!e){return}if(arguments.length===2){a=e.length;for(i=0;i<a;++i){e[i].call(this,arguments[1])}}else{n=[];i=arguments.length;for(i=1;i<arguments.length;++i){n.push(arguments[i])}a=e.length;for(i=0;i<a;++i){e[i].apply(this,n)}}};this.dispose=function(){r={}}}};a.prototype.pipe=function(e){this.on("data",function(t){e.push(t)});this.on("done",function(t){e.flush(t)});return e};a.prototype.push=function(t){this.trigger("data",t)};a.prototype.flush=function(t){this.trigger("done",t)};e.exports=a},{}]},{},[13])(13)});