src/webm-writer-0.2.0.js
function flushClusterFrameBuffer() {
                if (clusterFrameBuffer.length == 0) {
                    return;
                }
    
                // First work out how large of a buffer we need to hold the cluster data
                var
                    rawImageSize = 0;
                
                for (var i = 0; i < clusterFrameBuffer.length; i++) {
                    rawImageSize += clusterFrameBuffer[i].frame.length;
                }
                
                var
                    buffer = new ArrayBufferDataStream(rawImageSize + clusterFrameBuffer.length * 32), // Estimate 32 bytes per SimpleBlock header
    
                    cluster = createCluster({
                        timecode: Math.round(clusterStartTime),
                    });
                    
                for (var i = 0; i < clusterFrameBuffer.length; i++) {
                    cluster.data.push(createKeyframeBlock(clusterFrameBuffer[i]));
                }
                
                writeEBML(buffer, blobBuffer.pos, cluster);
                blobBuffer.write(buffer.getAsDataArray());
                
                addCuePoint(DEFAULT_TRACK_NUMBER, Math.round(clusterStartTime), cluster.offset);
                
                clusterFrameBuffer = [];
                clusterStartTime += clusterDuration;
                clusterDuration = 0;
            }
function flushClusterFrameBuffer() {
                if (clusterFrameBuffer.length == 0) {
                    return;
                }
    
                // First work out how large of a buffer we need to hold the cluster data
                var
                    rawImageSize = 0;
                
                for (var i = 0; i < clusterFrameBuffer.length; i++) {
                    rawImageSize += clusterFrameBuffer[i].frame.length;
                }
                
                var
                    buffer = new ArrayBufferDataStream(rawImageSize + clusterFrameBuffer.length * 32), // Estimate 32 bytes per SimpleBlock header
    
                    cluster = createCluster({
                        timecode: Math.round(clusterStartTime),
                    });
                    
                for (var i = 0; i < clusterFrameBuffer.length; i++) {
                    cluster.data.push(createKeyframeBlock(clusterFrameBuffer[i]));
                }
                
                writeEBML(buffer, blobBuffer.pos, cluster);
                blobBuffer.write(buffer.getAsDataArray());
                
                addCuePoint(DEFAULT_TRACK_NUMBER, Math.round(clusterStartTime), cluster.offset);
                
                clusterFrameBuffer = [];
                clusterStartTime += clusterDuration;
                clusterDuration = 0;
            }
function flushClusterFrameBuffer ( ) { if ( clusterFrameBuffer . length == 0 ) { return ; } // First work out how large of a buffer we need to hold the cluster data var rawImageSize = 0 ; for ( var i = 0 ; i < clusterFrameBuffer . length ; i ++ ) { rawImageSize += clusterFrameBuffer [ i ] . frame . length ; } var buffer = new ArrayBufferDataStream ( rawImageSize + clusterFrameBuffer . length * 32 ) , // Estimate 32 bytes per SimpleBlock header cluster = createCluster ( { timecode : Math . round ( clusterStartTime ) , } ) ; for ( var i = 0 ; i < clusterFrameBuffer . length ; i ++ ) { cluster . data . push ( createKeyframeBlock ( clusterFrameBuffer [ i ] ) ) ; } writeEBML ( buffer , blobBuffer . pos , cluster ) ; blobBuffer . write ( buffer . getAsDataArray ( ) ) ; addCuePoint ( DEFAULT_TRACK_NUMBER , Math . round ( clusterStartTime ) , cluster . offset ) ; clusterFrameBuffer = [ ] ; clusterStartTime += clusterDuration ; clusterDuration = 0 ; }
Flush the frames in the current clusterFrameBuffer out to the stream as a Cluster.
Flush the frames in the current clusterFrameBuffer out to the stream as a Cluster .