GithubHelp home page GithubHelp logo

liuliaixue / node-m3u8stream Goto Github PK

View Code? Open in Web Editor NEW

This project forked from fent/node-m3u8stream

0.0 1.0 0.0 7.3 MB

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

License: MIT License

JavaScript 67.61% TypeScript 32.39%

node-m3u8stream's Introduction

node-m3u8stream

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

Build Status Dependency Status 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 - number
    • 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.

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

node-m3u8stream's People

Contributors

dependabot-preview[bot] avatar fent avatar greenkeeper[bot] avatar selfisekai avatar sky0014 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.