     sidx._raw.setUint32(0,newSidxSize) # sidx size changed
     sidx._raw.setUint16(30,@downloadIndexes.length) # reference_count
 
-    # tkhd and mvhd durations must be updated too
-
-    tkhd = @newHeader.fetch('tkhd')
-    mvhd = @newHeader.fetch('mvhd')
-
-    
 
     console.log 'sidx.size',sidx._raw.getUint32(0)
     console.log 'sidx.reference_count',sidx._raw.getUint16(30)

      console.log 'newReferences[i],i,referencesOffset+i',byte,i,i+referencesOffset,'"'+String.fromCharCode(byte)+'"'
      headerData[ i+referencesOffset ] = byte

    console.log 'headerData',headerData.buffer.byteLength
    checkNewHeader = mp4.parseBuffer( headerData.buffer )
    console.log 'checkNewHeader',checkNewHeader
    newHeaderStr = String.fromCharCode.apply(null,headerData)
    console.log 'newHeaderStr',newHeaderStr
    @fileStream.write newHeaderStr,'binary',(err)=>
      if err?
        console.error err

    if obj.end?
      @end = @parseTime(obj.end)

  int32toBuff8:(number)->
    int32 = new Uint32Array(1)
    int32[0]=number
    buff8 = new Uint8Array(int32.buffer)
    buff8

  makeNewHeader:(next)->
    sidx = @newHeader.fetch('sidx')
    refCount = sidx.reference_count
