@javagt/n-m3u8dl-re
v0.5.1
Published
TypeScript port of N_m3u8DL-RE v0.5.1 (C#) — cross-platform DASH/HLS/MSS stream downloader. Ported by DeepSeek V4 Flash.
Maintainers
Readme
@javagt/n-m3u8dl-re
Version 0.5.1 — Pure TypeScript port of N_m3u8DL-RE v0.5.1, the C# media stream downloader by nilaoda.
Ported by DeepSeek V4 Flash. Version numbers are kept in sync with the original C# releases.
Installation
npm install @javagt/n-m3u8dl-reLibrary Usage
The library exports every module for programmatic use — parse manifests, download segments, decrypt content, and handle subtitles all from TypeScript/JavaScript.
Download a stream with Widevine keys
import { downloadMedia } from '@javagt/n-m3u8dl-re';
const result = await downloadMedia({
mpdUrl: 'https://.../manifest.mpd',
keys: ['635b2fb2...:0c0a5df3...'],
saveName: 'My Video',
saveDir: '/downloads',
});
console.log(result.success ? `Saved to ${result.outputPath}` : `Failed: ${result.error}`);Parse a DASH manifest programmatically
import { parseMPD, extractDASHStreams } from '@javagt/n-m3u8dl-re';
const streams = extractDASHStreams(mpdXml, 'https://example.com/base/');
for (const stream of streams) {
console.log(stream.bandwidth, stream.codecs, stream.resolution);
}Parse an HLS playlist
import { HLSParser, isHLSUrl } from '@javagt/n-m3u8dl-re';
const parser = new HLSParser();
const result = parser.parse(m3u8Content);
console.log(result.variants?.length, 'variant streams found');Decrypt an MP4 with CENC keys
import { decryptMP4 } from '@javagt/n-m3u8dl-re';
await decryptMP4('encrypted.mp4', 'decrypted.mp4', '635b2fb2...', '0c0a5df3...');Parse MP4 box structure
import { parseChildren, findBox, BoxReader } from '@javagt/n-m3u8dl-re';
const boxes = parseChildren(mp4Buffer);
const moov = findBox(boxes, 'moov');
// Extract DRM info, codecs, etc.Download segments with progress
import { DownloadManager } from '@javagt/n-m3u8dl-re';
const manager = new DownloadManager({ threadCount: 4 });
const results = await manager.downloadVOD(segments);Subtitle processing
import { parseVTT, convertVTTtoSRT, parseTTML, mergeSubtitleFiles } from '@javagt/n-m3u8dl-re';MSS (Smooth Streaming)
import { extractMSSStreams, synthesizeMoov, parseISM } from '@javagt/n-m3u8dl-re';ESM Imports
All modules are available as named ESM imports:
// Parsers
import { parseMPD, extractDASHStreams } from '@javagt/n-m3u8dl-re';
import { HLSParser, parseHLSContent } from '@javagt/n-m3u8dl-re';
import { extractMSSStreams, parseISM } from '@javagt/n-m3u8dl-re';
// Crypto
import { decryptMP4, aes128Decrypt, ChaCha20 } from '@javagt/n-m3u8dl-re';
// MP4
import { parseChildren, findBox, BoxReader, BoxWriter } from '@javagt/n-m3u8dl-re';
import { parsePssh, parseTenc, extractDRMFromMoov } from '@javagt/n-m3u8dl-re';
// Download
import { DownloadManager, HttpClient, MergeManager } from '@javagt/n-m3u8dl-re';
// Subtitles
import { parseVTT, parseTTML, parseSRT } from '@javagt/n-m3u8dl-re';
// CLI (for tools that need the full pipeline)
import { cliMain, parseCLI, parseFilter } from '@javagt/n-m3u8dl-re';Features
- DASH: Parse MPD manifests with SegmentTemplate, SegmentTimeline, and ContentProtection
- HLS: Parse M3U8 playlists with AES-128 encryption, variant streams, and live support
- MSS: Parse Microsoft Smooth Streaming ISM manifests with FourCC codec handling
- MP4: Binary parsing for DRM extraction, codec configuration, and moov synthesis
- Download: Parallel segment downloading with HTTP range requests
- Encryption: AES-128-CBC and ChaCha20 decryption support
Installation
npm install
npm run buildUsage
npx tsx src/cli/index.ts <url> [options]Project Structure
src/
parser/ # Manifest parsers (DASH, HLS, MSS)
mp4/ # MP4 binary parsing and moov synthesis
crypto/ # Encryption/decryption
download/ # Segment downloading
cli/ # Command-line interfaceDocumentation
See ../N_m3u8DL-RE/docs/features/ for feature specifications.
License
MIT
Ported from N_m3u8DL-RE (MIT) by DeepSeek V4 Flash.
