JSPM

  • Created
  • Published
  • Downloads 117
  • Score
    100M100P100Q68410F
  • License MIT

Streaming manifest parser

Package Exports

  • dasha

Readme

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@4.0.0-alpha.1

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.