# @svta/cml-cmcd

> Common Media Client Data (CMCD) encoding and decoding

Latest version **2.7.0** (published 2026-09-15) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @svta/cml-cmcd
pnpm add @svta/cml-cmcd
yarn add @svta/cml-cmcd
bun add @svta/cml-cmcd
```

## Health

**Score 65/100 (B)** — status: active.

Positive: esm support; no vulnerabilities; has provenance; recently updated; high maintenance score.

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 2.7.0 |
| Published | 2026-09-15 |
| First published | 2025-10-08 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | ESM |
| Node | >=20 |
| Dependencies | 0 |
| Unpacked size | 457.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 84 |
| Maintainers | littlespex, jason_n_thibeault |
| Keywords | Common Media Library, CML, CMCD, CTA-5004, Common Media Client Data |

## Links

- npm: https://www.npmjs.com/package/@svta/cml-cmcd
- Repository: https://github.com/streaming-video-technology-alliance/common-media-library
- Homepage: https://github.com/streaming-video-technology-alliance/common-media-library/tree/main/libs/cmcd
- Issues: https://github.com/streaming-video-technology-alliance/common-media-library/issues
- npm.io page: https://npm.io/package/@svta/cml-cmcd

## Recent versions

- 2.7.0 (latest) — 2026-09-15
- 2.6.1 — 2026-09-08
- 2.6.0 — 2026-09-04
- 2.5.0 — 2026-07-28
- 2.4.1 — 2026-07-21
- 2.4.0 — 2026-05-24
- 2.3.2 — 2026-05-13
- 2.3.1 — 2026-04-30
- 2.3.0 — 2026-04-15
- 2.2.0 — 2026-02-23
- 2.1.2 — 2026-02-12
- 2.1.1 — 2026-02-09
- 2.1.0 — 2026-02-06
- 2.0.1 — 2026-02-05
- 2.0.0 — 2026-02-03
- … 7 more at https://npm.io/package/@svta/cml-cmcd/versions

## README

# @svta/cml-cmcd

Common Media Client Data (CMCD) encoding and decoding.

## Installation

```bash
npm i @svta/cml-cmcd
```

## Usage

```typescript
import { CmcdReportingMode, encodeCmcd } from "@svta/cml-cmcd";

const input = {
	br: 1000,
	"com.example-hello": "world",
	ec: ["ERR001", "ERR002"],
	su: true,
};
const options = { version: 2, reportingMode: CmcdReportingMode.REQUEST };
const result = encodeCmcd(input, options);
// result === 'br=1000,com.example-hello="world",ec=("ERR001" "ERR002"),su,v=2'
```

## Testing CMCD output with `CmcdReportRecorder`

`CmcdReportRecorder` captures the CMCD requests that a player under test
sends, whether through `XMLHttpRequest` or `fetch`. Each capture is
normalized to
[`HttpRequest`](https://github.com/streaming-video-technology-alliance/common-media-library/tree/main/libs/utils),
so tests work the same for both transports.

````ts
import { CmcdReportRecorder, validateCmcdRequest } from '@svta/cml-cmcd'

const recorder = new CmcdReportRecorder()
recorder.attach({ eventTargetUrls: ['https://events.example.com'] })

// ... configure and start the player under test ...

const segments = await recorder.waitForSegments({ count: 3 })
for (const r of segments) {
  const result = validateCmcdRequest(r.request)
  if (!result.valid) {
    console.error(result.issues)
  }
}

recorder.detach()
````

---
_Source: https://npm.io/package/@svta/cml-cmcd · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
