0.0.29 • Published 5 years ago

hlx-lib v0.0.29

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

Build Status Coverage Status Dependency Status Development Dependency Status Known Vulnerabilities XO code style

hlx-lib

A library for processing HLS streams in Node.js

Features

  • It exposes gulp like interface for processing an HLS stream as Node's object mode stream.
  • The stream is represented as a series of data events of hls-parser objects.
  • To process the stream, users just need to insert their own Transform stream between the src and dest.

Install

NPM

Usage

Example 1 - Default source / destination

const hlx = require('hlx'); // hlx-lib can be transparently referenced via hlx module
const {createDecryptor} = require('hlx-decryptor');
const decryptor = createDecryptor('AES-128');

// Store all decrypted files in /var/www/media/
hlx.src('https://foo.bar/sample.m3u8')
.pipe(decryptor)
.pipe(hlx.dest('/var/www/media/'));

Example 2 - Custom source

const hlx = require('hlx');
const {createReadStream} = require('hlx-src-webdav-pull');
const reader = createReadStream({
  url: 'http://foo.bar/webdav',
  user: {WebDAV user},
  pass: {WebDAV password}
});

// Store all decrypted files in /var/www/media/
hlx.src(reader)
.pipe(decryptor)
.pipe(hlx.dest('/var/www/media/'));

Example 3 - Custom destination

const hlx = require('hlx');
const {createReadStream} = require('hlx-dest-http-server');
const writer = createWriteStream({
  port: 8080,
  prefix: 'media',
  outputDir: '/var/www/media/'
});

// Host the stream at http://localhost:8080/media/sample.m3u8
hlx.src('https://foo.bar/sample.m3u8')
.pipe(decryptor)
.pipe(hlx.dest(writer));

API

src(location[, options])

Creates a new stream.Readable object.

params

NameTypeRequiredDefaultDescription
locationstring or stream.ReadableYesN/AIt should be either of a local file path, a url of the playlist, or a custom source object (stream.Readable)
optionsobjectNo{}See below

options

NameTypeDefaultDescription
noUriConversionbooleanfalsePassing true will prevent any URI conversions done internally. The default behavior is to convert all URIs into paths relative to the master playlist

You can also pass the options for hlx-file-reader's createReadStream and hlx-url-rewriter's 'createUrlRewriter, which will be relayed to those modules internally.

return value

An instance of stream.Readable. When the location is a local file path or a url, the hlx-file-reader stream will be created. Otherwise, the passed readable stream will be returned back.

dest(location[, options])

Creates a new stream.Writable object.

params

NameTypeRequiredDefaultDescription
locationstring or stream.WritableNonullIt should be either of a local file path or a custom destination object (stream.Writable)
optionsobjectNo{}See below

options

NameTypeDefaultDescription
inputDirstring/The root directory from which all the files are read (This option is only used in case of file: urls)

return value

When the location is a local file path, the hlx-file-writer stream will be created. Otherwise, the passed writable stream will be returned back.

0.0.29

5 years ago

0.0.28

5 years ago

0.0.27

5 years ago

0.0.26

5 years ago

0.0.25

5 years ago

0.0.24

5 years ago

0.0.23

5 years ago

0.0.22

5 years ago

0.0.21

5 years ago

0.0.20

5 years ago

0.0.19

5 years ago

0.0.18

5 years ago

0.0.17

5 years ago

0.0.16

5 years ago

0.0.15

5 years ago

0.0.14

5 years ago

0.0.13

5 years ago

0.0.12

5 years ago

0.0.11

5 years ago

0.0.10

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago