azot-labs / dasha

Streaming manifest parser

Home Page:https://npm.im/dasha

Repository from Github https://github.comazot-labs/dashaRepository from Github https://github.comazot-labs/dasha

dasha

npm version npm downloads/month npm downloads

Library for parsing MPEG-DASH (.mpd) and HLS (.m3u8) manifests. Made with the purpose of obtaining a simplified representation convenient for further downloading of segments.

Warning

This README is for the alpha version. Info about latest stable version is available on NPM or another GitHub branch.

Install

npm i dasha@alpha

Usage

import fs from 'node:fs/promises';
import { parse } from 'dasha';

const url = 'https://dash.akamaized.net/dash264/TestCases/1a/sony/SNE_DASH_SD_CASE1A_REVISED.mpd';
const streamExtractor = new StreamExtractor();
await streamExtractor.loadSourceFromUrl(url);
const streams = await streamExtractor.extractStreams();

for (const stream of streams) {
  const segments = stream.playlist?.mediaParts[0].mediaSegments || [];
  const filename = `${stream.name}_${stream.groupId}`;
  for (const segment of segments) {
    const content = await fetch(segment.url).then((res) => res.arrayBuffer());
    await fs.appendFile(`${filename}.${stream.extension}`, content);
  }
}

Credits

This project is heavily influenced by the robust implementation found in N_m3u8DL-RE. Special thanks to the open-source community and contributors who make projects like this possible.

Licenses

This project is licensed under the MIT License.

About

Streaming manifest parser

https://npm.im/dasha

License:MIT License


Languages

Language:TypeScript 98.6%Language:JavaScript 1.4%