 
   open: (filename) ->
     startTime = process.hrtime()
-    @bits = new Bits fs.readFileSync filename  # up to 1GB
+    @fileBuf = fs.readFileSync filename  # up to 1GB
+    @bits = new Bits @fileBuf
     diffTime = process.hrtime startTime
     console.log "took #{(diffTime[0] * 1e9 + diffTime[1]) / 1000000} ms to read"
 


    return

  getNumSamplesInChunk: (chunk) ->
    for entry in @entries
      if not entry.numChunks?
        return null  # the last chunk
      if chunk < entry.firstChunk + entry.numChunks
        return entry.samplesPerChunk
    throw new Error "Chunk not found: #{chunk}"

Bits = require './bits'
EventEmitterModule = require './event_emitter'
Sequent = require 'sequent'
fs = require 'fs'

formatDate = (date) ->
  date.toISOString()

TAG_CTOO = new Buffer([0xa9, 0x74, 0x6f, 0x6f]).toString 'utf8'
MIN_TIME_DIFF = 0.01  # seconds
READ_BUFFER_TIME = 3.0
QUEUE_BUFFER_TIME = 1.5

getCurrentTime = ->
  time = process.hrtime()
  return time[0] + time[1] / 1e9

class MP4File
  constructor: (filename) ->
