Socket
Socket
Sign inDemoInstall

mux.js

Package Overview
Dependencies
Maintainers
16
Versions
103
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mux.js - npm Package Compare versions

Comparing version 5.12.2 to 5.13.0

12

CHANGELOG.md

@@ -0,1 +1,13 @@

<a name="5.13.0"></a>
# [5.13.0](https://github.com/videojs/mux.js/compare/v5.12.2...v5.13.0) (2021-08-24)
### Features
* add firstSequenceNumber option to Transmuxer to start sequence somewhere other than zero ([#395](https://github.com/videojs/mux.js/issues/395)) ([6ff42f4](https://github.com/videojs/mux.js/commit/6ff42f4))
### Chores
* add github release ci action ([#397](https://github.com/videojs/mux.js/issues/397)) ([abe7936](https://github.com/videojs/mux.js/commit/abe7936))
* update ci workflow to fix ci ([#396](https://github.com/videojs/mux.js/issues/396)) ([86cfdca](https://github.com/videojs/mux.js/commit/86cfdca))
<a name="5.12.2"></a>

@@ -2,0 +14,0 @@ ## [5.12.2](https://github.com/videojs/mux.js/compare/v5.12.1...v5.12.2) (2021-07-14)

6

cjs/mp4/transmuxer.js

@@ -99,3 +99,3 @@ /**

var adtsFrames = [],
sequenceNumber = 0,
sequenceNumber,
earliestAllowedDts = 0,

@@ -105,2 +105,3 @@ audioAppendStartTs = 0,

options = options || {};
sequenceNumber = options.firstSequenceNumber || 0;

@@ -205,3 +206,3 @@ _AudioSegmentStream.prototype.init.call(this);

_VideoSegmentStream = function VideoSegmentStream(track, options) {
var sequenceNumber = 0,
var sequenceNumber,
nalUnits = [],

@@ -212,2 +213,3 @@ gopsToAlignWith = [],

options = options || {};
sequenceNumber = options.firstSequenceNumber || 0;

@@ -214,0 +216,0 @@ _VideoSegmentStream.prototype.init.call(this);

@@ -1,2 +0,2 @@

/*! @name mux.js @version 5.12.2 @license Apache-2.0 */
/*! @name mux.js @version 5.13.0 @license Apache-2.0 */
!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?module.exports=i():"function"==typeof define&&define.amd?define(i):(t="undefined"!=typeof globalThis?globalThis:t||self).muxjs=i()}(this,(function(){"use strict";var t;(t=function(i,e){var s,a=0,n=16384,r=function(t,i){var e,s=t.position+i;s<t.bytes.byteLength||((e=new Uint8Array(2*s)).set(t.bytes.subarray(0,t.position),0),t.bytes=e,t.view=new DataView(t.bytes.buffer))},o=t.widthBytes||new Uint8Array("width".length),h=t.heightBytes||new Uint8Array("height".length),p=t.videocodecidBytes||new Uint8Array("videocodecid".length);if(!t.widthBytes){for(s=0;s<"width".length;s++)o[s]="width".charCodeAt(s);for(s=0;s<"height".length;s++)h[s]="height".charCodeAt(s);for(s=0;s<"videocodecid".length;s++)p[s]="videocodecid".charCodeAt(s);t.widthBytes=o,t.heightBytes=h,t.videocodecidBytes=p}switch(this.keyFrame=!1,i){case t.VIDEO_TAG:this.length=16,n*=6;break;case t.AUDIO_TAG:this.length=13,this.keyFrame=!0;break;case t.METADATA_TAG:this.length=29,this.keyFrame=!0;break;default:throw new Error("Unknown FLV tag type")}this.bytes=new Uint8Array(n),this.view=new DataView(this.bytes.buffer),this.bytes[0]=i,this.position=this.length,this.keyFrame=e,this.pts=0,this.dts=0,this.writeBytes=function(t,i,e){var s,a=i||0;s=a+(e=e||t.byteLength),r(this,e),this.bytes.set(t.subarray(a,s),this.position),this.position+=e,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(){return 0===a?0: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 i,e;this.length===a+4?this.length-=4:a>0&&(i=a+4,e=this.length-i,this.position=a,this.view.setUint32(this.position,e),this.position=this.length,t&&t.push(this.bytes.subarray(i,i+e))),a=0},this.writeMetaDataDouble=function(t,i){var e;if(r(this,2+t.length+9),this.view.setUint16(this.position,t.length),this.position+=2,"width"===t)this.bytes.set(o,this.position),this.position+=5;else if("height"===t)this.bytes.set(h,this.position),this.position+=6;else if("videocodecid"===t)this.bytes.set(p,this.position),this.position+=12;else for(e=0;e<t.length;e++)this.bytes[this.position]=t.charCodeAt(e),this.position++;this.position++,this.view.setFloat64(this.position,i),this.position+=8,this.length=Math.max(this.length,this.position),++a},this.writeMetaDataBoolean=function(t,i){var e;for(r(this,2),this.view.setUint16(this.position,t.length),this.position+=2,e=0;e<t.length;e++)r(this,1),this.bytes[this.position]=t.charCodeAt(e),this.position++;r(this,2),this.view.setUint8(this.position,1),this.position++,this.view.setUint8(this.position,i?1:0),this.position++,this.length=Math.max(this.length,this.position),++a},this.finalize=function(){var i,s;switch(this.bytes[0]){case t.VIDEO_TAG:this.bytes[11]=7|(this.keyFrame||e?16:32),this.bytes[12]=e?0:1,i=this.pts-this.dts,this.bytes[13]=(16711680&i)>>>16,this.bytes[14]=(65280&i)>>>8,this.bytes[15]=(255&i)>>>0;break;case t.AUDIO_TAG:this.bytes[11]=175,this.bytes[12]=e?0:1;break;case t.METADATA_TAG:this.position=11,this.view.setUint8(this.position,2),this.position++,this.view.setUint16(this.position,10),this.position+=2,this.bytes.set([111,110,77,101,116,97,68,97,116,97],this.position),this.position+=10,this.bytes[this.position]=8,this.position++,this.view.setUint32(this.position,a),this.position=this.length,this.bytes.set([0,0,9],this.position),this.position+=3,this.length=this.position}return s=this.length-11,this.bytes[1]=(16711680&s)>>>16,this.bytes[2]=(65280&s)>>>8,this.bytes[3]=(255&s)>>>0,this.bytes[4]=(16711680&this.dts)>>>16,this.bytes[5]=(65280&this.dts)>>>8,this.bytes[6]=(255&this.dts)>>>0,this.bytes[7]=(4278190080&this.dts)>>>24,this.bytes[8]=0,this.bytes[9]=0,this.bytes[10]=0,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=t.frameTime(this.bytes),this}}).AUDIO_TAG=8,t.VIDEO_TAG=9,t.METADATA_TAG=18,t.isAudioFrame=function(i){return t.AUDIO_TAG===i[0]},t.isVideoFrame=function(i){return t.VIDEO_TAG===i[0]},t.isMetaData=function(i){return t.METADATA_TAG===i[0]},t.isKeyFrame=function(i){return t.isVideoFrame(i)?23===i[11]:!!t.isAudioFrame(i)||!!t.isMetaData(i)},t.frameTime=function(t){var i=t[4]<<16;return i|=t[5]<<8,i|=t[6]<<0,i|=t[7]<<24};var i=t,e=function(){this.init=function(){var t={};this.on=function(i,e){t[i]||(t[i]=[]),t[i]=t[i].concat(e)},this.off=function(i,e){var s;return!!t[i]&&(s=t[i].indexOf(e),t[i]=t[i].slice(),t[i].splice(s,1),s>-1)},this.trigger=function(i){var e,s,a,n;if(e=t[i])if(2===arguments.length)for(a=e.length,s=0;s<a;++s)e[s].call(this,arguments[1]);else{for(n=[],s=arguments.length,s=1;s<arguments.length;++s)n.push(arguments[s]);for(a=e.length,s=0;s<a;++s)e[s].apply(this,n)}},this.dispose=function(){t={}}}};e.prototype.pipe=function(t){return this.on("data",(function(i){t.push(i)})),this.on("done",(function(i){t.flush(i)})),this.on("partialdone",(function(i){t.partialFlush(i)})),this.on("endedtimeline",(function(i){t.endTimeline(i)})),this.on("reset",(function(i){t.reset(i)})),t},e.prototype.push=function(t){this.trigger("data",t)},e.prototype.flush=function(t){this.trigger("done",t)},e.prototype.partialFlush=function(t){this.trigger("partialdone",t)},e.prototype.endTimeline=function(t){this.trigger("endedtimeline",t)},e.prototype.reset=function(t){this.trigger("reset",t)};var s=e,a=function(t){for(var i=0,e={payloadType:-1,payloadSize:0},s=0,a=0;i<t.byteLength&&128!==t[i];){for(;255===t[i];)s+=255,i++;for(s+=t[i++];255===t[i];)a+=255,i++;if(a+=t[i++],!e.payload&&4===s){if("GA94"===String.fromCharCode(t[i+3],t[i+4],t[i+5],t[i+6])){e.payloadType=s,e.payloadSize=a,e.payload=t.subarray(i,i+a);break}e.payload=void 0}i+=a,s=0,a=0}return e},n=function(t){return 181!==t.payload[0]||49!=(t.payload[1]<<8|t.payload[2])||"GA94"!==String.fromCharCode(t.payload[3],t.payload[4],t.payload[5],t.payload[6])||3!==t.payload[7]?null:t.payload.subarray(8,t.payload.length-1)},r=function(t,i){var e,s,a,n,r=[];if(!(64&i[0]))return r;for(s=31&i[0],e=0;e<s;e++)n={type:3&i[(a=3*e)+2],pts:t},4&i[a+2]&&(n.ccData=i[a+3]<<8|i[a+4],r.push(n));return r},o=4,h=function t(i){i=i||{},t.prototype.init.call(this),this.parse708captions_="boolean"!=typeof i.parse708captions||i.parse708captions,this.captionPackets_=[],this.ccStreams_=[new _(0,0),new _(0,1),new _(1,0),new _(1,1)],this.parse708captions_&&(this.cc708Stream_=new u),this.reset(),this.ccStreams_.forEach((function(t){t.on("data",this.trigger.bind(this,"data")),t.on("partialdone",this.trigger.bind(this,"partialdone")),t.on("done",this.trigger.bind(this,"done"))}),this),this.parse708captions_&&(this.cc708Stream_.on("data",this.trigger.bind(this,"data")),this.cc708Stream_.on("partialdone",this.trigger.bind(this,"partialdone")),this.cc708Stream_.on("done",this.trigger.bind(this,"done")))};(h.prototype=new s).push=function(t){var i,e,s;if("sei_rbsp"===t.nalUnitType&&(i=a(t.escapedRBSP)).payload&&i.payloadType===o&&(e=n(i)))if(t.dts<this.latestDts_)this.ignoreNextEqualDts_=!0;else{if(t.dts===this.latestDts_&&this.ignoreNextEqualDts_)return this.numSameDts_--,void(this.numSameDts_||(this.ignoreNextEqualDts_=!1));s=r(t.pts,e),this.captionPackets_=this.captionPackets_.concat(s),this.latestDts_!==t.dts&&(this.numSameDts_=0),this.numSameDts_++,this.latestDts_=t.dts}},h.prototype.flushCCStreams=function(t){this.ccStreams_.forEach((function(i){return"flush"===t?i.flush():i.partialFlush()}),this)},h.prototype.flushStream=function(t){this.captionPackets_.length?(this.captionPackets_.forEach((function(t,i){t.presortIndex=i})),this.captionPackets_.sort((function(t,i){return t.pts===i.pts?t.presortIndex-i.presortIndex:t.pts-i.pts})),this.captionPackets_.forEach((function(t){t.type<2?this.dispatchCea608Packet(t):this.dispatchCea708Packet(t)}),this),this.captionPackets_.length=0,this.flushCCStreams(t)):this.flushCCStreams(t)},h.prototype.flush=function(){return this.flushStream("flush")},h.prototype.partialFlush=function(){return this.flushStream("partialFlush")},h.prototype.reset=function(){this.latestDts_=null,this.ignoreNextEqualDts_=!1,this.numSameDts_=0,this.activeCea608Channel_=[null,null],this.ccStreams_.forEach((function(t){t.reset()}))},h.prototype.dispatchCea608Packet=function(t){this.setsTextOrXDSActive(t)?this.activeCea608Channel_[t.type]=null:this.setsChannel1Active(t)?this.activeCea608Channel_[t.type]=0:this.setsChannel2Active(t)&&(this.activeCea608Channel_[t.type]=1),null!==this.activeCea608Channel_[t.type]&&this.ccStreams_[(t.type<<1)+this.activeCea608Channel_[t.type]].push(t)},h.prototype.setsChannel1Active=function(t){return 4096==(30720&t.ccData)},h.prototype.setsChannel2Active=function(t){return 6144==(30720&t.ccData)},h.prototype.setsTextOrXDSActive=function(t){return 256==(28928&t.ccData)||4138==(30974&t.ccData)||6186==(30974&t.ccData)},h.prototype.dispatchCea708Packet=function(t){this.parse708captions_&&this.cc708Stream_.push(t)};var p={127:9834,4128:32,4129:160,4133:8230,4138:352,4140:338,4144:9608,4145:8216,4146:8217,4147:8220,4148:8221,4149:8226,4153:8482,4154:353,4156:339,4157:8480,4159:376,4214:8539,4215:8540,4216:8541,4217:8542,4218:9168,4219:9124,4220:9123,4221:9135,4222:9126,4223:9121,4256:12600},d=function(t){return 32<=t&&t<=127||160<=t&&t<=255},l=function(t){this.windowNum=t,this.reset()};l.prototype.reset=function(){this.clearText(),this.pendingNewLine=!1,this.winAttr={},this.penAttr={},this.penLoc={},this.penColor={},this.visible=0,this.rowLock=0,this.columnLock=0,this.priority=0,this.relativePositioning=0,this.anchorVertical=0,this.anchorHorizontal=0,this.anchorPoint=0,this.rowCount=1,this.virtualRowCount=this.rowCount+1,this.columnCount=41,this.windowStyle=0,this.penStyle=0},l.prototype.getText=function(){return this.rows.join("\n")},l.prototype.clearText=function(){this.rows=[""],this.rowIdx=0},l.prototype.newLine=function(t){for(this.rows.length>=this.virtualRowCount&&"function"==typeof this.beforeRowOverflow&&this.beforeRowOverflow(t),this.rows.length>0&&(this.rows.push(""),this.rowIdx++);this.rows.length>this.virtualRowCount;)this.rows.shift(),this.rowIdx--},l.prototype.isEmpty=function(){return 0===this.rows.length||1===this.rows.length&&""===this.rows[0]},l.prototype.addText=function(t){this.rows[this.rowIdx]+=t},l.prototype.backspace=function(){if(!this.isEmpty()){var t=this.rows[this.rowIdx];this.rows[this.rowIdx]=t.substr(0,t.length-1)}};var c=function(t){this.serviceNum=t,this.text="",this.currentWindow=new l(-1),this.windows=[]};c.prototype.init=function(t,i){this.startPts=t;for(var e=0;e<8;e++)this.windows[e]=new l(e),"function"==typeof i&&(this.windows[e].beforeRowOverflow=i)},c.prototype.setCurrentWindow=function(t){this.currentWindow=this.windows[t]};var u=function t(){t.prototype.init.call(this);var i=this;this.current708Packet=null,this.services={},this.push=function(t){3===t.type?(i.new708Packet(),i.add708Bytes(t)):(null===i.current708Packet&&i.new708Packet(),i.add708Bytes(t))}};u.prototype=new s,u.prototype.new708Packet=function(){null!==this.current708Packet&&this.push708Packet(),this.current708Packet={data:[],ptsVals:[]}},u.prototype.add708Bytes=function(t){var i=t.ccData,e=i>>>8,s=255&i;this.current708Packet.ptsVals.push(t.pts),this.current708Packet.data.push(e),this.current708Packet.data.push(s)},u.prototype.push708Packet=function(){var t=this.current708Packet,i=t.data,e=null,s=null,a=0,n=i[a++];for(t.seq=n>>6,t.sizeCode=63&n;a<i.length;a++)s=31&(n=i[a++]),7===(e=n>>5)&&s>0&&(e=n=i[a++]),this.pushServiceBlock(e,a,s),s>0&&(a+=s-1)},u.prototype.pushServiceBlock=function(t,i,e){var s,a=i,n=this.current708Packet.data,r=this.services[t];for(r||(r=this.initService(t,a));a<i+e&&a<n.length;a++)s=n[a],d(s)?a=this.handleText(a,r):16===s?a=this.extendedCommands(a,r):128<=s&&s<=135?a=this.setCurrentWindow(a,r):152<=s&&s<=159?a=this.defineWindow(a,r):136===s?a=this.clearWindows(a,r):140===s?a=this.deleteWindows(a,r):137===s?a=this.displayWindows(a,r):138===s?a=this.hideWindows(a,r):139===s?a=this.toggleWindows(a,r):151===s?a=this.setWindowAttributes(a,r):144===s?a=this.setPenAttributes(a,r):145===s?a=this.setPenColor(a,r):146===s?a=this.setPenLocation(a,r):143===s?r=this.reset(a,r):8===s?r.currentWindow.backspace():12===s?r.currentWindow.clearText():13===s?r.currentWindow.pendingNewLine=!0:14===s?r.currentWindow.clearText():141===s&&a++},u.prototype.extendedCommands=function(t,i){var e=this.current708Packet.data[++t];return d(e)&&(t=this.handleText(t,i,!0)),t},u.prototype.getPts=function(t){return this.current708Packet.ptsVals[Math.floor(t/2)]},u.prototype.initService=function(t,i){var e=this;return this.services[t]=new c(t),this.services[t].init(this.getPts(i),(function(i){e.flushDisplayed(i,e.services[t])})),this.services[t]},u.prototype.handleText=function(t,i,e){var s,a,n=this.current708Packet.data[t],r=(a=p[s=(e?4096:0)|n]||s,4096&s&&s===a?"":String.fromCharCode(a)),o=i.currentWindow;return o.pendingNewLine&&!o.isEmpty()&&o.newLine(this.getPts(t)),o.pendingNewLine=!1,o.addText(r),t},u.prototype.setCurrentWindow=function(t,i){var e=7&this.current708Packet.data[t];return i.setCurrentWindow(e),t},u.prototype.defineWindow=function(t,i){var e=this.current708Packet.data,s=e[t],a=7&s;i.setCurrentWindow(a);var n=i.currentWindow;return s=e[++t],n.visible=(32&s)>>5,n.rowLock=(16&s)>>4,n.columnLock=(8&s)>>3,n.priority=7&s,s=e[++t],n.relativePositioning=(128&s)>>7,n.anchorVertical=127&s,s=e[++t],n.anchorHorizontal=s,s=e[++t],n.anchorPoint=(240&s)>>4,n.rowCount=15&s,s=e[++t],n.columnCount=63&s,s=e[++t],n.windowStyle=(56&s)>>3,n.penStyle=7&s,n.virtualRowCount=n.rowCount+1,t},u.prototype.setWindowAttributes=function(t,i){var e=this.current708Packet.data,s=e[t],a=i.currentWindow.winAttr;return s=e[++t],a.fillOpacity=(192&s)>>6,a.fillRed=(48&s)>>4,a.fillGreen=(12&s)>>2,a.fillBlue=3&s,s=e[++t],a.borderType=(192&s)>>6,a.borderRed=(48&s)>>4,a.borderGreen=(12&s)>>2,a.borderBlue=3&s,s=e[++t],a.borderType+=(128&s)>>5,a.wordWrap=(64&s)>>6,a.printDirection=(48&s)>>4,a.scrollDirection=(12&s)>>2,a.justify=3&s,s=e[++t],a.effectSpeed=(240&s)>>4,a.effectDirection=(12&s)>>2,a.displayEffect=3&s,t},u.prototype.flushDisplayed=function(t,i){for(var e=[],s=0;s<8;s++)i.windows[s].visible&&!i.windows[s].isEmpty()&&e.push(i.windows[s].getText());i.endPts=t,i.text=e.join("\n\n"),this.pushCaption(i),i.startPts=t},u.prototype.pushCaption=function(t){""!==t.text&&(this.trigger("data",{startPts:t.startPts,endPts:t.endPts,text:t.text,stream:"cc708_"+t.serviceNum}),t.text="",t.startPts=t.endPts)},u.prototype.displayWindows=function(t,i){var e=this.current708Packet.data[++t],s=this.getPts(t);this.flushDisplayed(s,i);for(var a=0;a<8;a++)e&1<<a&&(i.windows[a].visible=1);return t},u.prototype.hideWindows=function(t,i){var e=this.current708Packet.data[++t],s=this.getPts(t);this.flushDisplayed(s,i);for(var a=0;a<8;a++)e&1<<a&&(i.windows[a].visible=0);return t},u.prototype.toggleWindows=function(t,i){var e=this.current708Packet.data[++t],s=this.getPts(t);this.flushDisplayed(s,i);for(var a=0;a<8;a++)e&1<<a&&(i.windows[a].visible^=1);return t},u.prototype.clearWindows=function(t,i){var e=this.current708Packet.data[++t],s=this.getPts(t);this.flushDisplayed(s,i);for(var a=0;a<8;a++)e&1<<a&&i.windows[a].clearText();return t},u.prototype.deleteWindows=function(t,i){var e=this.current708Packet.data[++t],s=this.getPts(t);this.flushDisplayed(s,i);for(var a=0;a<8;a++)e&1<<a&&i.windows[a].reset();return t},u.prototype.setPenAttributes=function(t,i){var e=this.current708Packet.data,s=e[t],a=i.currentWindow.penAttr;return s=e[++t],a.textTag=(240&s)>>4,a.offset=(12&s)>>2,a.penSize=3&s,s=e[++t],a.italics=(128&s)>>7,a.underline=(64&s)>>6,a.edgeType=(56&s)>>3,a.fontStyle=7&s,t},u.prototype.setPenColor=function(t,i){var e=this.current708Packet.data,s=e[t],a=i.currentWindow.penColor;return s=e[++t],a.fgOpacity=(192&s)>>6,a.fgRed=(48&s)>>4,a.fgGreen=(12&s)>>2,a.fgBlue=3&s,s=e[++t],a.bgOpacity=(192&s)>>6,a.bgRed=(48&s)>>4,a.bgGreen=(12&s)>>2,a.bgBlue=3&s,s=e[++t],a.edgeRed=(48&s)>>4,a.edgeGreen=(12&s)>>2,a.edgeBlue=3&s,t},u.prototype.setPenLocation=function(t,i){var e=this.current708Packet.data,s=e[t],a=i.currentWindow.penLoc;return i.currentWindow.pendingNewLine=!0,s=e[++t],a.row=15&s,s=e[++t],a.column=63&s,t},u.prototype.reset=function(t,i){var e=this.getPts(t);return this.flushDisplayed(e,i),this.initService(i.serviceNum,t)};var f={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},g=function(t){return null===t?"":(t=f[t]||t,String.fromCharCode(t))},y=[4352,4384,4608,4640,5376,5408,5632,5664,5888,5920,4096,4864,4896,5120,5152],m=function(){for(var t=[],i=15;i--;)t.push("");return t},_=function t(i,e){t.prototype.init.call(this),this.field_=i||0,this.dataChannel_=e||0,this.name_="CC"+(1+(this.field_<<1|this.dataChannel_)),this.setConstants(),this.reset(),this.push=function(t){var i,e,s,a,n;if((i=32639&t.ccData)!==this.lastControlCode_){if(4096==(61440&i)?this.lastControlCode_=i:i!==this.PADDING_&&(this.lastControlCode_=null),s=i>>>8,a=255&i,i!==this.PADDING_)if(i===this.RESUME_CAPTION_LOADING_)this.mode_="popOn";else if(i===this.END_OF_CAPTION_)this.mode_="popOn",this.clearFormatting(t.pts),this.flushDisplayed(t.pts),e=this.displayed_,this.displayed_=this.nonDisplayed_,this.nonDisplayed_=e,this.startPts_=t.pts;else if(i===this.ROLL_UP_2_ROWS_)this.rollUpRows_=2,this.setRollUp(t.pts);else if(i===this.ROLL_UP_3_ROWS_)this.rollUpRows_=3,this.setRollUp(t.pts);else if(i===this.ROLL_UP_4_ROWS_)this.rollUpRows_=4,this.setRollUp(t.pts);else if(i===this.CARRIAGE_RETURN_)this.clearFormatting(t.pts),this.flushDisplayed(t.pts),this.shiftRowsUp_(),this.startPts_=t.pts;else if(i===this.BACKSPACE_)"popOn"===this.mode_?this.nonDisplayed_[this.row_]=this.nonDisplayed_[this.row_].slice(0,-1):this.displayed_[this.row_]=this.displayed_[this.row_].slice(0,-1);else if(i===this.ERASE_DISPLAYED_MEMORY_)this.flushDisplayed(t.pts),this.displayed_=m();else if(i===this.ERASE_NON_DISPLAYED_MEMORY_)this.nonDisplayed_=m();else if(i===this.RESUME_DIRECT_CAPTIONING_)"paintOn"!==this.mode_&&(this.flushDisplayed(t.pts),this.displayed_=m()),this.mode_="paintOn",this.startPts_=t.pts;else if(this.isSpecialCharacter(s,a))n=g((s=(3&s)<<8)|a),this[this.mode_](t.pts,n),this.column_++;else if(this.isExtCharacter(s,a))"popOn"===this.mode_?this.nonDisplayed_[this.row_]=this.nonDisplayed_[this.row_].slice(0,-1):this.displayed_[this.row_]=this.displayed_[this.row_].slice(0,-1),n=g((s=(3&s)<<8)|a),this[this.mode_](t.pts,n),this.column_++;else if(this.isMidRowCode(s,a))this.clearFormatting(t.pts),this[this.mode_](t.pts," "),this.column_++,14==(14&a)&&this.addFormatting(t.pts,["i"]),1==(1&a)&&this.addFormatting(t.pts,["u"]);else if(this.isOffsetControlCode(s,a))this.column_+=3&a;else if(this.isPAC(s,a)){var r=y.indexOf(7968&i);"rollUp"===this.mode_&&(r-this.rollUpRows_+1<0&&(r=this.rollUpRows_-1),this.setRollUp(t.pts,r)),r!==this.row_&&(this.clearFormatting(t.pts),this.row_=r),1&a&&-1===this.formatting_.indexOf("u")&&this.addFormatting(t.pts,["u"]),16==(16&i)&&(this.column_=4*((14&i)>>1)),this.isColorPAC(a)&&14==(14&a)&&this.addFormatting(t.pts,["i"])}else this.isNormalChar(s)&&(0===a&&(a=null),n=g(s),n+=g(a),this[this.mode_](t.pts,n),this.column_+=n.length)}else this.lastControlCode_=null}};_.prototype=new s,_.prototype.flushDisplayed=function(t){var i=this.displayed_.map((function(t,i){try{return t.trim()}catch(t){return this.trigger("log",{level:"warn",message:"Skipping a malformed 608 caption at index "+i+"."}),""}}),this).join("\n").replace(/^\n+|\n+$/g,"");i.length&&this.trigger("data",{startPts:this.startPts_,endPts:t,text:i,stream:this.name_})},_.prototype.reset=function(){this.mode_="popOn",this.topRow_=0,this.startPts_=0,this.displayed_=m(),this.nonDisplayed_=m(),this.lastControlCode_=null,this.column_=0,this.row_=14,this.rollUpRows_=2,this.formatting_=[]},_.prototype.setConstants=function(){0===this.dataChannel_?(this.BASE_=16,this.EXT_=17,this.CONTROL_=(20|this.field_)<<8,this.OFFSET_=23):1===this.dataChannel_&&(this.BASE_=24,this.EXT_=25,this.CONTROL_=(28|this.field_)<<8,this.OFFSET_=31),this.PADDING_=0,this.RESUME_CAPTION_LOADING_=32|this.CONTROL_,this.END_OF_CAPTION_=47|this.CONTROL_,this.ROLL_UP_2_ROWS_=37|this.CONTROL_,this.ROLL_UP_3_ROWS_=38|this.CONTROL_,this.ROLL_UP_4_ROWS_=39|this.CONTROL_,this.CARRIAGE_RETURN_=45|this.CONTROL_,this.RESUME_DIRECT_CAPTIONING_=41|this.CONTROL_,this.BACKSPACE_=33|this.CONTROL_,this.ERASE_DISPLAYED_MEMORY_=44|this.CONTROL_,this.ERASE_NON_DISPLAYED_MEMORY_=46|this.CONTROL_},_.prototype.isSpecialCharacter=function(t,i){return t===this.EXT_&&i>=48&&i<=63},_.prototype.isExtCharacter=function(t,i){return(t===this.EXT_+1||t===this.EXT_+2)&&i>=32&&i<=63},_.prototype.isMidRowCode=function(t,i){return t===this.EXT_&&i>=32&&i<=47},_.prototype.isOffsetControlCode=function(t,i){return t===this.OFFSET_&&i>=33&&i<=35},_.prototype.isPAC=function(t,i){return t>=this.BASE_&&t<this.BASE_+8&&i>=64&&i<=127},_.prototype.isColorPAC=function(t){return t>=64&&t<=79||t>=96&&t<=127},_.prototype.isNormalChar=function(t){return t>=32&&t<=127},_.prototype.setRollUp=function(t,i){if("rollUp"!==this.mode_&&(this.row_=14,this.mode_="rollUp",this.flushDisplayed(t),this.nonDisplayed_=m(),this.displayed_=m()),void 0!==i&&i!==this.row_)for(var e=0;e<this.rollUpRows_;e++)this.displayed_[i-e]=this.displayed_[this.row_-e],this.displayed_[this.row_-e]="";void 0===i&&(i=this.row_),this.topRow_=i-this.rollUpRows_+1},_.prototype.addFormatting=function(t,i){this.formatting_=this.formatting_.concat(i);var e=i.reduce((function(t,i){return t+"<"+i+">"}),"");this[this.mode_](t,e)},_.prototype.clearFormatting=function(t){if(this.formatting_.length){var i=this.formatting_.reverse().reduce((function(t,i){return t+"</"+i+">"}),"");this.formatting_=[],this[this.mode_](t,i)}},_.prototype.popOn=function(t,i){var e=this.nonDisplayed_[this.row_];e+=i,this.nonDisplayed_[this.row_]=e},_.prototype.rollUp=function(t,i){var e=this.displayed_[this.row_];e+=i,this.displayed_[this.row_]=e},_.prototype.shiftRowsUp_=function(){var t;for(t=0;t<this.topRow_;t++)this.displayed_[t]="";for(t=this.row_+1;t<15;t++)this.displayed_[t]="";for(t=this.topRow_;t<this.row_;t++)this.displayed_[t]=this.displayed_[t+1];this.displayed_[this.row_]=""},_.prototype.paintOn=function(t,i){var e=this.displayed_[this.row_];e+=i,this.displayed_[this.row_]=e};var w={CaptionStream:h,Cea608Stream:_,Cea708Stream:u},b={H264_STREAM_TYPE:27,ADTS_STREAM_TYPE:15,METADATA_STREAM_TYPE:21},v="shared",T=function(t,i){var e=1;for(t>i&&(e=-1);Math.abs(i-t)>4294967296;)t+=8589934592*e;return t},k=function t(i){var e,s;t.prototype.init.call(this),this.type_=i||v,this.push=function(t){this.type_!==v&&t.type!==this.type_||(void 0===s&&(s=t.dts),t.dts=T(t.dts,s),t.pts=T(t.pts,s),e=t.dts,this.trigger("data",t))},this.flush=function(){s=e,this.trigger("done")},this.endTimeline=function(){this.flush(),this.trigger("endedtimeline")},this.discontinuity=function(){s=void 0,e=void 0},this.reset=function(){this.discontinuity(),this.trigger("reset")}};k.prototype=new s;var S,A=k,C=function(t,i,e){var s,a="";for(s=i;s<e;s++)a+="%"+("00"+t[s].toString(16)).slice(-2);return a},D=function(t,i,e){return decodeURIComponent(C(t,i,e))},P=function(t){return t[0]<<21|t[1]<<14|t[2]<<7|t[3]},E={TXXX:function(t){var i;if(3===t.data[0]){for(i=1;i<t.data.length;i++)if(0===t.data[i]){t.description=D(t.data,1,i),t.value=D(t.data,i+1,t.data.length).replace(/\0*$/,"");break}t.data=t.value}},WXXX:function(t){var i;if(3===t.data[0])for(i=1;i<t.data.length;i++)if(0===t.data[i]){t.description=D(t.data,1,i),t.url=D(t.data,i+1,t.data.length);break}},PRIV:function(t){var i,e;for(i=0;i<t.data.length;i++)if(0===t.data[i]){t.owner=(e=t.data,unescape(C(e,0,i)));break}t.privateData=t.data.subarray(i+1),t.data=t.privateData}};(S=function(t){var i,e={descriptor:t&&t.descriptor},s=0,a=[],n=0;if(S.prototype.init.call(this),this.dispatchType=b.METADATA_STREAM_TYPE.toString(16),e.descriptor)for(i=0;i<e.descriptor.length;i++)this.dispatchType+=("00"+e.descriptor[i].toString(16)).slice(-2);this.push=function(t){var i,e,r,o,h;if("timed-metadata"===t.type)if(t.dataAlignmentIndicator&&(n=0,a.length=0),0===a.length&&(t.data.length<10||t.data[0]!=="I".charCodeAt(0)||t.data[1]!=="D".charCodeAt(0)||t.data[2]!=="3".charCodeAt(0)))this.trigger("log",{level:"warn",message:"Skipping unrecognized metadata packet"});else if(a.push(t),n+=t.data.byteLength,1===a.length&&(s=P(t.data.subarray(6,10)),s+=10),!(n<s)){for(i={data:new Uint8Array(s),frames:[],pts:a[0].pts,dts:a[0].dts},h=0;h<s;)i.data.set(a[0].data.subarray(0,s-h),h),h+=a[0].data.byteLength,n-=a[0].data.byteLength,a.shift();e=10,64&i.data[5]&&(e+=4,e+=P(i.data.subarray(10,14)),s-=P(i.data.subarray(16,20)));do{if((r=P(i.data.subarray(e+4,e+8)))<1)return void this.trigger("log",{level:"warn",message:"Malformed ID3 frame encountered. Skipping metadata parsing."});if((o={id:String.fromCharCode(i.data[e],i.data[e+1],i.data[e+2],i.data[e+3]),data:i.data.subarray(e+10,e+r+10)}).key=o.id,E[o.id]&&(E[o.id](o),"com.apple.streaming.transportStreamTimestamp"===o.owner)){var p=o.data,d=(1&p[3])<<30|p[4]<<22|p[5]<<14|p[6]<<6|p[7]>>>2;d*=4,d+=3&p[7],o.timeStamp=d,void 0===i.pts&&void 0===i.dts&&(i.pts=o.timeStamp,i.dts=o.timeStamp),this.trigger("timestamp",o)}i.frames.push(o),e+=10,e+=r}while(e<s);this.trigger("data",i)}}}).prototype=new s;var U,R,M,O=S,x=A,L=188;(U=function(){var t=new Uint8Array(L),i=0;U.prototype.init.call(this),this.push=function(e){var s,a=0,n=L;for(i?((s=new Uint8Array(e.byteLength+i)).set(t.subarray(0,i)),s.set(e,i),i=0):s=e;n<s.byteLength;)71!==s[a]||71!==s[n]?(a++,n++):(this.trigger("data",s.subarray(a,n)),a+=L,n+=L);a<s.byteLength&&(t.set(s.subarray(a),0),i=s.byteLength-a)},this.flush=function(){i===L&&71===t[0]&&(this.trigger("data",t),i=0),this.trigger("done")},this.endTimeline=function(){this.flush(),this.trigger("endedtimeline")},this.reset=function(){i=0,this.trigger("reset")}}).prototype=new s,(R=function(){var t,i,e,s;R.prototype.init.call(this),s=this,this.packetsWaitingForPmt=[],this.programMapTable=void 0,t=function(t,s){var a=0;s.payloadUnitStartIndicator&&(a+=t[a]+1),"pat"===s.type?i(t.subarray(a),s):e(t.subarray(a),s)},i=function(t,i){i.section_number=t[7],i.last_section_number=t[8],s.pmtPid=(31&t[10])<<8|t[11],i.pmtPid=s.pmtPid},e=function(t,i){var e,a;if(1&t[5]){for(s.programMapTable={video:null,audio:null,"timed-metadata":{}},e=3+((15&t[1])<<8|t[2])-4,a=12+((15&t[10])<<8|t[11]);a<e;){var n=t[a],r=(31&t[a+1])<<8|t[a+2];n===b.H264_STREAM_TYPE&&null===s.programMapTable.video?s.programMapTable.video=r:n===b.ADTS_STREAM_TYPE&&null===s.programMapTable.audio?s.programMapTable.audio=r:n===b.METADATA_STREAM_TYPE&&(s.programMapTable["timed-metadata"][r]=n),a+=5+((15&t[a+3])<<8|t[a+4])}i.programMapTable=s.programMapTable}},this.push=function(i){var e={},s=4;if(e.payloadUnitStartIndicator=!!(64&i[1]),e.pid=31&i[1],e.pid<<=8,e.pid|=i[2],(48&i[3])>>>4>1&&(s+=i[s]+1),0===e.pid)e.type="pat",t(i.subarray(s),e),this.trigger("data",e);else if(e.pid===this.pmtPid)for(e.type="pmt",t(i.subarray(s),e),this.trigger("data",e);this.packetsWaitingForPmt.length;)this.processPes_.apply(this,this.packetsWaitingForPmt.shift());else void 0===this.programMapTable?this.packetsWaitingForPmt.push([i,s,e]):this.processPes_(i,s,e)},this.processPes_=function(t,i,e){e.pid===this.programMapTable.video?e.streamType=b.H264_STREAM_TYPE:e.pid===this.programMapTable.audio?e.streamType=b.ADTS_STREAM_TYPE:e.streamType=this.programMapTable["timed-metadata"][e.pid],e.type="pes",e.data=t.subarray(i),this.trigger("data",e)}}).prototype=new s,R.STREAM_TYPES={h264:27,adts:15},(M=function(){var t,i=this,e=!1,s={data:[],size:0},a={data:[],size:0},n={data:[],size:0},r=function(t,e,s){var a,n,r=new Uint8Array(t.size),o={type:e},h=0,p=0;if(t.data.length&&!(t.size<9)){for(o.trackId=t.data[0].pid,h=0;h<t.data.length;h++)n=t.data[h],r.set(n.data,p),p+=n.data.byteLength;var d,l,c,u;l=o,u=(d=r)[0]<<16|d[1]<<8|d[2],l.data=new Uint8Array,1===u&&(l.packetLength=6+(d[4]<<8|d[5]),l.dataAlignmentIndicator=0!=(4&d[6]),192&(c=d[7])&&(l.pts=(14&d[9])<<27|(255&d[10])<<20|(254&d[11])<<12|(255&d[12])<<5|(254&d[13])>>>3,l.pts*=4,l.pts+=(6&d[13])>>>1,l.dts=l.pts,64&c&&(l.dts=(14&d[14])<<27|(255&d[15])<<20|(254&d[16])<<12|(255&d[17])<<5|(254&d[18])>>>3,l.dts*=4,l.dts+=(6&d[18])>>>1)),l.data=d.subarray(9+d[8])),a="video"===e||o.packetLength<=t.size,(s||a)&&(t.size=0,t.data.length=0),a&&i.trigger("data",o)}};M.prototype.init.call(this),this.push=function(o){({pat:function(){},pes:function(){var t,i;switch(o.streamType){case b.H264_STREAM_TYPE:t=s,i="video";break;case b.ADTS_STREAM_TYPE:t=a,i="audio";break;case b.METADATA_STREAM_TYPE:t=n,i="timed-metadata";break;default:return}o.payloadUnitStartIndicator&&r(t,i,!0),t.data.push(o),t.size+=o.data.byteLength},pmt:function(){var s={type:"metadata",tracks:[]};null!==(t=o.programMapTable).video&&s.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+t.video,codec:"avc",type:"video"}),null!==t.audio&&s.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+t.audio,codec:"adts",type:"audio"}),e=!0,i.trigger("data",s)}})[o.type]()},this.reset=function(){s.size=0,s.data.length=0,a.size=0,a.data.length=0,this.trigger("reset")},this.flushStreams_=function(){r(s,"video"),r(a,"audio"),r(n,"timed-metadata")},this.flush=function(){if(!e&&t){var s={type:"metadata",tracks:[]};null!==t.video&&s.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+t.video,codec:"avc",type:"video"}),null!==t.audio&&s.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+t.audio,codec:"adts",type:"audio"}),i.trigger("data",s)}e=!1,this.flushStreams_(),this.trigger("done")}}).prototype=new s;var I={PAT_PID:0,MP2T_PACKET_LENGTH:L,TransportPacketStream:U,TransportParseStream:R,ElementaryStream:M,TimestampRolloverStream:x,CaptionStream:w.CaptionStream,Cea608Stream:w.Cea608Stream,Cea708Stream:w.Cea708Stream,MetadataStream:O};for(var B in b)b.hasOwnProperty(B)&&(I[B]=b[B]);var G,N,W,F,z=I,V=9e4;G=function(t){return t*V},N=function(t,i){return t*i},W=function(t){return t/V},F=function(t,i){return t/i};var Y,X=V,j=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];(Y=function(t){var i,e=0;Y.prototype.init.call(this),this.skipWarn_=function(t,i){this.trigger("log",{level:"warn",message:"adts skiping bytes "+t+" to "+i+" in frame "+e+" outside syncword"})},this.push=function(s){var a,n,r,o,h,p=0;if(t||(e=0),"audio"===s.type){var d;for(i&&i.length?(r=i,(i=new Uint8Array(r.byteLength+s.data.byteLength)).set(r),i.set(s.data,r.byteLength)):i=s.data;p+7<i.length;)if(255===i[p]&&240==(246&i[p+1])){if("number"==typeof d&&(this.skipWarn_(d,p),d=null),n=2*(1&~i[p+1]),a=(3&i[p+3])<<11|i[p+4]<<3|(224&i[p+5])>>5,h=(o=1024*(1+(3&i[p+6])))*X/j[(60&i[p+2])>>>2],i.byteLength-p<a)break;this.trigger("data",{pts:s.pts+e*h,dts:s.dts+e*h,sampleCount:o,audioobjecttype:1+(i[p+2]>>>6&3),channelcount:(1&i[p+2])<<2|(192&i[p+3])>>>6,samplerate:j[(60&i[p+2])>>>2],samplingfrequencyindex:(60&i[p+2])>>>2,samplesize:16,data:i.subarray(p+7+n,p+a)}),e++,p+=a}else"number"!=typeof d&&(d=p),p++;"number"==typeof d&&(this.skipWarn_(d,p),d=null),i=i.subarray(p)}},this.flush=function(){e=0,this.trigger("done")},this.reset=function(){i=void 0,this.trigger("reset")},this.endTimeline=function(){i=void 0,this.trigger("endedtimeline")}}).prototype=new s;var q,H,K,Z=Y,$=function(t){var i=t.byteLength,e=0,s=0;this.length=function(){return 8*i},this.bitsAvailable=function(){return 8*i+s},this.loadWord=function(){var a=t.byteLength-i,n=new Uint8Array(4),r=Math.min(4,i);if(0===r)throw new Error("no bytes available");n.set(t.subarray(a,a+r)),e=new DataView(n.buffer).getUint32(0),s=8*r,i-=r},this.skipBits=function(t){var a;s>t?(e<<=t,s-=t):(t-=s,t-=8*(a=Math.floor(t/8)),i-=a,this.loadWord(),e<<=t,s-=t)},this.readBits=function(t){var a=Math.min(s,t),n=e>>>32-a;return(s-=a)>0?e<<=a:i>0&&this.loadWord(),(a=t-a)>0?n<<a|this.readBits(a):n},this.skipLeadingZeros=function(){var t;for(t=0;t<s;++t)if(0!=(e&2147483648>>>t))return e<<=t,s-=t,t;return this.loadWord(),t+this.skipLeadingZeros()},this.skipUnsignedExpGolomb=function(){this.skipBits(1+this.skipLeadingZeros())},this.skipExpGolomb=function(){this.skipBits(1+this.skipLeadingZeros())},this.readUnsignedExpGolomb=function(){var t=this.skipLeadingZeros();return this.readBits(t+1)-1},this.readExpGolomb=function(){var t=this.readUnsignedExpGolomb();return 1&t?1+t>>>1:-1*(t>>>1)},this.readBoolean=function(){return 1===this.readBits(1)},this.readUnsignedByte=function(){return this.readBits(8)},this.loadWord()};(H=function(){var t,i,e=0;H.prototype.init.call(this),this.push=function(s){var a;i?((a=new Uint8Array(i.byteLength+s.data.byteLength)).set(i),a.set(s.data,i.byteLength),i=a):i=s.data;for(var n=i.byteLength;e<n-3;e++)if(1===i[e+2]){t=e+5;break}for(;t<n;)switch(i[t]){case 0:if(0!==i[t-1]){t+=2;break}if(0!==i[t-2]){t++;break}e+3!==t-2&&this.trigger("data",i.subarray(e+3,t-2));do{t++}while(1!==i[t]&&t<n);e=t-2,t+=3;break;case 1:if(0!==i[t-1]||0!==i[t-2]){t+=3;break}this.trigger("data",i.subarray(e+3,t-2)),e=t-2,t+=3;break;default:t+=3}i=i.subarray(e),t-=e,e=0},this.reset=function(){i=null,e=0,this.trigger("reset")},this.flush=function(){i&&i.byteLength>3&&this.trigger("data",i.subarray(e+3)),i=null,e=0,this.trigger("done")},this.endTimeline=function(){this.flush(),this.trigger("endedtimeline")}}).prototype=new s,K={100:!0,110:!0,122:!0,244:!0,44:!0,83:!0,86:!0,118:!0,128:!0,138:!0,139:!0,134:!0},(q=function(){var t,i,e,s,a,n,r,o=new H;q.prototype.init.call(this),t=this,this.push=function(t){"video"===t.type&&(i=t.trackId,e=t.pts,s=t.dts,o.push(t))},o.on("data",(function(r){var o={trackId:i,pts:e,dts:s,data:r,nalUnitTypeCode:31&r[0]};switch(o.nalUnitTypeCode){case 5:o.nalUnitType="slice_layer_without_partitioning_rbsp_idr";break;case 6:o.nalUnitType="sei_rbsp",o.escapedRBSP=a(r.subarray(1));break;case 7:o.nalUnitType="seq_parameter_set_rbsp",o.escapedRBSP=a(r.subarray(1)),o.config=n(o.escapedRBSP);break;case 8:o.nalUnitType="pic_parameter_set_rbsp";break;case 9:o.nalUnitType="access_unit_delimiter_rbsp"}t.trigger("data",o)})),o.on("done",(function(){t.trigger("done")})),o.on("partialdone",(function(){t.trigger("partialdone")})),o.on("reset",(function(){t.trigger("reset")})),o.on("endedtimeline",(function(){t.trigger("endedtimeline")})),this.flush=function(){o.flush()},this.partialFlush=function(){o.partialFlush()},this.reset=function(){o.reset()},this.endTimeline=function(){o.endTimeline()},r=function(t,i){var e,s=8,a=8;for(e=0;e<t;e++)0!==a&&(a=(s+i.readExpGolomb()+256)%256),s=0===a?s:a},a=function(t){for(var i,e,s=t.byteLength,a=[],n=1;n<s-2;)0===t[n]&&0===t[n+1]&&3===t[n+2]?(a.push(n+2),n+=2):n++;if(0===a.length)return t;i=s-a.length,e=new Uint8Array(i);var r=0;for(n=0;n<i;r++,n++)r===a[0]&&(r++,a.shift()),e[n]=t[r];return e},n=function(t){var i,e,s,a,n,o,h,p,d,l,c,u,f=0,g=0,y=0,m=0,_=[1,1];if(e=(i=new $(t)).readUnsignedByte(),a=i.readUnsignedByte(),s=i.readUnsignedByte(),i.skipUnsignedExpGolomb(),K[e]&&(3===(n=i.readUnsignedExpGolomb())&&i.skipBits(1),i.skipUnsignedExpGolomb(),i.skipUnsignedExpGolomb(),i.skipBits(1),i.readBoolean()))for(c=3!==n?8:12,u=0;u<c;u++)i.readBoolean()&&r(u<6?16:64,i);if(i.skipUnsignedExpGolomb(),0===(o=i.readUnsignedExpGolomb()))i.readUnsignedExpGolomb();else if(1===o)for(i.skipBits(1),i.skipExpGolomb(),i.skipExpGolomb(),h=i.readUnsignedExpGolomb(),u=0;u<h;u++)i.skipExpGolomb();if(i.skipUnsignedExpGolomb(),i.skipBits(1),p=i.readUnsignedExpGolomb(),d=i.readUnsignedExpGolomb(),0===(l=i.readBits(1))&&i.skipBits(1),i.skipBits(1),i.readBoolean()&&(f=i.readUnsignedExpGolomb(),g=i.readUnsignedExpGolomb(),y=i.readUnsignedExpGolomb(),m=i.readUnsignedExpGolomb()),i.readBoolean()&&i.readBoolean()){switch(i.readUnsignedByte()){case 1:_=[1,1];break;case 2:_=[12,11];break;case 3:_=[10,11];break;case 4:_=[16,11];break;case 5:_=[40,33];break;case 6:_=[24,11];break;case 7:_=[20,11];break;case 8:_=[32,11];break;case 9:_=[80,33];break;case 10:_=[18,11];break;case 11:_=[15,11];break;case 12:_=[64,33];break;case 13:_=[160,99];break;case 14:_=[4,3];break;case 15:_=[3,2];break;case 16:_=[2,1];break;case 255:_=[i.readUnsignedByte()<<8|i.readUnsignedByte(),i.readUnsignedByte()<<8|i.readUnsignedByte()]}_&&(_[0],_[1])}return{profileIdc:e,levelIdc:s,profileCompatibility:a,width:16*(p+1)-2*f-2*g,height:(2-l)*(d+1)*16-2*y-2*m,sarRatio:_}}}).prototype=new s;var J={H264Stream:q,NalByteStream:H},Q=function t(i){this.numberOfTracks=0,this.metadataStream=i.metadataStream,this.videoTags=[],this.audioTags=[],this.videoTrack=null,this.audioTrack=null,this.pendingCaptions=[],this.pendingMetadata=[],this.pendingTracks=0,this.processedTracks=0,t.prototype.init.call(this),this.push=function(t){return t.text?this.pendingCaptions.push(t):t.frames?this.pendingMetadata.push(t):("video"===t.track.type&&(this.videoTrack=t.track,this.videoTags=t.tags,this.pendingTracks++),void("audio"===t.track.type&&(this.audioTrack=t.track,this.audioTags=t.tags,this.pendingTracks++)))}};(Q.prototype=new s).flush=function(t){var i,e,s,a,n={tags:{},captions:[],captionStreams:{},metadata:[]};if(this.pendingTracks<this.numberOfTracks){if("VideoSegmentStream"!==t&&"AudioSegmentStream"!==t)return;if(0===this.pendingTracks&&(this.processedTracks++,this.processedTracks<this.numberOfTracks))return}if(this.processedTracks+=this.pendingTracks,this.pendingTracks=0,!(this.processedTracks<this.numberOfTracks)){for(this.videoTrack?a=this.videoTrack.timelineStartInfo.pts:this.audioTrack&&(a=this.audioTrack.timelineStartInfo.pts),n.tags.videoTags=this.videoTags,n.tags.audioTags=this.audioTags,s=0;s<this.pendingCaptions.length;s++)(e=this.pendingCaptions[s]).startTime=e.startPts-a,e.startTime/=9e4,e.endTime=e.endPts-a,e.endTime/=9e4,n.captionStreams[e.stream]=!0,n.captions.push(e);for(s=0;s<this.pendingMetadata.length;s++)(i=this.pendingMetadata[s]).cueTime=i.pts-a,i.cueTime/=9e4,n.metadata.push(i);n.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",n),this.trigger("done")}};var tt,it,et,st,at,nt,rt=Q,ot=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}})},ht=J.H264Stream;st=function(t,i){"number"==typeof i.pts&&(void 0===t.timelineStartInfo.pts?t.timelineStartInfo.pts=i.pts:t.timelineStartInfo.pts=Math.min(t.timelineStartInfo.pts,i.pts)),"number"==typeof i.dts&&(void 0===t.timelineStartInfo.dts?t.timelineStartInfo.dts=i.dts:t.timelineStartInfo.dts=Math.min(t.timelineStartInfo.dts,i.dts))},at=function(t,e){var s=new i(i.METADATA_TAG);return s.dts=e,s.pts=e,s.writeMetaDataDouble("videocodecid",7),s.writeMetaDataDouble("width",t.width),s.writeMetaDataDouble("height",t.height),s},nt=function(t,e){var s,a=new i(i.VIDEO_TAG,!0);for(a.dts=e,a.pts=e,a.writeByte(1),a.writeByte(t.profileIdc),a.writeByte(t.profileCompatibility),a.writeByte(t.levelIdc),a.writeByte(255),a.writeByte(225),a.writeShort(t.sps[0].length),a.writeBytes(t.sps[0]),a.writeByte(t.pps.length),s=0;s<t.pps.length;++s)a.writeShort(t.pps[s].length),a.writeBytes(t.pps[s]);return a},(et=function(t){var e,s=[],a=[];et.prototype.init.call(this),this.push=function(i){st(t,i),t&&(t.audioobjecttype=i.audioobjecttype,t.channelcount=i.channelcount,t.samplerate=i.samplerate,t.samplingfrequencyindex=i.samplingfrequencyindex,t.samplesize=i.samplesize,t.extraData=t.audioobjecttype<<11|t.samplingfrequencyindex<<7|t.channelcount<<3),i.pts=Math.round(i.pts/90),i.dts=Math.round(i.dts/90),s.push(i)},this.flush=function(){var n,r,o,h=new ot;if(0!==s.length){for(o=-1/0;s.length;)n=s.shift(),a.length&&n.pts>=a[0]&&(o=a.shift(),this.writeMetaDataTags(h,o)),(t.extraData!==e||n.pts-o>=1e3)&&(this.writeMetaDataTags(h,n.pts),e=t.extraData,o=n.pts),(r=new i(i.AUDIO_TAG)).pts=n.pts,r.dts=n.dts,r.writeBytes(n.data),h.push(r.finalize());a.length=0,e=null,this.trigger("data",{track:t,tags:h.list}),this.trigger("done","AudioSegmentStream")}else this.trigger("done","AudioSegmentStream")},this.writeMetaDataTags=function(e,s){var a;(a=new i(i.METADATA_TAG)).pts=s,a.dts=s,a.writeMetaDataDouble("audiocodecid",10),a.writeMetaDataBoolean("stereo",2===t.channelcount),a.writeMetaDataDouble("audiosamplerate",t.samplerate),a.writeMetaDataDouble("audiosamplesize",16),e.push(a.finalize()),(a=new i(i.AUDIO_TAG,!0)).pts=s,a.dts=s,a.view.setUint16(a.position,t.extraData),a.position+=2,a.length=Math.max(a.length,a.position),e.push(a.finalize())},this.onVideoKeyFrame=function(t){a.push(t)}}).prototype=new s,(it=function(t){var e,s,a=[];it.prototype.init.call(this),this.finishFrame=function(i,a){if(a){if(e&&t&&t.newMetadata&&(a.keyFrame||0===i.length)){var n=at(e,a.dts).finalize(),r=nt(t,a.dts).finalize();n.metaDataTag=r.metaDataTag=!0,i.push(n),i.push(r),t.newMetadata=!1,this.trigger("keyframe",a.dts)}a.endNalUnit(),i.push(a.finalize()),s=null}},this.push=function(i){st(t,i),i.pts=Math.round(i.pts/90),i.dts=Math.round(i.dts/90),a.push(i)},this.flush=function(){for(var n,r=new ot;a.length&&"access_unit_delimiter_rbsp"!==a[0].nalUnitType;)a.shift();if(0!==a.length){for(;a.length;)"seq_parameter_set_rbsp"===(n=a.shift()).nalUnitType?(t.newMetadata=!0,e=n.config,t.width=e.width,t.height=e.height,t.sps=[n.data],t.profileIdc=e.profileIdc,t.levelIdc=e.levelIdc,t.profileCompatibility=e.profileCompatibility,s.endNalUnit()):"pic_parameter_set_rbsp"===n.nalUnitType?(t.newMetadata=!0,t.pps=[n.data],s.endNalUnit()):"access_unit_delimiter_rbsp"===n.nalUnitType?(s&&this.finishFrame(r,s),(s=new i(i.VIDEO_TAG)).pts=n.pts,s.dts=n.dts):("slice_layer_without_partitioning_rbsp_idr"===n.nalUnitType&&(s.keyFrame=!0),s.endNalUnit()),s.startNalUnit(),s.writeBytes(n.data);s&&this.finishFrame(r,s),this.trigger("data",{track:t,tags:r.list}),this.trigger("done","VideoSegmentStream")}else this.trigger("done","VideoSegmentStream")}}).prototype=new s,(tt=function(t){var i,e,s,a,n,r,o,h,p,d,l,c,u=this;tt.prototype.init.call(this),t=t||{},this.metadataStream=new z.MetadataStream,t.metadataStream=this.metadataStream,i=new z.TransportPacketStream,e=new z.TransportParseStream,s=new z.ElementaryStream,a=new z.TimestampRolloverStream("video"),n=new z.TimestampRolloverStream("audio"),r=new z.TimestampRolloverStream("timed-metadata"),o=new Z,h=new ht,c=new rt(t),i.pipe(e).pipe(s),s.pipe(a).pipe(h),s.pipe(n).pipe(o),s.pipe(r).pipe(this.metadataStream).pipe(c),l=new z.CaptionStream(t),h.pipe(l).pipe(c),s.on("data",(function(t){var i,e,s;if("metadata"===t.type){for(i=t.tracks.length;i--;)"video"===t.tracks[i].type?e=t.tracks[i]:"audio"===t.tracks[i].type&&(s=t.tracks[i]);e&&!p&&(c.numberOfTracks++,p=new it(e),h.pipe(p).pipe(c)),s&&!d&&(c.numberOfTracks++,d=new et(s),o.pipe(d).pipe(c),p&&p.on("keyframe",d.onVideoKeyFrame))}})),this.push=function(t){i.push(t)},this.flush=function(){i.flush()},this.resetCaptions=function(){l.reset()},c.on("data",(function(t){u.trigger("data",t)})),c.on("done",(function(){u.trigger("done")}))}).prototype=new s;var pt=function(t,e,s){var a,n,r,o=new Uint8Array(9),h=new DataView(o.buffer);return t=t||0,e=void 0===e||e,s=void 0===s||s,h.setUint8(0,70),h.setUint8(1,76),h.setUint8(2,86),h.setUint8(3,1),h.setUint8(4,(e?4:0)|(s?1:0)),h.setUint32(5,o.byteLength),t<=0?((n=new Uint8Array(o.byteLength+4)).set(o),n.set([0,0,0,0],o.byteLength),n):((a=new i(i.METADATA_TAG)).pts=a.dts=0,a.writeMetaDataDouble("duration",t),r=a.finalize().length,(n=new Uint8Array(o.byteLength+r)).set(o),n.set(h.byteLength,r),n)};return{tag:i,Transmuxer:tt,getFlvHeader:pt}}));

@@ -99,3 +99,3 @@ /**

var adtsFrames = [],
sequenceNumber = 0,
sequenceNumber,
earliestAllowedDts = 0,

@@ -105,2 +105,3 @@ audioAppendStartTs = 0,

options = options || {};
sequenceNumber = options.firstSequenceNumber || 0;

@@ -205,3 +206,3 @@ _AudioSegmentStream.prototype.init.call(this);

_VideoSegmentStream = function VideoSegmentStream(track, options) {
var sequenceNumber = 0,
var sequenceNumber,
nalUnits = [],

@@ -212,2 +213,3 @@ gopsToAlignWith = [],

options = options || {};
sequenceNumber = options.firstSequenceNumber || 0;

@@ -214,0 +216,0 @@ _VideoSegmentStream.prototype.init.call(this);

@@ -95,3 +95,3 @@ /**

adtsFrames = [],
sequenceNumber = 0,
sequenceNumber,
earliestAllowedDts = 0,

@@ -103,2 +103,4 @@ audioAppendStartTs = 0,

sequenceNumber = options.firstSequenceNumber || 0;
AudioSegmentStream.prototype.init.call(this);

@@ -232,3 +234,3 @@

var
sequenceNumber = 0,
sequenceNumber,
nalUnits = [],

@@ -241,2 +243,4 @@ gopsToAlignWith = [],

sequenceNumber = options.firstSequenceNumber || 0;
VideoSegmentStream.prototype.init.call(this);

@@ -243,0 +247,0 @@

{
"name": "mux.js",
"version": "5.12.2",
"version": "5.13.0",
"description": "A collection of lightweight utilities for inspecting and manipulating video container formats.",

@@ -5,0 +5,0 @@ "repository": {

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc