{"title":"Build a Streaming Quality Model Beyond Video Starts","excerpt":"A video start metric counts a session that froze twice and fell to 360p as a success. Split each session into eight contracts, assert each from the player's event log and buffer, and report the ones you cannot observe as NOT TESTED. Includes a Playwright and hls.js lab with one held segment.","canonicalUrl":"https://automationtester.in/blog/automation-tutorials/streaming-quality-model-beyond-video-starts","category":{"name":"Automation Tutorials","slug":"automation-tutorials"},"tags":["streaming","video-testing","hls","playwright","media-source-extensions","test-strategy"],"author":{"name":"Shashank Rawlani","url":"https://shashank.rawlani.com","linkedin":"https://www.linkedin.com/in/shashankrawlani/"},"datePublished":"2026-11-21T13:30:00.000Z","dateModified":"2026-11-21T13:30:00.000Z","coverImage":{"url":"https://ik.imagekit.io/automationtester/automationtester-in/blog/covers/v3/streaming-quality-model-beyond-video-starts.webp","alt":"A green strand enters from the left, passes a ringed green node and fans into eight lanes. Two run unbroken to green nodes; one breaks at two orange gaps and one thins to orange, both ending in crossed circles; four are dashed grey."},"contentHtml":"<div class=\"callout callout-info\"><strong>Quick answer:</strong> A video start metric answers one question: did a first frame play. A viewing session makes at least eight separate promises: startup, continuity, adaptation, audio and video sync, presentation and captions, entitlement, ads, and recovery. Each has its own signal in its own layer: the manifest, player events, the Media Source Extensions buffer, or the device. Assert each contract separately from the session's event log, report one with no signal as NOT TESTED rather than passing it, count <code>waiting</code> only after the first <code>playing</code>, and do not expect <code>stalled</code> to fire for an MSE player.</div>\n\n<p>The dashboard tile says 99.4% of video starts succeeded, and the support queue is full of viewers saying the match froze. Both can be true at once. Take one session from the lab later in this article. The first frame plays 36 milliseconds after the page asks for it. Then the picture freezes twice, for six seconds in total, and the player drops from 720p to 360p and finishes there. A start-success metric counts that session as a success. A time-to-first-frame chart ranks it above the clean session, which took 204 milliseconds to start.</p>\n\n<p>The start metric is not wrong. It measures one row of a table that has eight, and a team holding only that row cannot tell a frozen match from a good one. This article builds the table and computes it from a real browser session.</p>\n\n<p>This is part 1 of an eight-part series on streaming and connected-TV quality. Later parts each take one area: manifest validation, startup percentiles, adaptive bitrate under controlled networks, DRM without leaking keys, server-side ad events, captions and A/V sync, and telemetry release gates. This part is the map they share.</p>\n\n<div class=\"callout callout-warning\"><strong>Versions checked on 2026-11-18:</strong> ffmpeg 9.0.1, Node.js 26.12.1, Playwright 1.62.1 with its bundled Chromium 151.0.7922.34, and hls.js 1.7.4. The lab ran on macOS against <code>http://localhost</code> only, with synthetic ffmpeg <code>testsrc2</code> and <code>sine</code> media. The cited MSE and EME documents are W3C Working Drafts dated 9 and 8 November 2026, and Media Playback Quality is an Editor's Draft; re-read them before relying on a detail.</div>\n\n<h2 id=\"sqm-eight-contracts\">Eight promises inside one viewing session</h2>\n\n<p>Each row below is a contract a viewer would describe in their own words. The third column is what a test can actually assert, and the fourth is the lowest layer where that signal exists.</p>\n\n<table>\n<thead><tr><th>Contract</th><th>What the viewer notices</th><th>Signal a test can assert</th><th>Layer that sees it</th></tr></thead>\n<tbody>\n<tr><td>Startup</td><td>A black screen after pressing play</td><td>Time from the play request to the first <code>playing</code> event</td><td>Player events</td></tr>\n<tr><td>Continuity</td><td>The picture freezes mid-programme</td><td>Each <code>waiting</code> after the first <code>playing</code>, with <code>currentTime</code> against the end of <code>video.buffered</code></td><td>Player events and MSE buffer</td></tr>\n<tr><td>Adaptation</td><td>A soft picture on a good connection</td><td>Rendition switches and time spent on each rendition, against the <code>BANDWIDTH</code> each variant declares</td><td>Player and manifest</td></tr>\n<tr><td>A/V sync</td><td>Lips and voice drift apart</td><td>Offset between a known visual marker and a known audio marker in the decoded output</td><td>Device output</td></tr>\n<tr><td>Presentation and captions</td><td>Judder, or subtitles missing or in the wrong language</td><td><code>getVideoPlaybackQuality()</code> counters; subtitle renditions in the manifest and text tracks in the player</td><td>Decoder, manifest and player</td></tr>\n<tr><td>Entitlement</td><td>\"Not available\" for a paying viewer</td><td>Licence response status and EME key statuses such as <code>usable</code>, <code>expired</code> and <code>output-restricted</code></td><td>Licence service and the CDM</td></tr>\n<tr><td>Ads</td><td>The break plays, but content resumes at the wrong point or the impression is never counted</td><td>Splice markers in the playlist joined to the tracking beacons the player sent</td><td>Manifest and beacon collector</td></tr>\n<tr><td>Recovery</td><td>The player gives up where a retry would have worked</td><td>Fatal against non-fatal player errors, and time from a stall to the next <code>playing</code></td><td>Player</td></tr>\n</tbody>\n</table>\n\n<p>The layer column doubles as a routing table. A freeze where <code>currentTime</code> has reached the end of the buffered range means media did not arrive in time, which points at the CDN, the origin or the player's request scheduling. A freeze with seconds of media already buffered ahead points away from the network, towards the decoder or the player's own state. Team names differ between companies; what matters is that every row has one first responder and fails with the evidence that routes it.</p>\n\n<h2 id=\"sqm-what-each-layer-proves\">What the manifest, the player and the device can each prove</h2>\n\n<p><strong>The manifest proves what is offered, not what plays.</strong> RFC 8216 defines <code>BANDWIDTH</code> on a variant as its peak segment bit rate and warns that an inaccurate value can cause playback stalls or stop a client from playing the variant. A manifest check can catch that lie before it looks like an adaptation problem. It cannot fully check captions: an <code>EXT-X-MEDIA</code> entry with <code>TYPE=CLOSED-CAPTIONS</code> does not specify a rendition, because CEA-608 captions normally travel inside the video stream, so the playlist can only declare them. The same RFC states that the algorithms clients use to switch between variants are out of its scope. Adaptation behaviour therefore belongs to the player, and two players can make different choices from the same playlist without either breaking the protocol.</p>\n\n<p><strong>Player events prove what the element did.</strong> The HTML standard defines <code>waiting</code> as playback having stopped because the next frame is not available while the user agent expects it to arrive, and <code>playing</code> as playback being ready to start after a pause or a delay for lack of data. Those two events bracket every freeze. hls.js adds its own vocabulary and reports every problem through a single <code>ERROR</code> event whose <code>fatal</code> flag is <code>true</code> only after all of its recovery attempts have run out.</p>\n\n<p><strong>The MSE buffer proves why the element stopped.</strong> Logging <code>video.buffered</code> next to each <code>waiting</code> turns \"it froze at 7.91 seconds\" into \"it froze at 7.91 seconds with media buffered only to 7.96\", a delivery problem, not a decoder one.</p>\n\n<p><strong>The device proves what the viewer saw.</strong> Encrypted Media Extensions defines an <code>output-restricted</code> key status for a key whose output restrictions cannot currently be met, in which case the decrypted media may be blocked from presentation. A key can be <code>usable</code> in a desktop test browser and restricted on a viewer's television and display chain. Sync drift, decoder frame drops and output protection live here, out of reach of a headless browser. EME is also exposed only to secure contexts, so a browser entitlement lab must run from <code>https</code> or <code>http://localhost</code>, never <code>file://</code>.</p>\n\n<h2 id=\"sqm-misleading-media-events\">Three media events that mislead a naive monitor</h2>\n\n<p><strong><code>waiting</code> fires before the first frame.</strong> When <code>play()</code> is called and the element's <code>readyState</code> is <code>HAVE_NOTHING</code>, <code>HAVE_METADATA</code> or <code>HAVE_CURRENT_DATA</code>, the HTML standard has it queue a <code>waiting</code> event. In the lab both sessions log one at 3 milliseconds, before the manifest is even parsed. A monitor that counts every <code>waiting</code> as a rebuffer reports a freeze in every session, and teams learn to ignore it.</p>\n\n<p><strong><code>stalled</code> belongs to a code path MSE does not use.</strong> The HTML standard defines <code>stalled</code> inside the steps for fetching a remote resource: after a media element stall timeout of about three seconds with no data, the element fires it. The MSE specification says an attached <code>MediaSource</code> does not use those remote-mode steps, and that future versions will likely remove <code>stalled</code> for MSE playback, though today's browsers may still fire it. In the lab, Chromium 151 fired no <code>stalled</code> event during a freeze lasting six seconds. hls.js feeds the element through MSE, so a dashboard built on <code>stalled</code> can show zero freezes for a player like this one while viewers watch a frozen picture.</p>\n\n<p><strong>Dropped-frame counters are local and resettable.</strong> Media Playback Quality defines <code>droppedVideoFrames</code> as frames dropped before decode or for missing their display deadline, and resets both counters whenever the element's load algorithm runs, which includes assigning it a new source. Treat them as a property of the machine doing the decoding. Across four runs of the lab, the session with the held segment dropped 20, 0, 16 and 12 of 720 frames, and the clean session dropped none in any run. That is a desktop under test load, not evidence about a television.</p>\n\n<h2 id=\"sqm-held-segment-lab\">A lab with one held segment</h2>\n\n<p>The lab plays the same 24-second stream twice in Playwright's Chromium. The first session is served cleanly. In the second, a local server sends the response headers for segment 4 (8 to 10 seconds of media) at once, then holds the body for 8 seconds, in every rendition. The fault is injected at the HTTP layer because packet-level loss needs root on macOS, and a response whose body arrives late is how slow delivery looks from the player's side. Both sessions start; the question is which contracts notice.</p>\n\n<p>In a scratch directory, install the pinned packages:</p>\n\n<pre class=\"language-bash\"><code class=\"language-bash\">npm init -y\nnpm i hls.js@1.7.4 playwright@1.62.1</code></pre>\n\n<p>Generate two renditions, 720p and 360p, as fragmented MP4 HLS with two-second segments and a keyframe every 60 frames, so segment boundaries line up across renditions:</p>\n\n<pre class=\"language-bash\"><code class=\"language-bash\">mkdir -p media\nffmpeg -hide_banner -loglevel error -y \\\n  -f lavfi -i testsrc2=size=1280x720:rate=30:duration=24 \\\n  -f lavfi -i sine=frequency=1000:sample_rate=48000:duration=24 \\\n  -filter_complex \"[0:v]split=2[a][b];[b]scale=640:360[b2]\" \\\n  -map \"[a]\" -map \"[b2]\" -map 1:a -map 1:a \\\n  -c:v libx264 -profile:v main -preset veryfast -g 60 -keyint_min 60 -sc_threshold 0 \\\n  -b:v:0 2500k -b:v:1 700k -c:a aac -b:a 96k \\\n  -f hls -hls_time 2 -hls_playlist_type vod -hls_segment_type fmp4 \\\n  -var_stream_map \"v:0,a:0 v:1,a:1\" -master_pl_name master.m3u8 \\\n  -hls_segment_filename \"media/v%v/seg%02d.m4s\" media/v%v/index.m3u8</code></pre>\n\n<p>The server holds the body of any path ending in the configured suffix:</p>\n\n<pre class=\"language-javascript\"><code class=\"language-javascript\">// Static server for the lab. serve(\"seg04.m4s=8000\") sends the headers for\n// any path ending in seg04.m4s at once, then holds the body for 8 s.\nimport { createServer } from \"node:http\";\nimport { readFile } from \"node:fs/promises\";\nimport { extname, join } from \"node:path\";\n\nconst TYPES = { \".html\": \"text/html\", \".js\": \"text/javascript\", \".m3u8\": \"application/vnd.apple.mpegurl\",\n  \".mp4\": \"video/mp4\", \".m4s\": \"video/iso.segment\" };\nconst FILES = { \"/\": \"player.html\", \"/hls.min.js\": \"node_modules/hls.js/dist/hls.min.js\" };\n\nexport function serve(delay = \"\") {\n  const [suffix, ms] = delay ? delay.split(\"=\") : [null, 0];\n  const server = createServer(async (req, res) =&gt; {\n    const path = req.url.split(\"?\")[0];\n    const file = FILES[path] ?? (path.startsWith(\"/media/\") ? join(\".\", path) : null);\n    let body;\n    try { body = await readFile(file); } catch { res.writeHead(404).end(); return; }\n    res.writeHead(200, { \"content-type\": TYPES[extname(file)] ?? \"application/octet-stream\" });\n    if (suffix &amp;&amp; path.endsWith(suffix)) {\n      res.flushHeaders();\n      setTimeout(() =&gt; res.end(body), Number(ms));\n    } else {\n      res.end(body);\n    }\n  });\n  return new Promise((ok) =&gt; server.listen(0, \"127.0.0.1\", () =&gt; ok(server)));\n}</code></pre>\n\n<p>The page logs every event with <code>currentTime</code> and the buffered ranges at that moment. It listens for <code>stalled</code> too, so its absence is measured, not assumed:</p>\n\n<pre class=\"language-html\"><code class=\"language-html\">&lt;!doctype html&gt;\n&lt;meta charset=\"utf-8\"&gt;\n&lt;video id=\"v\" muted playsinline width=\"640\"&gt;&lt;/video&gt;\n&lt;script src=\"/hls.min.js\"&gt;&lt;/script&gt;\n&lt;script&gt;\n  const video = document.getElementById(\"v\");\n  const t0 = performance.now();\n  const log = (window.__log = []);\n  const ranges = () =&gt; Array.from({ length: video.buffered.length }, (_, i) =&gt;\n    [+video.buffered.start(i).toFixed(2), +video.buffered.end(i).toFixed(2)]);\n  const rec = (type, extra = {}) =&gt;\n    log.push({ t: Math.round(performance.now() - t0), type, ct: +video.currentTime.toFixed(2), buf: ranges(), ...extra });\n\n  for (const type of [\"loadedmetadata\", \"playing\", \"waiting\", \"stalled\", \"ended\", \"error\"]) {\n    video.addEventListener(type, () =&gt; rec(type));\n  }\n\n  const hls = new Hls();\n  hls.on(Hls.Events.MANIFEST_PARSED, (_, d) =&gt;\n    rec(\"manifest\", { heights: d.levels.map((l) =&gt; l.height), subtitleTracks: hls.subtitleTracks.length }));\n  hls.on(Hls.Events.LEVEL_SWITCHED, (_, d) =&gt; rec(\"level\", { height: hls.levels[d.level].height }));\n  hls.on(Hls.Events.ERROR, (_, d) =&gt; rec(\"hls-error\", { details: d.details, fatal: d.fatal }));\n  hls.loadSource(\"/media/master.m3u8\");\n  hls.attachMedia(video);\n  video.play().catch((e) =&gt; rec(\"play-rejected\", { name: e.name }));\n\n  video.addEventListener(\"ended\", () =&gt; {\n    const q = video.getVideoPlaybackQuality();\n    rec(\"quality\", { total: q.totalVideoFrames, dropped: q.droppedVideoFrames });\n    window.__done = true;\n  });\n&lt;/script&gt;</code></pre>\n\n<p>Verdicts come only from that log, and a contract with no signal in this stream reports NOT TESTED:</p>\n\n<pre class=\"language-javascript\"><code class=\"language-javascript\">// One verdict per contract, computed only from the session's event log.\n// A contract with no signal in this stream says NOT TESTED; it never passes.\nconst POLICY = { startupMs: 3000, rebufferRatio: 0.005, droppedRatio: 0.01, recoveryMs: 10000, topHeight: 720, topShare: 0.8 };\n\nexport function verdicts(log) {\n  const first = (type) =&gt; log.find((e) =&gt; e.type === type);\n  const manifest = first(\"manifest\");\n  const playing = first(\"playing\");\n  const ended = first(\"ended\");\n  const quality = first(\"quality\");\n\n  // A stall is a `waiting` after playback began, closed by the next `playing`.\n  const stalls = [];\n  for (const e of log) {\n    if (!playing || e.t &lt;= playing.t) continue;\n    if (e.type === \"waiting\") stalls.push({ from: e.t, at: e.ct, buf: e.buf, to: null });\n    if (e.type === \"playing\" &amp;&amp; stalls.at(-1)?.to === null) stalls.at(-1).to = e.t;\n  }\n  const stallMs = stalls.reduce((sum, s) =&gt; sum + ((s.to ?? ended.t) - s.from), 0);\n  const watchMs = ended.t - playing.t;\n  const ratio = stallMs / watchMs;\n  // Share of the session, first `playing` to `ended`, spent on the top rendition.\n  const levels = log.filter((e) =&gt; e.type === \"level\");\n  let topMs = 0;\n  levels.forEach((e, i) =&gt; {\n    const from = Math.max(e.t, playing.t);\n    const to = levels[i + 1]?.t ?? ended.t;\n    if (e.height === POLICY.topHeight) topMs += Math.max(0, to - from);\n  });\n  const topShare = topMs / watchMs;\n  const fatal = log.filter((e) =&gt; e.type === \"hls-error\" &amp;&amp; e.fatal);\n  const longest = Math.max(0, ...stalls.map((s) =&gt; (s.to ?? ended.t) - s.from));\n\n  const row = (contract, verdict, evidence) =&gt; `${contract.padEnd(13)} ${verdict.padEnd(10)} ${evidence}`;\n  const ok = (cond) =&gt; (cond ? \"PASS\" : \"FAIL\");\n  return [\n    row(\"contract\", \"verdict\", \"evidence\"),\n    row(\"video start\", ok(!!playing), playing ? \"playing fired\" : \"playing never fired\"),\n    row(\"startup\", ok(playing.t &lt;= POLICY.startupMs), `first playing at ${playing.t} ms (limit ${POLICY.startupMs})`),\n    row(\"continuity\", ok(ratio &lt;= POLICY.rebufferRatio),\n      `${stalls.length} stall(s), ${stallMs} ms of ${watchMs} ms = ${(ratio * 100).toFixed(2)}%` +\n      stalls.map((s) =&gt; `; waiting at ${s.at}s, buffered ${JSON.stringify(s.buf)}`).join(\"\")),\n    row(\"adaptation\", ok(topShare &gt;= POLICY.topShare),\n      `${levels.map((e) =&gt; `${e.height}p`).join(\" -&gt; \")}, ${(topShare * 100).toFixed(0)}% of session at ${POLICY.topHeight}p`),\n    row(\"presentation\", ok(quality.dropped / quality.total &lt;= POLICY.droppedRatio),\n      `${quality.dropped} of ${quality.total} frames dropped`),\n    row(\"recovery\", ok(fatal.length === 0 &amp;&amp; longest &lt;= POLICY.recoveryMs),\n      `${fatal.length} fatal error(s), longest stall ${longest} ms`),\n    row(\"captions\", \"NOT TESTED\", `${manifest.subtitleTracks} subtitle rendition(s) in the manifest`),\n    row(\"av sync\", \"NOT TESTED\", \"no sync marker in the media\"),\n    row(\"entitlement\", \"NOT TESTED\", \"clear stream, no key system\"),\n    row(\"ads\", \"NOT TESTED\", \"no ad markers in the playlist\"),\n  ];\n}</code></pre>\n\n<p>The runner starts a fresh server per scenario and waits for <code>ended</code>:</p>\n\n<pre class=\"language-javascript\"><code class=\"language-javascript\">// Plays the local stream once per scenario in Playwright's Chromium, prints\n// the raw event log, then a verdict per contract.\nimport { chromium } from \"playwright\";\nimport { serve } from \"./server.mjs\";\nimport { verdicts } from \"./contracts.mjs\";\n\nconst scenarios = [\n  { name: \"clean\", delay: \"\" },\n  { name: \"seg04-held-8s\", delay: \"seg04.m4s=8000\" },\n];\n\nconst browser = await chromium.launch();\nconsole.log(`chromium ${browser.version()}`);\nfor (const s of scenarios) {\n  const server = await serve(s.delay);\n  const page = await browser.newPage();\n  await page.goto(`http://localhost:${server.address().port}/`);\n  await page.waitForFunction(() =&gt; window.__done === true, null, { timeout: 90_000 });\n  const log = await page.evaluate(() =&gt; window.__log);\n  console.log(`\\n=== ${s.name} ===`);\n  for (const e of log) console.log(JSON.stringify(e));\n  console.log(\"\");\n  for (const row of verdicts(log)) console.log(row);\n  await page.close();\n  server.close();\n}\nawait browser.close();</code></pre>\n\n<pre class=\"language-bash\"><code class=\"language-bash\">node session.mjs</code></pre>\n\n<p>Both sessions play in real time, so the run takes about 55 seconds. This is its output, unedited:</p>\n\n<pre class=\"language-text\"><code class=\"language-text\">chromium 151.0.7922.34\n\n=== clean ===\n{\"t\":3,\"type\":\"waiting\",\"ct\":0,\"buf\":[]}\n{\"t\":5,\"type\":\"manifest\",\"ct\":0,\"buf\":[],\"heights\":[360,720],\"subtitleTracks\":0}\n{\"t\":35,\"type\":\"loadedmetadata\",\"ct\":0,\"buf\":[]}\n{\"t\":204,\"type\":\"playing\",\"ct\":0,\"buf\":[[0,24.07]]}\n{\"t\":204,\"type\":\"level\",\"ct\":0,\"buf\":[[0,24.07]],\"height\":720}\n{\"t\":24320,\"type\":\"ended\",\"ct\":24.07,\"buf\":[[0,24.07]]}\n{\"t\":24321,\"type\":\"quality\",\"ct\":24.07,\"buf\":[[0,24.07]],\"total\":720,\"dropped\":0}\n\ncontract      verdict    evidence\nvideo start   PASS       playing fired\nstartup       PASS       first playing at 204 ms (limit 3000)\ncontinuity    PASS       0 stall(s), 0 ms of 24116 ms = 0.00%\nadaptation    PASS       720p, 100% of session at 720p\npresentation  PASS       0 of 720 frames dropped\nrecovery      PASS       0 fatal error(s), longest stall 0 ms\ncaptions      NOT TESTED 0 subtitle rendition(s) in the manifest\nav sync       NOT TESTED no sync marker in the media\nentitlement   NOT TESTED clear stream, no key system\nads           NOT TESTED no ad markers in the playlist\n\n=== seg04-held-8s ===\n{\"t\":3,\"type\":\"waiting\",\"ct\":0,\"buf\":[]}\n{\"t\":4,\"type\":\"manifest\",\"ct\":0,\"buf\":[],\"heights\":[360,720],\"subtitleTracks\":0}\n{\"t\":25,\"type\":\"loadedmetadata\",\"ct\":0,\"buf\":[]}\n{\"t\":36,\"type\":\"playing\",\"ct\":0,\"buf\":[[0,7.96]]}\n{\"t\":36,\"type\":\"level\",\"ct\":0,\"buf\":[[0,7.96]],\"height\":720}\n{\"t\":7996,\"type\":\"waiting\",\"ct\":7.91,\"buf\":[[0,7.96]]}\n{\"t\":8007,\"type\":\"hls-error\",\"ct\":7.91,\"buf\":[[0,7.96]],\"details\":\"bufferStalledError\",\"fatal\":false}\n{\"t\":8052,\"type\":\"playing\",\"ct\":7.94,\"buf\":[[0,9.96]]}\n{\"t\":10059,\"type\":\"waiting\",\"ct\":9.92,\"buf\":[[0,9.96]]}\n{\"t\":10107,\"type\":\"hls-error\",\"ct\":9.92,\"buf\":[[0,9.96]],\"details\":\"bufferStalledError\",\"fatal\":false}\n{\"t\":16048,\"type\":\"hls-error\",\"ct\":9.92,\"buf\":[[0,9.96]],\"details\":\"bufferAppendNoProgress\",\"fatal\":false}\n{\"t\":16049,\"type\":\"level\",\"ct\":9.92,\"buf\":[[0,9.96]],\"height\":360}\n{\"t\":16053,\"type\":\"playing\",\"ct\":9.96,\"buf\":[[0,13.97]]}\n{\"t\":30204,\"type\":\"ended\",\"ct\":24.07,\"buf\":[[0,24.07]]}\n{\"t\":30205,\"type\":\"quality\",\"ct\":24.07,\"buf\":[[0,24.07]],\"total\":720,\"dropped\":12}\n\ncontract      verdict    evidence\nvideo start   PASS       playing fired\nstartup       PASS       first playing at 36 ms (limit 3000)\ncontinuity    FAIL       2 stall(s), 6050 ms of 30168 ms = 20.05%; waiting at 7.91s, buffered [[0,7.96]]; waiting at 9.92s, buffered [[0,9.96]]\nadaptation    FAIL       720p -&gt; 360p, 53% of session at 720p\npresentation  FAIL       12 of 720 frames dropped\nrecovery      PASS       0 fatal error(s), longest stall 5994 ms\ncaptions      NOT TESTED 0 subtitle rendition(s) in the manifest\nav sync       NOT TESTED no sync marker in the media\nentitlement   NOT TESTED clear stream, no key system\nads           NOT TESTED no ad markers in the playlist</code></pre>\n\n<h2 id=\"sqm-reading-the-verdicts\">What the two verdict tables say</h2>\n\n<p><strong>Start and startup pass in both.</strong> The faulted session reported its first <code>playing</code> after 36 milliseconds, against 204 for the clean one. The head start is localhost noise, not a property of the stream, and a start chart cannot see anything after the first frame anyway.</p>\n\n<p><strong>Continuity fails, and the log shows why.</strong> The first freeze began at 7.91 seconds with media buffered to 7.96: the buffer ran dry exactly at the held segment, and that freeze lasted 56 milliseconds because the segment arrived 8 seconds after it was requested. The second freeze lasted 5,994 milliseconds and began at 9.92 seconds, after segment 4 was already in the buffer. Nothing in the fault explains a second freeze, so a second run added two listeners for hls.js fragment events, logging each fragment's sequence number and level index (0 is 360p, 1 is 720p):</p>\n\n<pre class=\"language-javascript\"><code class=\"language-javascript\">for (const ev of [\"FRAG_LOADING\", \"FRAG_LOADED\"]) {\n  hls.on(Hls.Events[ev], (_, d) =&gt; rec(ev, { sn: d.frag.sn, lvl: d.frag.level }));\n}</code></pre>\n\n<pre class=\"language-text\"><code class=\"language-text\">{\"t\":39,\"type\":\"FRAG_LOADING\",\"ct\":0,\"buf\":[[0,7.96]],\"sn\":4,\"lvl\":1}\n{\"t\":8045,\"type\":\"FRAG_LOADED\",\"ct\":7.84,\"buf\":[[0,7.96]],\"sn\":4,\"lvl\":1}\n{\"t\":8051,\"type\":\"FRAG_LOADING\",\"ct\":7.85,\"buf\":[[0,9.96]],\"sn\":4,\"lvl\":0}\n{\"t\":16058,\"type\":\"FRAG_LOADED\",\"ct\":9.92,\"buf\":[[0,9.96]],\"sn\":4,\"lvl\":0}\n{\"t\":16059,\"type\":\"hls-error\",\"ct\":9.92,\"buf\":[[0,9.96]],\"details\":\"bufferAppendNoProgress\",\"fatal\":false}\n{\"t\":16060,\"type\":\"level\",\"ct\":9.92,\"buf\":[[0,9.96]],\"height\":360}</code></pre>\n\n<p>After segment 4 took 8 seconds at 720p, the player switched down and requested segment 4 again at 360p. The lab holds segment 4 in every rendition, so that request waited 8 seconds too, and playback froze until it arrived. Its append then produced <code>bufferAppendNoProgress</code>, which hls.js raises when appending a whole fragment does not extend the buffered coverage; 8 to 10 seconds was already buffered from the 720p copy. One slow response cost two freezes and a wasted download: the player's reaction cost more than the fault, and only the continuity row, read with the buffer, shows it.</p>\n\n<p><strong>Adaptation fails at 53%.</strong> From 16 seconds of wall clock the player showed 360p, and the rest of this short stream then loaded at 360p within milliseconds, leaving nothing to upgrade. The verdict is still the viewer's truth: almost half the session ran at the lower rendition on a connection that could carry the higher one.</p>\n\n<p><strong>Presentation is the noisy row.</strong> It failed here on 12 dropped frames, yet passed in another run of the same session. A row that flips on an unchanged stream belongs on the device it describes, not in a desktop gate.</p>\n\n<p><strong>Recovery passes.</strong> Both <code>bufferStalledError</code> events were non-fatal and the longest freeze stayed under 10 seconds. A test watching only for fatal errors would have passed this session outright.</p>\n\n<p><strong>Four rows say NOT TESTED.</strong> The stream has no subtitle rendition, no sync marker, no key system and no ad markers. Without those rows the clean session reads six out of six; with them, six of ten, which is what the lab actually knows.</p>\n\n<h2 id=\"sqm-costs-and-limits\">What this model costs, and where it stops</h2>\n\n<p>The thresholds are policy. Three seconds to start, 0.5% rebuffering and 80% of the session on the top rendition are this lab's numbers, and no specification sets any of them. Derive yours from your own sessions before a verdict means anything.</p>\n\n<p>One session is an anecdote. A rebuffer ratio becomes a gate only across many sessions, split by device family and network; the verdict table is the unit those aggregates are built from.</p>\n\n<p>Real-time playback is the price of honest timing: 55 seconds for 48 seconds of media. Raising <code>playbackRate</code> changes how fast the buffer drains, which is the very thing continuity measures.</p>\n\n<p>A desktop browser stops at the device boundary. Sync, decoder drops and output restrictions need the viewer's television, set-top box or phone; this lab tells you which rows still need that hardware. If you embed a third-party player you cannot instrument, keep its unobservable rows in the table as NOT TESTED so the gap stays visible.</p>\n\n<h2 id=\"sqm-questions\">Questions about modelling stream quality</h2>\n\n<h3 id=\"sqm-faq-rebuffer-ratio\">Is a rebuffer ratio enough for continuity?</h3>\n<p>No. A ratio dilutes. One six-second freeze in a two-hour match is about 0.08% of the session, under a 0.5% target, and it is still the moment a goal was missed. Assert the longest single freeze and the number of freezes alongside the ratio.</p>\n\n<h3 id=\"sqm-faq-cdn-logs\">Can CDN logs replace player-side signals?</h3>\n<p>They show that a segment response was slow, not whether the player was waiting for it; a player holding 30 seconds of media can absorb a slow segment unseen. In the lab, the CDN view would hold two 8-second responses with no hint that the second was a needless re-request. Joining both sides needs a shared session identifier.</p>\n\n<h3 id=\"sqm-faq-native-players\">Our TV app uses a native player, not hls.js. Does this transfer?</h3>\n<p>The contracts transfer; the signal sources do not. <code>waiting</code>, <code>playing</code> and <code>buffered</code> are HTML media element behaviour. <code>LEVEL_SWITCHED</code> and the <code>fatal</code> flag are hls.js vocabulary, and a native player reports rendition changes and unrecoverable errors in its own way, if at all. Map each row to what your player reports, and keep the row when it reports nothing.</p>\n\n<h2 id=\"sqm-references\">Specifications behind the session contracts</h2>\n<ul>\n<li><a href=\"https://html.spec.whatwg.org/multipage/media.html\">WHATWG HTML Living Standard, media elements</a>. <code>waiting</code> and <code>playing</code>, <code>waiting</code> fired by <code>play()</code>, and the remote-fetch stall timeout behind <code>stalled</code>.</li>\n<li><a href=\"https://www.w3.org/TR/media-source-2/\">W3C Media Source Extensions, Working Draft</a>. MSE playback skips the remote fetch steps; <code>stalled</code> is likely to be removed for it.</li>\n<li><a href=\"https://w3c.github.io/media-playback-quality/\">W3C Media Playback Quality, Editor's Draft</a>. What <code>droppedVideoFrames</code> counts and when the counters reset.</li>\n<li><a href=\"https://www.rfc-editor.org/rfc/rfc8216\">RFC 8216, HTTP Live Streaming</a>. <code>BANDWIDTH</code>, <code>CLOSED-CAPTIONS</code> with no rendition, and switching left to clients.</li>\n<li><a href=\"https://www.w3.org/TR/encrypted-media-2/\">W3C Encrypted Media Extensions, Working Draft</a>. Key status <code>output-restricted</code> and the secure-context requirement.</li>\n<li><a href=\"https://github.com/video-dev/hls.js/blob/v1.7.4/docs/API.md\">hls.js API documentation at v1.7.4</a>. The <code>fatal</code> flag, the error details seen in the lab, and the 30-second default buffer.</li>\n<li><a href=\"https://ffmpeg.org/ffmpeg-formats.html#hls-2\">FFmpeg formats documentation, HLS muxer</a>. The options used to build the two-rendition lab stream.</li>\n</ul>\n\n<h2 id=\"sqm-apply-this-now\">Apply this now to your playback checks</h2>\n\n<ol>\n<li>Put your current start metric in a table with the eight contracts beside it, and mark each row with the signal you collect today, or NOT TESTED.</li>\n<li>Change the rebuffer counter to count <code>waiting</code> only after the first <code>playing</code>, and remove any alert that depends on <code>stalled</code> for an MSE player.</li>\n<li>Log <code>video.buffered</code> and <code>currentTime</code> with every <code>waiting</code>, so each freeze arrives already routed to delivery or to the decoder.</li>\n<li>Run the held-segment session against your own player build and keep the raw event log with the CI run; the <a href=\"/blog/automation-tutorials/retain-ci-artifacts-explain-failures\">guide to retaining CI artifacts that explain failures</a> covers how long and where. The <a href=\"/tools/json-formatter\">JSON formatter</a> makes a long log readable.</li>\n<li>Name one owner per row, and capture the table and the first held-segment verdicts as the baseline for the next release.</li>\n</ol>\n"}