eshaz/mse-audio-wrapper

Per Frame Statistics

eshaz opened this issue · 0 comments

eshaz commented

There should be an option to return statistics on a per frame basis. Since the duration of each frame is already being calculated in order to mux the incoming audio into mp4 or webm, this will be nice to expose to consumers such as icecast-metadata-js/stream-recorder which relies on frame accurate duration to schedule metadata updates.

This feature may also enable clients that don't support MediaSource to continue to view metadata; however, this would require two stream connections and synchronizing metadata updates with the HTML 5 audio element.

Each frame will have it's metadata supplied in an ordered array of objects

  • frameNumber: incrementing frame ID starting at 0
  • frameDuration: the duration in seconds of the frame
  • frameLength: the byte length of the frame
  • totalBytesIn: the byte offset in relation to the incoming data where the start of the frame is located
  • totalBytesOut: the byte offset in relation to the outgoing (mp4, or webm) data where the start of the frame is located
  • totalDuration: the total duration in second where the start of the frame is located
[
  {
    frameNumber: 0,
    frameDuration: 1234.567,
    frameLength: 3214,
    totalBytesIn: 1234,
    totalBytesOut: 4567,
    totalDuration: 254.13
  },
  {
    frameNumber: n,
    frameDuration: ...,
    frameLength: ...,
    totalBytesIn: ...,
    totalBytesOut: ...,
    totalDuration: ...
  }
]