• Stars
    star
    213
  • Rank 185,410 (Top 4 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 7 years ago
  • Updated 6 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Concatenates segments from a m3u8/dash-mpd playlist into a consumable stream.

node-m3u8stream

Reads segments from a m3u8 playlist or DASH MPD file into a consumable stream.

Depfu codecov

Usage

const fs = require('fs');
const m3u8stream = require('m3u8stream')

m3u8stream('http://somesite.com/link/to/the/playlist.m3u8')
    .pipe(fs.createWriteStream('videofile.mp4'));

API

m3u8stream(url, [options])

Creates a readable stream of binary media data. options can have the following

  • begin - Where to begin playing the video. Accepts an absolute unix timestamp or date and a relative time in the formats 1:23:45.123 and 1m2s.
  • liveBuffer - How much buffer in milliseconds to have for live streams. Default is 20000.
  • chunkReadahead - How many chunks to preload ahead. Default is 3.
  • highWaterMark - How much of the download to buffer into the stream. See node's docs for more. Note that the actual amount buffered can be higher since each chunk request maintains its own buffer.
  • requestOptions - Any options you want to pass to miniget, such as headers.
  • parser - Either "m3u8" or "dash-mpd". Defaults to guessing based on the playlist url ending in .m3u8 or .mpd.
  • id - For playlist containing multiple media options. If not given, the first representation will be picked.

Stream#end()

If called, stops requesting segments, and refreshing the playlist.

Event: progress

  • Object - Current segment with the following fields,
    • number - num
    • number - size
    • number - duration
    • string - url
  • number - Total number of segments.
  • number - Bytes downloaded up to this point.

For static non-live playlists, emitted each time a segment has finished downloading. Since total download size is unknown until all segment endpoints are hit, progress is calculated based on how many segments are available.

miniget events

All miniget events are forwarded and can be listened to from the returned stream.

m3u8stream.parseTimestamp(time)

Converts human friendly time to milliseconds. Supports the format
00:00:00.000 for hours, minutes, seconds, and milliseconds respectively.
And 0ms, 0s, 0m, 0h, and together 1m1s.

  • time - A string (or number) giving the user-readable input data

Limitations

Currently, it does not support encrypted media segments. This is because the sites where this was tested on and intended for, YouTube and Twitch, don't use it.

This does not parse master playlists, only media playlists. If you want to parse a master playlist to get links to media playlists, you can try the m3u8 module.

Install

npm install m3u8stream

Tests

Tests are written with mocha

npm test

More Repositories

1

node-ytdl-core

YouTube video downloader in javascript.
JavaScript
4,507
star
2

randexp.js

Create random strings that match a given regular expression.
JavaScript
1,779
star
3

node-ytdl

Command line youtube video downloader.
JavaScript
1,188
star
4

node-feedsub

Subscribes to RSS/Atom/JSON feeds and notifies on new items.
TypeScript
196
star
5

timequeue.js

A queue with custom concurrency and time limit.
TypeScript
191
star
6

node-torrent

Torrent reader, writer, and hash checker for node.
JavaScript
190
star
7

feedme.js

RSS/Atom/JSON feed parser
TypeScript
155
star
8

clusterhub

Sync data in your cluster applications.
JavaScript
131
star
9

ret.js

Tokenizes a string that represents a regular expression.
JavaScript
90
star
10

socket.io-clusterhub

socket.io storage powered by clusterhub for multi process applications.
JavaScript
70
star
11

chrome-options

Options page for Chrome extensions
JavaScript
64
star
12

node-muk

Mock object methods and dependencies.
JavaScript
57
star
13

node-miniget

A small http(s) GET library.
TypeScript
52
star
14

node-streamify

Streamify helps you easily provide a streaming interface for your code.
JavaScript
51
star
15

pauseable.js

Create event emitters, intervals, and timeouts that can be paused and resumed.
JavaScript
47
star
16

node-streamspeed

A simple way to keep track of the speed of your node streams.
TypeScript
38
star
17

irc-colors.js

Color and formatting for irc bots made easy. Inspired by colors.js and cli-color.
JavaScript
35
star
18

node-kat

File and stream concatenation the right way.
JavaScript
25
star
19

node-stream-equal

Test that two readable streams are equal to each other.
TypeScript
24
star
20

node-streamin

Provide a better streaming api in your app.
JavaScript
20
star
21

npm-updates

Emits update events from the npm repository.
JavaScript
16
star
22

node-jstream

Continuously reads in JSON and outputs Javascript objects.
JavaScript
16
star
23

muk-prop.js

Mock object methods and properties
JavaScript
12
star
24

hook.io-feedsub

hook.io bindings for RSS/Atom/JSON feeds
JavaScript
11
star
25

node-eventyoshi

Allows several event emitters to be listened and emitted through a single one.
JavaScript
11
star
26

node-torrent-cli

CLI for reading, writing, and hash checking torrents
JavaScript
10
star
27

chrome-veefeed

Follow YouTube and Twitch channels, get notifications, categorize videos
JavaScript
9
star
28

pokecry

guess pokemon through their cries
JavaScript
8
star
29

node-newsemitter

An event emitter that emits only new events.
TypeScript
7
star
30

clusterchat

A simple multi process chat demo using socket.io-clusterhub
JavaScript
7
star
31

ordered-queue.js

Queue with concurrency that starts tasks in order and runs them in parallel.
JavaScript
7
star
32

node-module-boilerplate

My personal boilerplate that I use to create node modules.
JavaScript
6
star
33

vim-relative-indent

Hide leading indent
Vim Script
5
star
34

hook.io-npm

Hook that emits on npm module updates.
JavaScript
5
star
35

jps

A scraper for the jpopsuki tracker.
JavaScript
5
star
36

nickserv

Communicates with the NickServ IRC service
JavaScript
5
star
37

node-streamit

JavaScript
4
star
38

ann

IRC bot made to announce and for convenience.
CoffeeScript
4
star
39

vim-frozen

colorscheme for vim
Vim Script
3
star
40

twi

really basic twitter cli client
JavaScript
3
star
41

node-writestreamp

A writable file stream that creates directories as needed.
JavaScript
3
star
42

gifchat

gifphy bot for hipchat
JavaScript
2
star
43

queue2.js

A unordered queue and ordered queue working together.
JavaScript
2
star
44

pokenum

A way to remember numbers using Pokemon.
JavaScript
1
star
45

node-muk-require

Mock dependencies
JavaScript
1
star
46

nickie

Nickserv irc bot.
JavaScript
1
star
47

node-callme

Hey I just met you, and this is crazy, but here's my callback.
JavaScript
1
star
48

jquery.rubber.js

jQuery plugin that stretches text fields to fit their content.
JavaScript
1
star