# googlevideo

> A collection of modules for handling YouTube's custom UMP format and SABR streaming protocol.

Latest version **5.0.1** (published 2026-10-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install googlevideo
pnpm add googlevideo
yarn add googlevideo
bun add googlevideo
```

## 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 | 5.0.1 |
| Published | 2026-10-23 |
| First published | 2024-10-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM |
| Dependencies | 1 |
| Unpacked size | 828.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 180 |
| Author | LuanRT |
| Maintainers | luanrt |
| Keywords | UMP, Ustreamer, SABR, Google, YouTube |

## Links

- npm: https://www.npmjs.com/package/googlevideo
- Repository: https://github.com/LuanRT/GoogleVideo
- Homepage: https://github.com/LuanRT/GoogleVideo#readme
- Issues: https://github.com/LuanRT/GoogleVideo/issues
- Funding: https://github.com/sponsors/LuanRT
- npm.io page: https://npm.io/package/googlevideo

## Dependencies (1)

- [@bufbuild/protobuf](https://npm.io/package/@bufbuild/protobuf.md) ^2.16.0

## Alternatives

- [byte-size](https://npm.io/package/byte-size.md) — 2.1M weekly downloads
- [speed-limiter](https://npm.io/package/speed-limiter.md) — 16.0K weekly downloads
- [@powersync/node](https://npm.io/package/@powersync/node.md) — 10.9K weekly downloads
- [@ledgerhq/coin-cardano](https://npm.io/package/@ledgerhq/coin-cardano.md) — 1.0K weekly downloads
- [@jayesol/jayeson.lib.streamfinder](https://npm.io/package/@jayesol/jayeson.lib.streamfinder.md) — 1.0K weekly downloads

## Recent versions

- 5.0.1 (latest) — 2026-10-23
- 5.0.0 — 2026-10-20
- 4.1.1 — 2026-07-13
- 4.0.4 — 2025-09-15
- 4.0.3 — 2025-08-16
- 4.0.2 — 2025-07-24
- 4.0.1 — 2025-07-22
- 4.0.0 — 2025-07-22
- 3.0.0 — 2025-03-23
- 2.0.0 — 2024-11-02
- 1.1.0 — 2024-10-24
- 1.0.0 — 2024-10-24

## README

# GoogleVideo
[![JSR](https://jsr.io/badges/@luanrt/googlevideo)](https://jsr.io/@luanrt/googlevideo)
[![NPM](https://img.shields.io/npm/v/googlevideo)](https://www.npmjs.com/package/googlevideo)
[![License](https://img.shields.io/github/license/LuanRT/googlevideo)](./LICENSE)

A collection of modules for handling YouTube's custom UMP format and SABR streaming protocol. Use it to build custom clients and downloaders, or integrate with existing media players (e.g., [Shaka Player](https://github.com/shaka-project/shaka-player)).

**[API Reference →](https://ytjs.dev/googlevideo/api)**

## Installation

```bash
# NPM
npm install googlevideo

# JSR / Deno
npx jsr add @luanrt/googlevideo
deno add jsr:@luanrt/googlevideo

# GitHub
npm install LuanRT/googlevideo
```

## Basic Usage
Below is a basic example using the UMP modules to create a buffer, write parts, and then read them:

> [!NOTE] 
> More advanced usage examples can be found in the [/examples](./examples/) directory.

```typescript
import { MediaHeader, UMPPartId } from 'googlevideo/protos';
import { CompositeBuffer, UmpReader, UmpWriter } from 'googlevideo/ump';
import { concatenateChunks } from 'googlevideo/utils';

const umpReader = new UmpReader({
  onPart: (type, data) => {
    switch (type) {
      case UMPPartId.MEDIA_HEADER: {
        const mediaHeader = MediaHeader.decode(concatenateChunks(data.chunks));
        console.log('Media Header:', mediaHeader);
        break;
      }
      case UMPPartId.MEDIA: {
        const headerId = data.getUint8(0);
        console.log(`Media Part (Associated Header ID: ${headerId}):`, data.split(1).remainingBuffer.getLength(), 'bytes');
        break;
      }
      case UMPPartId.MEDIA_END: {
        const headerId = data.getUint8(0);
        console.log(`Media End Part (Associated Header ID: ${headerId}):`, data.split(1).remainingBuffer.getLength(), 'bytes');
        break;
      }
    }
  }
});

function mockUmpData(): CompositeBuffer {
  const buffer = new CompositeBuffer();
  const writer = new UmpWriter(buffer);

  const audioHeaderId = 0;

  const partsToWrite: [UMPPartId, Uint8Array][] = [
    [
      UMPPartId.MEDIA_HEADER,
      MediaHeader.encode({
        itag: 141,
        videoId: "sOa4VVlI9tE",
        headerId: audioHeaderId,
        segmentLengthBytes: "963966",
        segmentByteRangeStart: "5463800",
        isInitializationSegment: false,
        lmt: "1645502668395260",
        segmentNum: 1,
        durationMs: "4000",
        formatId: {
          itag: 141,
          lastModified: "1645502668395260",
          xtags: ""
        },
      }).finish()
    ],
    [UMPPartId.MEDIA, new Uint8Array([audioHeaderId, ...new Uint8Array(827609).fill(0)])],
    [UMPPartId.MEDIA, new Uint8Array([audioHeaderId, ...new Uint8Array(136357).fill(0)])],
    [UMPPartId.MEDIA_END, new Uint8Array([audioHeaderId])]
  ];

  for (const [type, data] of partsToWrite)
    writer.write(type, data);

  return buffer;
}

umpReader.feed(mockUmpData());
```

Expected output:
```
Media Header: { ... }
Media Part (Associated Header ID: 0): 827609 bytes
Media Part (Associated Header ID: 0): 136357 bytes
Media End Part (Associated Header ID: 0): 0 bytes
```

## License
Distributed under the [MIT](./LICENSE) License.

<p align="right">
(<a href="#top">back to top</a>)
</p>

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