UNPKG

mp4box

Version:

JavaScript version of GPAC's MP4Box tool

35 lines (33 loc) 690 B
BoxParser.stszBox.prototype.write = function(stream) { var i; var constant = true; this.version = 0; this.flags = 0; if (this.sample_sizes.length > 0) { i = 0; while (i+1 < this.sample_sizes.length) { if (this.sample_sizes[i+1] !== this.sample_sizes[0]) { constant = false; break; } else { i++; } } } else { constant = false; } this.size = 8; if (!constant) { this.size += 4*this.sample_sizes.length; } this.writeHeader(stream); if (!constant) { stream.writeUint32(0); } else { stream.writeUint32(this.sample_sizes[0]); } stream.writeUint32(this.sample_sizes.length); if (!constant) { stream.writeUint32Array(this.sample_sizes); } }