Shaka-player: Time To First Byte (TTFB)

Created on 27 Nov 2019  路  8Comments  路  Source: google/shaka-player

Hi,

I need to measure video's load latency (i.e., Time To First Byte delay) so I was wondering if there is any API that I could use to get it. If there is not such an API is there a straightforward solution to measure this parameter?

archived question

All 8 comments

I think there are basically 3 things to consider when thinking about video load time:

  1. Time spent in JavaScript (mostly negligible unless you're doing something crazy)
  2. Time spent in browser native code (media stack init and license install could take time)
  3. Time spent in the network (requests for manifest, license, certificate, segments)

(3) is almost certainly the most expensive.

If you just want to measure the time it takes for your video to start, listen to the video element playing event.

If you want more detailed information about networking, you could take a look at the Performance API:
https://developer.mozilla.org/en-US/docs/Web/API/Performance

One feature we have planned for the future is Google Analytics support, which will log video performance diagnostics. Including, among other things, load latency.
No guarantee about when that will come out, though, so for now it'll probably be best to listen to the playing event as Chris suggested.

I am looking forward to seeing this feature in the next releases. Thanks for the update, though.

Just to clarify, is unload latency a good estimation of TTFB?

Do you mean loadLatency, like we measure in Player.getStats?

Technically speaking, our loadLatency is a measurement of how long it takes from the call to Player.load to when the media element has buffered up to the playhead. So it won't happen until the entire first segment has downloaded, at least. There's also going to be some time spent decoding the segment, but usually that's pretty negligible (unless, perhaps, you are using some codec that doesn't have hardware support yet, like AV1).
So the main issue is going to be how long your segments are. The longer they are, the further loadLatency will be from TTFB.

Oh, I see. You are talking about the "Unload latency" log we removed in v2.5.
That was a measure of how long it took to unload the old asset (i.e. stop playing it), when you switched what asset you were playing.
That log was removed during some refactoring in how we handle loading and unloading assets; we didn't keep it, because we were pretty sure nobody cared about that particular statistic to begin with.

@chavoosh Does this answer all your questions? Can we close the issue?

Closing due to inactivity. If this is still an issue for you or if you have further questions, you can ask us to reopen or have the bot reopen it by including @shaka-bot reopen in a comment.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gabor picture gabor  路  3Comments

luusetsenkoodbichsen picture luusetsenkoodbichsen  路  3Comments

alexandercerutti picture alexandercerutti  路  5Comments

baseballbrad3 picture baseballbrad3  路  4Comments

EstebanBP picture EstebanBP  路  4Comments