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?
I think there are basically 3 things to consider when thinking about video load time:
(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.