Skip to content

Commit

Permalink
convert data and get actual bandwith estimate
Browse files Browse the repository at this point in the history
  • Loading branch information
Mebareksaf committed Feb 23, 2024
1 parent c3eadc8 commit b0198a7
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions apps/ex_nvr_web/assets/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,16 @@ startStreaming = (src, poster_url) => {
})
window.hls.loadSource(src)
window.hls.attachMedia(video)

window.hls.on(Hls.Events.LEVEL_LOADED, (event, data) => {
const { level } = data;
const { level, stats } = data;
console.log(data)
const levelInfo = window.hls.levels[level];

const mbpsFactor = 1024 * 1024
infoBox.innerHTML = `
<p class="font-bold text-xs">Bitrate: ${levelInfo.bitrate}</p>
<p class="font-bold text-xs">Avg.Bitrate: ${levelInfo.averageBitrate}</p>
<p class="font-bold text-xs">Bandwith Estimate: ${(window.hls.bandwidthEstimate / mbpsFactor).toFixed(3)} (Mbps)</p>
<p class="font-bold text-xs">Bitrate: ${(levelInfo.bitrate / mbpsFactor).toFixed(3)} (Mbps)</p>
<p class="font-bold text-xs">Avg.Bitrate: ${(levelInfo.averageBitrate / mbpsFactor).toFixed(3)} (Mbps)</p>
<p class="font-bold text-xs">Resolution: ${levelInfo.width}x${levelInfo.height}</p>
<p class="font-bold text-xs">Codecs: ${levelInfo.attrs.CODECS}</p>
`;
Expand Down

0 comments on commit b0198a7

Please sign in to comment.